From 02c43249cd6c2f503d57be2bb0395d8e96d48ad7 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Wed, 24 Jul 2019 15:05:35 -0700 Subject: [PATCH] partly correct the transitions between talk overlays Tapping browser back button now does not show the underlying article However clicking the back icon does (which can be fixed by a hack see I80328b388b2e2da105bd670a3679b4ed3061b33a ) This works because displaying the talk overlay triggers a load to mobile.talk.overlays (for talk topic board) so the other overlays are guaranteed to be ready by the time you want to transition to them. Bug: T221978 Change-Id: Ic3b448169d52880b38408da47af9e4576c585e16 --- resources/skins.minerva.talk/init.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/resources/skins.minerva.talk/init.js b/resources/skins.minerva.talk/init.js index 00d5b25..5e102d6 100644 --- a/resources/skins.minerva.talk/init.js +++ b/resources/skins.minerva.talk/init.js @@ -45,6 +45,19 @@ return; } + /** + * Render a talk overlay for a given section + * @param {string} id (a number e.g. '1' or the string 'new') + * @param {Object} talkOptions + * @return {Overlay} + */ + function talkSectionOverlay( id, talkOptions ) { + if ( id === 'new' ) { + return new ( M.require( 'mobile.talk.overlays/TalkSectionAddOverlay' ) )( talkOptions ); + } + return new ( M.require( 'mobile.talk.overlays/TalkSectionOverlay' ) )( talkOptions ); + } + overlayManager.add( /^\/talk\/?(.*)$/, function ( id ) { var title = talkTitle.toText(), talkOptions = { @@ -72,12 +85,15 @@ // talk case if ( id ) { - return loader.loadModule( 'mobile.talk.overlays' ).then( function () { - if ( id === 'new' ) { - return new ( M.require( 'mobile.talk.overlays/TalkSectionAddOverlay' ) )( talkOptions ); - } - return new ( M.require( 'mobile.talk.overlays/TalkSectionOverlay' ) )( talkOptions ); - } ); + // If the module is already loaded return it instantly and synchronously. + // this avoids a flash of + // content when transitioning from mobile.talk.overlay to this overlay (T221978) + return mw.loader.getState( 'mobile.talk.overlays' ) === 'ready' ? + talkSectionOverlay( id, talkOptions ) : + // otherwise pull it from ResourceLoader async + loader.loadModule( 'mobile.talk.overlays' ).then( function () { + return talkSectionOverlay( id, talkOptions ); + } ); } else { return mobile.talk.overlay( title, gateway ); }