itizawa 5 лет назад
Родитель
Сommit
db8a90dd26

+ 5 - 4
src/client/js/components/PageHistory/PageRevisionList.jsx

@@ -73,6 +73,11 @@ class PageRevisionList extends React.Component {
     let hasDiffPrev;
 
     const revisionList = this.props.revisions.map((revision, idx) => {
+      // Returns null because the last revision is for the bottom diff display
+      if (idx === pageHistoryContainer.state.pagingLimit) {
+        return null;
+      }
+
       let previousRevision;
       if (idx + 1 < revisionCount) {
         previousRevision = revisions[idx + 1];
@@ -81,10 +86,6 @@ class PageRevisionList extends React.Component {
         previousRevision = revision; // if it is the first revision, show full text as diff text
       }
 
-      // Returns null because the last revision is for the bottom diff display
-      if (idx === pageHistoryContainer.state.pagingLimit) {
-        return null;
-      }
 
       const hasDiff = revision.hasDiffToPrev !== false; // set 'true' if undefined for backward compatibility
       const isContiguousNodiff = !hasDiff && !hasDiffPrev;

+ 6 - 5
src/client/js/services/PageHistoryContainer.js

@@ -28,7 +28,7 @@ export default class PageHistoryContainer extends Container {
 
       totalPages: 0,
       activePage: 1,
-      pagingLimit: appContainer.getConfig().showPageLimitationS || 10,
+      pagingLimit: 10,
     };
 
     this.retrieveRevisions = this.retrieveRevisions.bind(this);
@@ -50,8 +50,9 @@ export default class PageHistoryContainer extends Container {
    */
   async retrieveRevisions(selectedPage) {
     const { pageId, shareLinkId } = this.pageContainer.state;
+    const { pagingLimit } = this.state;
     const page = selectedPage;
-    const pagingLimitForShow = this.state.pagingLimit;
+    const pagingLimitForApiParam = pagingLimit + 1;
 
     if (!pageId) {
       return;
@@ -59,14 +60,14 @@ export default class PageHistoryContainer extends Container {
 
     // Get one more for the bottom display
     const res = await this.appContainer.apiv3Get('/revisions/list', {
-      pageId, shareLinkId, page, limit: pagingLimitForShow + 1,
+      pageId, shareLinkId, page, limit: pagingLimitForApiParam,
     });
     const rev = res.data.docs;
     // set Pagination state
     this.setState({
       activePage: selectedPage,
       totalPages: res.data.totalDocs,
-      pagingLimit: pagingLimitForShow,
+      pagingLimit,
     });
 
     const diffOpened = {};
@@ -74,7 +75,7 @@ export default class PageHistoryContainer extends Container {
     let lastId = rev.length - 1;
 
     // If the number of rev count is the same, the last rev is for diff display, so exclude it.
-    if (rev.length === pagingLimitForShow + 1) {
+    if (rev.length > pagingLimit) {
       lastId = rev.length - 2;
     }
 

+ 0 - 1
src/server/models/config.js

@@ -192,7 +192,6 @@ module.exports = function(crowi) {
         file: crowi.fileUploadService.getFileUploadEnabled(),
       },
       registrationWhiteList: crowi.configManager.getConfig('crowi', 'security:registrationWhiteList'),
-      showPageLimitationS: crowi.configManager.getConfig('crowi', 'customize:showPageLimitationS'),
       layoutType: crowi.configManager.getConfig('crowi', 'customize:layout'),
       themeType: crowi.configManager.getConfig('crowi', 'customize:theme'),
       isEnabledLinebreaks: crowi.configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks'),

+ 22 - 0
src/server/service/search-delegator/elasticsearch.js

@@ -352,6 +352,11 @@ class ElasticsearchDelegator {
     return this.updateOrInsertPages(() => Page.findById(pageId));
   }
 
+  updateOrInsertPageById(pageIds) {
+    const Page = mongoose.model('Page');
+    return this.updateOrInsertPages(() => Page.find({ _id: { $in: pageIds } }));
+  }
+
   /**
    * @param {function} queryFactory factory method to generate a Mongoose Query instance
    */
@@ -951,6 +956,23 @@ class ElasticsearchDelegator {
     return this.updateOrInsertPageById(page._id);
   }
 
+  async syncPagesUpdated(pages, user) {
+    logger.debug('SearchClient.syncPageUpdated', page.path);
+
+    // delete if page should not indexed
+    if (!this.shouldIndexed(page)) {
+      try {
+        await this.deletePages([page]);
+      }
+      catch (err) {
+        logger.error('deletePages:ES Error', err);
+      }
+      return;
+    }
+
+    return this.updateOrInsertPageById(page._id);
+  }
+
   async syncPageDeleted(page, user) {
     logger.debug('SearchClient.syncPageDeleted', page.path);