Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/66053


Change subject: Editor (beta): Refresh the page after an edit
......................................................................

Editor (beta): Refresh the page after an edit

Don't force the user to unnecessarily refresh the page

Change-Id: I167267dde2511c910acd1a1557250bdc8140c896
---
M MobileFrontend.i18n.php
M javascripts/common/history-beta.js
M javascripts/modules/editor/EditorOverlay.js
M javascripts/modules/editor/editor.js
4 files changed, 23 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/53/66053/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 9ac9e8d..24d3816 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -243,7 +243,6 @@
        'mobile-frontend-editor-cancel-confirm' => 'Do you really want to 
abandon your edit?',
        'mobile-frontend-editor-wait' => 'Saving edit, please wait.',
        'mobile-frontend-editor-success' => 'Success! Your edit was saved.',
-       'mobile-frontend-editor-refresh' => 'Refresh this page to see your 
changes.',
        'mobile-frontend-editor-error' => 'Error, edit not saved.',
        'mobile-frontend-editor-error-conflict' => 'Error, another user has 
edited this page.',
        'mobile-frontend-editor-error-loading' => 'Error, can\'t load section.',
diff --git a/javascripts/common/history-beta.js 
b/javascripts/common/history-beta.js
index 54c4c89..7b33f08 100644
--- a/javascripts/common/history-beta.js
+++ b/javascripts/common/history-beta.js
@@ -56,6 +56,15 @@
        }
 
        /**
+        * Invalidate the internal cache for a given page
+        *
+        * @param {String} pageTitle the title of the page who's cache you want 
to invalidate
+        */
+       function invalidateCachedPage( pageTitle ) {
+               delete cache[ pageTitle ];
+       }
+
+       /**
         * Retrieve a page from the api
         *
         * @param {Object} pageTitle the title of the page to be retrieved
@@ -144,6 +153,7 @@
        }
 
        M.history = $.extend( M.history, {
+               invalidateCachedPage: invalidateCachedPage,
                renderPage: renderPage,
                retrieveAllLanguages: retrieveAllLanguages,
                retrievePage: retrievePage,
diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 7130f67..8580e42 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -121,9 +121,12 @@
 
                        this.api.save().
                                done( function() {
+                                       var title = self.options.title;
+                                       M.history.invalidateCachedPage( title );
+                                       M.history.renderPage( title );
                                        self.hide();
                                        popup.show(
-                                               mw.msg( 
'mobile-frontend-editor-success' ) + ' ' + mw.msg( 
'mobile-frontend-editor-refresh' ),
+                                               mw.msg( 
'mobile-frontend-editor-success' ),
                                                'toast'
                                        );
                                } ).
diff --git a/javascripts/modules/editor/editor.js 
b/javascripts/modules/editor/editor.js
index fd8b6a0..7427937 100644
--- a/javascripts/modules/editor/editor.js
+++ b/javascripts/modules/editor/editor.js
@@ -21,14 +21,19 @@
                        } );
        }
 
-       if (
-               ( mw.config.get( 'wgMFAnonymousEditing' ) || mw.config.get( 
'wgUserName' ) ) &&
-               mw.config.get( 'wgIsPageEditable' )
-       ) {
+       function init() {
                addEditButton( 0, '#content' );
                $( '.section_heading' ).each( function( i ) {
                        addEditButton( i + 1, this );
                } );
        }
 
+       if (
+               ( mw.config.get( 'wgMFAnonymousEditing' ) || mw.config.get( 
'wgUserName' ) ) &&
+               mw.config.get( 'wgIsPageEditable' )
+       ) {
+               init();
+               M.on( 'page-loaded', init );
+       }
+
 }( mw.mobileFrontend, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I167267dde2511c910acd1a1557250bdc8140c896
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to