From bc6f886347f676220847461600122cde86edc272 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 6 Jan 2020 15:59:17 +0100 Subject: Fix mark all as read notifications --- client/src/app/menu/avatar-notification.component.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'client/src/app/menu/avatar-notification.component.ts') diff --git a/client/src/app/menu/avatar-notification.component.ts b/client/src/app/menu/avatar-notification.component.ts index ff830ac1c..989a11849 100644 --- a/client/src/app/menu/avatar-notification.component.ts +++ b/client/src/app/menu/avatar-notification.component.ts @@ -1,11 +1,12 @@ import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core' import { User } from '../shared/users/user.model' import { UserNotificationService } from '@app/shared/users/user-notification.service' -import { Subscription } from 'rxjs' +import { Subject, Subscription } from 'rxjs' import { Notifier, UserNotificationSocket } from '@app/core' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { NavigationEnd, Router } from '@angular/router' import { filter } from 'rxjs/operators' +import { UserNotificationsComponent } from '@app/shared' @Component({ selector: 'my-avatar-notification', @@ -14,11 +15,14 @@ import { filter } from 'rxjs/operators' }) export class AvatarNotificationComponent implements OnInit, OnDestroy { @ViewChild('popover', { static: true }) popover: NgbPopover + @Input() user: User unreadNotifications = 0 loaded = false + markAllAsReadSubject = new Subject() + private notificationSub: Subscription private routeSub: Subscription @@ -64,14 +68,7 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { } markAllAsRead () { - this.userNotificationService.markAllAsRead() - .subscribe( - () => { - this.unreadNotifications = 0 - }, - - err => this.notifier.error(err.message) - ) + this.markAllAsReadSubject.next(true) } private async subscribeToNotifications () { -- cgit v1.2.3