MDL-56389 message_popup: less greedy marking of notifications as read.

Only mark those notifications that were returned in the last query as
read, based on the time they were requested.
This commit is contained in:
Paul Holden
2020-01-23 22:16:35 +00:00
committed by Paul Holden
parent df2544ee7b
commit b486073a9a
4 changed files with 11 additions and 4 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -52,6 +52,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
this.markAllReadButton = this.root.find(SELECTORS.MARK_ALL_READ_BUTTON);
this.unreadCount = 0;
this.lastQueried = 0;
this.userId = this.root.attr('data-userid');
this.container = this.root.find(SELECTORS.ALL_NOTIFICATIONS_CONTAINER);
this.limit = 20;
@@ -279,6 +280,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
return NotificationRepo.query(request).then(function(result) {
var notifications = result.notifications;
this.unreadCount = result.unreadcount;
this.lastQueried = Math.floor(new Date().getTime() / 1000);
this.setLoadedAllContent(!notifications.length || notifications.length < this.limit);
this.initialLoad = true;
this.updateButtonAriaLabel();
@@ -305,7 +307,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
NotificationPopoverController.prototype.markAllAsRead = function() {
this.markAllReadButton.addClass('loading');
return NotificationRepo.markAllAsRead({useridto: this.userId})
var request = {
useridto: this.userId,
timecreatedto: this.lastQueried,
};
return NotificationRepo.markAllAsRead(request)
.then(function() {
this.unreadCount = 0;
this.root.find(SELECTORS.UNREAD_NOTIFICATION).removeClass('unread');
+1 -1
View File
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2019111800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2020012300; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2019111200; // Requires this Moodle version
$plugin->component = 'message_popup'; // Full name of the plugin (used for diagnostics)