Mooeypoo has uploaded a new change for review.
https://gerrit.wikimedia.org/r/310698
Change subject: Update the badges' seen state when Special:Notifications is
visited
..
Update the badges' seen state when Special:Notifications is visited
The special page and badges are completely different 'modules' so their
data models are disconnected. We do, however, want to make sure that
the badges' colors are updated when the special page is loaded.
We could tell the back end to never render the color of the badge
when we visit the special page, but that isn't consistent with our
update of seenTime, because there could be cases where the user
loaded the special page and moved away (or had a fluke API issue)
which means that the seenTime (and seen state in general) was *not*
updated.
We should represent this state when it is actually updated.
Bug: T134855
Change-Id: I053ce07ca26a858fd42c9d070b7dce73cc161e4b
---
M modules/ext.echo.init.js
M modules/ui/mw.echo.ui.NotificationsInboxWidget.js
2 files changed, 28 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/98/310698/1
diff --git a/modules/ext.echo.init.js b/modules/ext.echo.init.js
index f563f5d..70e1781 100644
--- a/modules/ext.echo.init.js
+++ b/modules/ext.echo.init.js
@@ -22,8 +22,6 @@
numMessages = $existingMessageLink.attr(
'data-counter-num' ),
badgeLabelAlerts = $existingAlertLink.attr(
'data-counter-text' ),
badgeLabelMessages = $existingMessageLink.attr(
'data-counter-text' ),
- hasUnseenAlerts = $existingAlertLink.hasClass(
'mw-echo-unseen-notifications' ),
- hasUnseenMessages = $existingMessageLink.hasClass(
'mw-echo-unseen-notifications' ),
// Store links
links = {
notifications: $( '#pt-notifications-alert a'
).attr( 'href' ),
@@ -33,7 +31,9 @@
// Respond to click on the notification button and load the UI
on demand
$( '.mw-echo-notification-badge-nojs' ).click( function ( e ) {
var time = mw.now(),
- myType = $( this ).parent().prop( 'id' ) ===
'pt-notifications-alert' ? 'alert' : 'message';
+ myType = $( this ).parent().prop( 'id' ) ===
'pt-notifications-alert' ? 'alert' : 'message',
+ hasUnseenAlerts = $existingAlertLink.hasClass(
'mw-echo-unseen-notifications' ),
+ hasUnseenMessages =
$existingMessageLink.hasClass( 'mw-echo-unseen-notifications' );
if ( e.which !== 1 ) {
return;
diff --git a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js
b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js
index d46f72d..dfdf633 100644
--- a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js
+++ b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js
@@ -262,10 +262,35 @@
widget.displayMessage( true );
}
)
+ .then( this.makePopupBadgesSeen.bind( this ) )
.always( this.popPending.bind( this ) );
};
/**
+* Look for the echo popup badges and update their seen states
+* If they are already loaded, trigger an update to their data-model's
seentime,
+* if they are not yet loaded, remove the 'unseen' classes that specify
their
+* unseen state.
+*/
+ mw.echo.ui.NotificationsInboxWidget.prototype.makePopupBadgesSeen =
function () {
+ if ( mw.echo.ui.messageWidget ) {
+ // This means the badge JS is already loaded
+ mw.echo.ui.messageWidget.controller.updateSeenTime();
+ } else {
+ // Hijack the DOM and change the state
+ $( '#pt-notifications-notice a' ).removeClass(
'mw-echo-unseen-notifications' );
+ }
+
+ if ( mw.echo.ui.alertWidget ) {
+ // This means the badge JS is already loaded
+ mw.echo.ui.alertWidget.controller.updateSeenTime();
+ } else {
+ // Hijack the DOM and change the state
+ $( '#pt-notifications-alert a' ).removeClass(
'mw-echo-unseen-notifications' );
+ }
+ };
+
+ /**
* Extend the pushPending method to disable UI elements
*/
mw.echo.ui.NotificationsInboxWidget.prototype.pushPending = function ()
{
--
To view, visit https://gerrit.wikimedia.org/r/310698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: