Remove notify menu dot when notification has been seen

This commit is contained in:
Natsumi
2021-05-27 01:06:28 +12:00
parent 983cf41107
commit d9618b25ed
+26 -4
View File
@@ -2117,6 +2117,7 @@ speechSynthesis.getVoices();
this.getNotifications({ n: 100 }).then(() => { this.getNotifications({ n: 100 }).then(() => {
this.deleteExpiredNotifcations(); this.deleteExpiredNotifcations();
this.isNotificationsLoading = false; this.isNotificationsLoading = false;
$app.unseenNotifications = [];
}); });
// this.bulk({ // this.bulk({
// fn: 'getNotifications', // fn: 'getNotifications',
@@ -3221,9 +3222,14 @@ speechSynthesis.getVoices();
notificationId: content.id notificationId: content.id
} }
}); });
if (content.type === 'invite') { break;
$app.inviteDownloadWorldCache(content);
} case 'notification-see':
this.$emit('NOTIFICATION:SEE', {
params: {
notificationId: content.notificationId
}
});
break; break;
case 'friend-add': case 'friend-add':
@@ -4702,6 +4708,9 @@ speechSynthesis.getVoices();
if (item) { if (item) {
item.$el.classList.remove('notify'); item.$el.classList.remove('notify');
} }
if (index === 'notification') {
this.unseenNotifications = [];
}
}; };
$app.methods.promptTOTP = function () { $app.methods.promptTOTP = function () {
@@ -6911,6 +6920,8 @@ speechSynthesis.getVoices();
$app.notificationTable.data = []; $app.notificationTable.data = [];
}); });
$app.data.unseenNotifications = [];
API.$on('NOTIFICATION', function (args) { API.$on('NOTIFICATION', function (args) {
var { ref } = args; var { ref } = args;
var array = $app.notificationTable.data; var array = $app.notificationTable.data;
@@ -6927,11 +6938,22 @@ speechSynthesis.getVoices();
} }
if (ref.$isDeleted === false) { if (ref.$isDeleted === false) {
$app.notificationTable.data.push(ref); $app.notificationTable.data.push(ref);
$app.notifyMenu('notification'); if (ref.senderUserId !== this.currentUser.id) {
$app.notifyMenu('notification');
$app.unseenNotifications.push(ref.id);
}
} }
$app.updateSharedFeed(true); $app.updateSharedFeed(true);
}); });
API.$on('NOTIFICATION:SEE', function (args) {
var { notificationId } = args.params;
removeFromArray($app.unseenNotifications, notificationId);
if ($app.unseenNotifications.length === 0) {
$app.selectMenu('notification');
}
});
API.$on('NOTIFICATION:@DELETE', function (args) { API.$on('NOTIFICATION:@DELETE', function (args) {
var { ref } = args; var { ref } = args;
var array = $app.notificationTable.data; var array = $app.notificationTable.data;