Merge "mmv.js: Store comingFromHashChange as a class property"

This commit is contained in:
jenkins-bot 2024-11-07 19:50:26 +00:00 committed by Gerrit Code Review
commit b0c2cc5671

View file

@ -44,7 +44,6 @@ const ThumbnailWidthCalculator = require( './mmv.ThumbnailWidthCalculator.js' );
const { extensions, useThumbnailGuessing } = require( './config.json' );
const router = require( 'mediawiki.router' );
let comingFromHashChange = false;
/**
* Analyses the page, looks for image content and sets up the hooks
@ -96,7 +95,7 @@ class MultimediaViewer {
*/
this.router = router;
this.setupRouter();
comingFromHashChange = false;
this.comingFromHashChange = false;
/**
* UI object used to display the pictures in the page.
@ -686,8 +685,8 @@ class MultimediaViewer {
this.viewLogger.recordViewDuration();
this.viewLogger.unattach();
if ( comingFromHashChange ) {
comingFromHashChange = false;
if ( this.comingFromHashChange ) {
this.comingFromHashChange = false;
} else {
this.router.back();
}
@ -707,7 +706,7 @@ class MultimediaViewer {
// handle empty hashes, and anchor links (page sections, possibly including /)
this.router.addRoute( /.*$/, () => {
if ( this.isOpen ) {
comingFromHashChange = true;
this.comingFromHashChange = true;
document.title = this.createDocumentTitle( null );
if ( this.ui ) {
// FIXME triggers mmv-close event, which calls viewer.close()