jenkins-bot has submitted this change and it was merged.
Change subject: ext.echo.overlay: Only build the 'mark all as read' button if
it's used
......................................................................
ext.echo.overlay: Only build the 'mark all as read' button if it's used
Otherwise a new copy will be created every time the user opens and closes
the popup, and jQuery will hold on to each one forever (because it has
events bound), leaking a minuscule amount of memory.
Change-Id: I70c713be839f826fc27d07b04260c166f9052020
---
M modules/overlay/ext.echo.overlay.js
1 file changed, 19 insertions(+), 20 deletions(-)
Approvals:
Bsitu: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/overlay/ext.echo.overlay.js
b/modules/overlay/ext.echo.overlay.js
index eaa6e22..4a5e8c4 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -136,26 +136,6 @@
titleText = mw.msg( 'echo-none' );
}
- $markReadButton = $( '<button>' )
- .addClass( 'mw-ui-button' )
- .attr( 'id', 'mw-echo-mark-read-button'
)
- .text( mw.msg( 'echo-mark-all-as-read'
) )
- .click( function ( e ) {
- e.preventDefault();
- api.post(
mw.echo.desktop.appendUseLang( {
- 'action' :
'echomarkread',
- 'all' : true,
- 'token':
mw.user.tokens.get( 'editToken' )
- } ) ).done( function ( result )
{
- if (
result.query.echomarkread.count !== undefined ) {
- count =
result.query.echomarkread.count;
-
mw.echo.overlay.updateCount( count, result.query.echomarkread.rawcount );
- // Reset header
to 'Notifications'
- $(
'#mw-echo-overlay-title-text').msg( 'echo-overlay-title' );
- }
- } );
- } );
-
// If there are more unread notifications than
can fit in the overlay,
// but fewer than the maximum count, show the
'mark all as read' button.
// The only reason we limit it to the maximum
is to prevent expensive
@@ -164,6 +144,25 @@
if ( overflow && unreadRawTotalCount <
mw.echo.overlay.configuration['max-notification-count']
) {
// Add the 'mark all as read' button to
the title area
+ $markReadButton = $( '<button>' )
+ .addClass( 'mw-ui-button' )
+ .attr( 'id',
'mw-echo-mark-read-button' )
+ .text( mw.msg(
'echo-mark-all-as-read' ) )
+ .click( function ( e ) {
+ e.preventDefault();
+ api.post(
mw.echo.desktop.appendUseLang( {
+ 'action' :
'echomarkread',
+ 'all' : true,
+ 'token':
mw.user.tokens.get( 'editToken' )
+ } ) ).done( function (
result ) {
+ if (
result.query.echomarkread.count !== undefined ) {
+ count =
result.query.echomarkread.count;
+
mw.echo.overlay.updateCount( count, result.query.echomarkread.rawcount );
+ //
Reset header to 'Notifications'
+ $(
'#mw-echo-overlay-title-text').msg( 'echo-overlay-title' );
+ }
+ } );
+ } );
$title.append( $markReadButton );
}
--
To view, visit https://gerrit.wikimedia.org/r/93112
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I70c713be839f826fc27d07b04260c166f9052020
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits