Jonas Kress (WMDE) has uploaded a new change for review.

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

Change subject: Fixes: Using back button in browser loads old version
......................................................................

Fixes: Using back button in browser loads old version

Detects navigation through browser back/forward buttons and triggers a
page reload if necessary.

Bug: T55466
Change-Id: Ia20803db3463941d838714aa63bff9eafc0c172d
---
M repo/resources/wikibase.ui.entityViewInit.js
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/32/226732/1

diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
old mode 100644
new mode 100755
index 4aeba0e..a16b5c0
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -8,6 +8,8 @@
 ( function( $, mw, wb, dataTypeStore, getExpertsStore, getFormatterStore, 
getParserStore ) {
        'use strict';
 
+       attachHistoryCacheCleaning();
+       
        mw.hook( 'wikipage.content' ).add( function() {
 
                if( mw.config.get( 'wbEntity' ) === null ) {
@@ -271,7 +273,22 @@
                        }
                } );
        }
+       
+       /**
+        *  This methods detects whether the site was loaded from "history 
cache" 
+        *  and triggers a reload to prevent the browser to display an old state
+        */
+       function attachHistoryCacheCleaning() {
+               if (window.name == "reload") {
+               window.name = "";
+               location.reload();
+           }
 
+               $( window ).on( "beforeunload", function() {
+                   window.name = "reload"; 
+              });
+       }
+       
        /**
         * @param {jQuery} $entityview
         * @param {jQuery} $origin

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia20803db3463941d838714aa63bff9eafc0c172d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>

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

Reply via email to