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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ export class UserNotificationService {
|
|||
}
|
||||
|
||||
private analyseNotifications(userNotification: UserNotification): UserNotification {
|
||||
if(userNotification.allNotifications.length > 30){
|
||||
if (userNotification.allNotifications.length > 30) {
|
||||
userNotification.allNotifications.length = 30;
|
||||
}
|
||||
userNotification.lastId = userNotification.allNotifications[userNotification.allNotifications.length - 1].id;
|
||||
|
@ -130,16 +130,22 @@ 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 {
|
||||
|
|
Loading…
Reference in New Issue