mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-09 08:28:40 +01:00
better update when notification panel is open #55
This commit is contained in:
parent
e61a7cd49a
commit
1fa3483a5e
@ -61,6 +61,7 @@ export class MentionsComponent implements OnInit, OnDestroy {
|
||||
this.userNotificationService.markMentionsAsRead(this.account.info);
|
||||
|
||||
this.userNotificationServiceSub = this.userNotificationService.userNotifications.subscribe((userNotifications: UserNotification[]) => {
|
||||
this.statuses.length = 0; //TODO: don't reset, only add the new ones
|
||||
const userNotification = userNotifications.find(x => x.account.id === this.account.info.id);
|
||||
if(userNotification && userNotification.mentions){
|
||||
userNotification.mentions.forEach((mention: Status) => {
|
||||
@ -69,6 +70,7 @@ export class MentionsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
this.lastId = userNotification.lastId;
|
||||
this.userNotificationService.markMentionsAsRead(this.account.info);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@ export class NotificationsComponent implements OnInit, OnDestroy {
|
||||
this.userNotificationService.markNotificationAsRead(this.account.info);
|
||||
|
||||
this.userNotificationServiceSub = this.userNotificationService.userNotifications.subscribe((userNotifications: UserNotification[]) => {
|
||||
this.notifications.length = 0; //TODO: don't reset, only add the new ones
|
||||
const userNotification = userNotifications.find(x => x.account.id === this.account.info.id);
|
||||
if(userNotification && userNotification.notifications){
|
||||
userNotification.notifications.forEach((notification: Notification) => {
|
||||
@ -72,6 +73,7 @@ export class NotificationsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
this.lastId = userNotification.lastId;
|
||||
this.userNotificationService.markNotificationAsRead(this.account.info);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -130,17 +130,23 @@ export class UserNotificationService {
|
||||
markMentionsAsRead(account: AccountInfo) {
|
||||
let currentNotifications = this.userNotifications.value;
|
||||
const currentAccountNotifications = currentNotifications.find(x => x.account.id === account.id);
|
||||
|
||||
if (currentAccountNotifications.hasNewMentions === true) {
|
||||
currentAccountNotifications.hasNewMentions = false;
|
||||
this.userNotifications.next(currentNotifications);
|
||||
}
|
||||
}
|
||||
|
||||
markNotificationAsRead(account: AccountInfo) {
|
||||
let currentNotifications = this.userNotifications.value;
|
||||
const currentAccountNotifications = currentNotifications.find(x => x.account.id === account.id);
|
||||
|
||||
if (currentAccountNotifications.hasNewNotifications === true) {
|
||||
currentAccountNotifications.hasNewNotifications = false;
|
||||
this.userNotifications.next(currentNotifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class UserNotification {
|
||||
account: AccountInfo;
|
||||
|
Loading…
x
Reference in New Issue
Block a user