jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/368176 )

Change subject: Support visual diffs on Special:ComparePages
......................................................................


Support visual diffs on Special:ComparePages

Bug: T171821
Change-Id: I13fe8349ab2d078b172637c931f1b80f7108c927
---
M extension.json
M modules/ve-mw/init/ve.init.mw.DiffPage.init.js
2 files changed, 18 insertions(+), 8 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index cb88de1..41984bb 100644
--- a/extension.json
+++ b/extension.json
@@ -1877,7 +1877,8 @@
                        "dependencies": [
                                "oojs-ui",
                                "oojs-ui.styles.icons-alerts",
-                               "oojs-ui.styles.icons-editing-advanced"
+                               "oojs-ui.styles.icons-editing-advanced",
+                               "mediawiki.Uri"
                        ],
                        "messages": [
                                "visualeditor-savedialog-review-visual",
diff --git a/modules/ve-mw/init/ve.init.mw.DiffPage.init.js 
b/modules/ve-mw/init/ve.init.mw.DiffPage.init.js
index 8ec60eb..8fd8322 100644
--- a/modules/ve-mw/init/ve.init.mw.DiffPage.init.js
+++ b/modules/ve-mw/init/ve.init.mw.DiffPage.init.js
@@ -9,7 +9,7 @@
        var $visualDiff,
                reviewModeButtonSelect,
                revCache = {},
-               pageName = mw.config.get( 'wgRelevantPageName' ),
+               uri = new mw.Uri(),
                mode = 'source',
                conf = mw.config.get( 'wgVisualEditorConfig' ),
                pluginModules = conf.pluginModules.filter( mw.loader.getState );
@@ -25,19 +25,28 @@
                return null;
        }
 
-       function fetchRevision( revId ) {
-               if ( !revCache[ revId ] ) {
-                       revCache[ revId ] = 
mw.libs.ve.targetLoader.requestParsoidData( pageName, revId, 'diff' );
+       function fetchRevision( pageName, revId ) {
+               revCache[ pageName ] = revCache[ pageName ] || {};
+               if ( !revCache[ pageName ][ revId ] ) {
+                       revCache[ pageName ][ revId ] = 
mw.libs.ve.targetLoader.requestParsoidData( pageName, revId, 'diff' );
                }
-               return revCache[ revId ];
+               return revCache[ pageName ][ revId ];
        }
 
        function onReviewModeButtonSelectSelect( item ) {
                var oldRevPromise, newRevPromise, modulePromise, progress,
+                       oldPageName, newPageName,
                        $revSlider = $( '.mw-revslider-container' ),
                        $wikitextDiff = $( 'table.diff[data-mw="interface"]' ),
                        oldId = mw.config.get( 'wgDiffOldId' ),
                        newId = mw.config.get( 'wgDiffNewId' );
+
+               if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 
'ComparePages' ) {
+                       oldPageName = newPageName = mw.config.get( 
'wgRelevantPageName' );
+               } else {
+                       oldPageName = uri.query.page1;
+                       newPageName = uri.query.page2;
+               }
 
                mode = item.getData();
 
@@ -45,8 +54,8 @@
                        progress = new OO.ui.ProgressBarWidget( { classes: [ 
've-init-mw-diffPage-loading' ] } );
                        $wikitextDiff.addClass( 'oo-ui-element-hidden' );
                        $wikitextDiff.before( progress.$element );
-                       oldRevPromise = fetchRevision( oldId );
-                       newRevPromise = fetchRevision( newId );
+                       oldRevPromise = fetchRevision( oldPageName, oldId );
+                       newRevPromise = fetchRevision( newPageName, newId );
                        // TODO: Load a smaller subset of VE for computing the 
visual diff
                        modulePromise = mw.loader.using( [ 
'ext.visualEditor.desktopArticleTarget' ].concat( pluginModules ) );
                        $.when( oldRevPromise, newRevPromise, modulePromise 
).then( function ( oldResponse, newResponse ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/368176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I13fe8349ab2d078b172637c931f1b80f7108c927
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Tchanders <thalia.e.c...@googlemail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to