Explorar el Código

fix isOldestRevision to oldestRevision

zahmis hace 5 años
padre
commit
ca5571bfd9

+ 8 - 8
src/client/js/components/PageHistory/PageRevisionTable.jsx

@@ -16,9 +16,9 @@ class PageRevisionTable extends React.Component {
    * @param {boolean} hasDiff whether revision has difference to previousRevision
    * @param {boolean} hasDiff whether revision has difference to previousRevision
    * @param {boolean} isContiguousNodiff true if the current 'hasDiff' and one of previous row is both false
    * @param {boolean} isContiguousNodiff true if the current 'hasDiff' and one of previous row is both false
    */
    */
-  renderRow(revision, previousRevision, isOldestRevision, hasDiff, isContiguousNodiff) {
+  renderRow(revision, previousRevision, hasDiff, isContiguousNodiff) {
     const { revisionComparerContainer, t } = this.props;
     const { revisionComparerContainer, t } = this.props;
-    const { latestRevision } = this.props.pageHistoryContainer.state;
+    const { latestRevision, oldestRevision } = this.props.pageHistoryContainer.state;
     const revisionId = revision._id;
     const revisionId = revision._id;
     const revisionDiffOpened = this.props.diffOpened[revisionId] || false;
     const revisionDiffOpened = this.props.diffOpened[revisionId] || false;
     const { sourceRevision, targetRevision } = revisionComparerContainer.state;
     const { sourceRevision, targetRevision } = revisionComparerContainer.state;
@@ -59,7 +59,7 @@ class PageRevisionTable extends React.Component {
                     type="button"
                     type="button"
                     className="btn btn-outline-secondary btn-sm"
                     className="btn btn-outline-secondary btn-sm"
                     onClick={handleComparePreviousRevisionButton}
                     onClick={handleComparePreviousRevisionButton}
-                    disabled={isOldestRevision}
+                    disabled={revision === oldestRevision}
                   >
                   >
                     {t('page_history.compare_previous')}
                     {t('page_history.compare_previous')}
                   </button>
                   </button>
@@ -126,17 +126,17 @@ class PageRevisionTable extends React.Component {
         previousRevision = revision; // if it is the first revision, show full text as diff text
         previousRevision = revision; // if it is the first revision, show full text as diff text
       }
       }
 
 
-      let isOldestRevision;
-      if (revision === revisions[revisionCount - 1]) {
-        isOldestRevision = true;
-      }
+      // let isOldestRevision;
+      // if (revision === revisionCount - 1) {
+      //   isOldestRevision = true;
+      // }
 
 
       const hasDiff = revision.hasDiffToPrev !== false; // set 'true' if undefined for backward compatibility
       const hasDiff = revision.hasDiffToPrev !== false; // set 'true' if undefined for backward compatibility
       const isContiguousNodiff = !hasDiff && !hasDiffPrev;
       const isContiguousNodiff = !hasDiff && !hasDiffPrev;
 
 
       hasDiffPrev = hasDiff;
       hasDiffPrev = hasDiff;
 
 
-      return this.renderRow(revision, previousRevision, isOldestRevision, hasDiff, isContiguousNodiff);
+      return this.renderRow(revision, previousRevision, hasDiff, isContiguousNodiff);
     });
     });
 
 
     return (
     return (

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

@@ -25,6 +25,7 @@ export default class PageHistoryContainer extends Container {
       // set dummy rivisions for using suspense
       // set dummy rivisions for using suspense
       revisions: this.dummyRevisions,
       revisions: this.dummyRevisions,
       latestRevision: this.dummyRevisions,
       latestRevision: this.dummyRevisions,
+      oldestRevision: this.dummyRevisions,
       diffOpened: {},
       diffOpened: {},
 
 
       totalPages: 0,
       totalPages: 0,
@@ -100,6 +101,10 @@ export default class PageHistoryContainer extends Container {
       this.setState({ latestRevision: rev[0] });
       this.setState({ latestRevision: rev[0] });
     }
     }
 
 
+    if (selectedPage === res.data.totalPages) {
+      this.setState({ oldestRevision: rev[lastId] });
+    }
+
     // load 0, and last default
     // load 0, and last default
     if (rev[0]) {
     if (rev[0]) {
       this.fetchPageRevisionBody(rev[0]);
       this.fetchPageRevisionBody(rev[0]);