jenkins-bot has submitted this change and it was merged. Change subject: Fix duplicate 'new' tag and menu item CTA ......................................................................
Fix duplicate 'new' tag and menu item CTA * Do not append the tutorial or the menu tag if there already exists one. * Only emit the comletion event once on CollectionEditOverlay (hide is always called in those cases, no need to emit it explicitly). * Only listen to 'collection-edit-completed' once for every collection creation (was keeping the listening of previous created collections and triggering the handler for the event multiple times). Bug: T98947 Change-Id: Ie5f7f6d7149d1c42eeb6a769c8fb0de3864bc1cc (cherry picked from commit 368b15f3e24e7b31dfd0670746560d39d2128802) --- M resources/ext.gather.collection.editor/CollectionEditOverlay.js M resources/ext.gather.init/init.js M resources/ext.gather.watchstar/CollectionsContentOverlay.js 3 files changed, 17 insertions(+), 11 deletions(-) Approvals: Robmoen: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/ext.gather.collection.editor/CollectionEditOverlay.js b/resources/ext.gather.collection.editor/CollectionEditOverlay.js index 08e6936..836c61e 100644 --- a/resources/ext.gather.collection.editor/CollectionEditOverlay.js +++ b/resources/ext.gather.collection.editor/CollectionEditOverlay.js @@ -240,13 +240,12 @@ } else { toast.show( self.options.editSuccessMsg, 'toast' ); } + self.hide(); self._reloadCollection(); - self._emitCompleted(); } ); } else if ( this._stateChanged ) { this.hide(); this._reloadCollection(); - this._emitCompleted(); } else { // nothing to do. this.hide(); diff --git a/resources/ext.gather.init/init.js b/resources/ext.gather.init/init.js index e06b6bf..286fdf2 100644 --- a/resources/ext.gather.init/init.js +++ b/resources/ext.gather.init/init.js @@ -98,17 +98,24 @@ showPointer( watchstar ); } watchstar.on( 'completed', function ( firstTimeUser, isNewCollection ) { + var $menuItem = $( '#mw-mf-page-left .collection-menu-item' ); if ( isNewCollection ) { // FIXME: Rename pointer overlay? - new PageActionOverlay( { - target: $( '#mw-mf-main-menu-button' ), - summary: mw.msg( 'gather-menu-guider' ), - cancelMsg: mw.msg( 'gather-add-to-collection-cancel' ) - } ).show(); + // Only append the overlay if it is not there yet + if ( $( '#mw-mf-page-center .tutorial-overlay' ).length === 0 ) { + new PageActionOverlay( { + target: $( '#mw-mf-main-menu-button' ), + summary: mw.msg( 'gather-menu-guider' ), + cancelMsg: mw.msg( 'gather-add-to-collection-cancel' ) + } ).show(); + } // FIXME: Hacky.. Should use MainMenu but Bug: T93257. - new Tag( { - label: 'new' - } ).appendTo( '#mw-mf-page-left .collection-menu-item' ); + // Only append the tag if there is none. + if ( $menuItem.find( '.gather-tag' ).length === 0 ) { + new Tag( { + label: 'new' + } ).appendTo( $menuItem ); + } } } ); } diff --git a/resources/ext.gather.watchstar/CollectionsContentOverlay.js b/resources/ext.gather.watchstar/CollectionsContentOverlay.js index 6456989..6c23cca 100644 --- a/resources/ext.gather.watchstar/CollectionsContentOverlay.js +++ b/resources/ext.gather.watchstar/CollectionsContentOverlay.js @@ -361,7 +361,7 @@ return api.addCollection( title ).done( function ( collection ) { api.addPageToCollection( collection.id, page ).done( function () { self._collectionStateChange( collection, true ); - M.on( 'collection-edit-completed', function () { + M.once( 'collection-edit-completed', function () { self._notifyChanges( collection, true ); } ); self.loadEditor( collection.id ); -- To view, visit https://gerrit.wikimedia.org/r/210745 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie5f7f6d7149d1c42eeb6a769c8fb0de3864bc1cc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: wmf/1.26wmf5 Gerrit-Owner: Robmoen <rm...@wikimedia.org> Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org> Gerrit-Reviewer: Robmoen <rm...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits