Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/301021
Change subject: [wip] Update and fetch seenTime per source ...................................................................... [wip] Update and fetch seenTime per source Change-Id: I10510fc612f7d5349f8b579ede70be647a119470 --- M modules/api/mw.echo.api.APIHandler.js M modules/controller/mw.echo.Controller.js M modules/ui/mw.echo.ui.NotificationsInboxWidget.js 3 files changed, 22 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/21/301021/1 diff --git a/modules/api/mw.echo.api.APIHandler.js b/modules/api/mw.echo.api.APIHandler.js index 2af0dfa..b032876 100644 --- a/modules/api/mw.echo.api.APIHandler.js +++ b/modules/api/mw.echo.api.APIHandler.js @@ -120,7 +120,7 @@ notsections: this.normalizedType[ type ], notformat: 'model', notlimit: this.limit, - notprop: 'list|count', + notprop: 'list|count|seenTime', uselang: this.userLang }, this.getTypeParams( type ) ); diff --git a/modules/controller/mw.echo.Controller.js b/modules/controller/mw.echo.Controller.js index 7641475..3f70f28 100644 --- a/modules/controller/mw.echo.Controller.js +++ b/modules/controller/mw.echo.Controller.js @@ -137,6 +137,7 @@ ) .then( function ( data ) { var i, notifData, newNotifData, localizedDate, date, itemModel, symbolicName, + maxSeenTime, dateItemIds = {}, dateItems = {}, models = {}; @@ -190,6 +191,20 @@ // Update the manager controller.manager.setNotificationModels( models ); + // Update the seenTime + // TODO: This query brings up mixed alert and message notifications. + // Regularly, each of those will have a different seenTime that is + // calculated for each badge, but for this page, both are fetched. + // For the moment, we are picking the max seenTime from + // either alert or notice and updating both, since the page gives + // us a mixed view which will update both seenTime to be the same + // anyways. + maxSeenTime = data.seenTime.alert < data.seenTime.notice ? + data.seenTime.notice : data.seenTime.alert; + controller.manager.getSeenTimeModel().setSeenTimeForSource( + currentSource, + maxSeenTime + ); // Update the pagination pagination.setNextPageContinue( data.continue ); @@ -319,6 +334,7 @@ */ mw.echo.Controller.prototype.createNotificationData = function ( apiData ) { var utcTimestamp, utcIsoMoment, + source = this.manager.getFiltersModel().getSourcePagesModel().getCurrentSource(), content = apiData[ '*' ] || {}; if ( apiData.timestamp.utciso8601 ) { @@ -336,7 +352,10 @@ source: 'local', count: apiData.count, read: !!apiData.read, - seen: !!apiData.read || utcTimestamp <= this.manager.getSeenTime(), //XXX + seen: ( + !!apiData.read || + utcTimestamp <= this.manager.getSeenTime( source ) + ), timestamp: utcTimestamp, category: apiData.category, content: { diff --git a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js index f3d8089..1f5f300 100644 --- a/modules/ui/mw.echo.ui.NotificationsInboxWidget.js +++ b/modules/ui/mw.echo.ui.NotificationsInboxWidget.js @@ -240,6 +240,7 @@ // Success function () { widget.popPending(); +debugger; // Update seen time widget.controller.updateSeenTimeForCurrentSource(); }, -- To view, visit https://gerrit.wikimedia.org/r/301021 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I10510fc612f7d5349f8b579ede70be647a119470 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits