mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-10 00:40:36 +01:00
prevent error overflow, fix #279
This commit is contained in:
parent
698fd39aa6
commit
b3d24b61d9
@ -62,6 +62,11 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
// //Test
|
||||||
|
// setInterval(() => {
|
||||||
|
// this.notificationService.notify('https://files.mastodon.social/accounts/avatars/000/520/226/original/fb37ef31376e5dfc.png', 500, null, true);
|
||||||
|
// }, 50);
|
||||||
|
|
||||||
// disable tutorial for future update
|
// disable tutorial for future update
|
||||||
localStorage.setItem('tutorial', JSON.stringify(true));
|
localStorage.setItem('tutorial', JSON.stringify(true));
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
<img class="notification-hub__notification--avatar" *ngIf="notification.avatar"
|
<img class="notification-hub__notification--avatar" *ngIf="notification.avatar"
|
||||||
src="{{ notification.avatar }}" />
|
src="{{ notification.avatar }}" />
|
||||||
|
|
||||||
<div class="notification-hub__notification--message">
|
<div class="notification-hub__notification--message" [class.notification-hub__notification--message--no-avatar]="!notification.avatar">
|
||||||
<span *ngIf="!notification.message">Error {{ notification.errorCode }}</span>
|
<span *ngIf="!notification.message">Error {{ notification.errorCode }}</span>
|
||||||
<span *ngIf="notification.message">{{ notification.message }}</span>
|
<span *ngIf="notification.message">{{ notification.message }}</span>
|
||||||
|
<span class="notification-hub__notification--count" *ngIf="notification.count > 1"> ({{ notification.count}})</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -27,7 +27,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&--message {
|
&--message {
|
||||||
|
padding-top: 4px;
|
||||||
margin-left: 37px;
|
margin-left: 37px;
|
||||||
|
|
||||||
|
&--no-avatar {
|
||||||
|
margin-left: 0px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--count {
|
||||||
|
color: rgba(255, 255, 255, .6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,17 +7,26 @@ import { NotificationService, NotificatioData } from '../../services/notificatio
|
|||||||
styleUrls: ['./notification-hub.component.scss']
|
styleUrls: ['./notification-hub.component.scss']
|
||||||
})
|
})
|
||||||
export class NotificationHubComponent implements OnInit {
|
export class NotificationHubComponent implements OnInit {
|
||||||
notifications: NotificatioData[] = [];
|
notifications: NotificationWrapper[] = [];
|
||||||
|
|
||||||
constructor(private notificationService: NotificationService) { }
|
constructor(private notificationService: NotificationService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.notificationService.notifactionStream.subscribe((notification: NotificatioData) => {
|
this.notificationService.notifactionStream.subscribe((notification: NotificatioData) => {
|
||||||
this.notifications.push(notification);
|
let alreadyExistingNotification = this.notifications.find(x => x.avatar === notification.avatar && x.message === notification.message);
|
||||||
|
|
||||||
setTimeout(() => {
|
if(alreadyExistingNotification){
|
||||||
this.notifications = this.notifications.filter(x => x.id !== notification.id);
|
alreadyExistingNotification.count++;
|
||||||
}, 5000);
|
} else{
|
||||||
|
this.notifications.push(new NotificationWrapper(notification));
|
||||||
|
if(this.notifications.length > 3){
|
||||||
|
this.notifications.length = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.notifications = this.notifications.filter(x => x.id !== notification.id);
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//this.autoSubmit();
|
//this.autoSubmit();
|
||||||
@ -35,3 +44,11 @@ export class NotificationHubComponent implements OnInit {
|
|||||||
this.notifications = this.notifications.filter(x => x.id !== notification.id);
|
this.notifications = this.notifications.filter(x => x.id !== notification.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotificationWrapper extends NotificatioData {
|
||||||
|
constructor(data: NotificatioData) {
|
||||||
|
super(data.avatar, data.errorCode, data.message, data.isError);
|
||||||
|
}
|
||||||
|
|
||||||
|
count = 1;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user