diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-06 15:59:17 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-06 15:59:17 +0100 |
commit | bc6f886347f676220847461600122cde86edc272 (patch) | |
tree | a922e2ffe5bb536432a726793f025a1ed7bb2722 /client/src/app/menu | |
parent | 93d54cc769d88ecb2d7ead3ca293dac52653c13f (diff) | |
download | PeerTube-bc6f886347f676220847461600122cde86edc272.tar.gz PeerTube-bc6f886347f676220847461600122cde86edc272.tar.zst PeerTube-bc6f886347f676220847461600122cde86edc272.zip |
Fix mark all as read notifications
Diffstat (limited to 'client/src/app/menu')
-rw-r--r-- | client/src/app/menu/avatar-notification.component.html | 2 | ||||
-rw-r--r-- | client/src/app/menu/avatar-notification.component.ts | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/client/src/app/menu/avatar-notification.component.html b/client/src/app/menu/avatar-notification.component.html index 8ffec46da..7975afba5 100644 --- a/client/src/app/menu/avatar-notification.component.html +++ b/client/src/app/menu/avatar-notification.component.html | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | <my-user-notifications | 32 | <my-user-notifications |
33 | [ignoreLoadingBar]="true" [infiniteScroll]="false" itemsPerPage="10" | 33 | [ignoreLoadingBar]="true" [infiniteScroll]="false" itemsPerPage="10" |
34 | (notificationsLoaded)="onNotificationLoaded()" | 34 | [markAllAsReadSubject]="markAllAsReadSubject" (notificationsLoaded)="onNotificationLoaded()" |
35 | ></my-user-notifications> | 35 | ></my-user-notifications> |
36 | 36 | ||
37 | <a *ngIf="loaded" class="all-notifications" routerLink="/my-account/notifications"> | 37 | <a *ngIf="loaded" class="all-notifications" routerLink="/my-account/notifications"> |
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 @@ | |||
1 | import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { User } from '../shared/users/user.model' | 2 | import { User } from '../shared/users/user.model' |
3 | import { UserNotificationService } from '@app/shared/users/user-notification.service' | 3 | import { UserNotificationService } from '@app/shared/users/user-notification.service' |
4 | import { Subscription } from 'rxjs' | 4 | import { Subject, Subscription } from 'rxjs' |
5 | import { Notifier, UserNotificationSocket } from '@app/core' | 5 | import { Notifier, UserNotificationSocket } from '@app/core' |
6 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' |
7 | import { NavigationEnd, Router } from '@angular/router' | 7 | import { NavigationEnd, Router } from '@angular/router' |
8 | import { filter } from 'rxjs/operators' | 8 | import { filter } from 'rxjs/operators' |
9 | import { UserNotificationsComponent } from '@app/shared' | ||
9 | 10 | ||
10 | @Component({ | 11 | @Component({ |
11 | selector: 'my-avatar-notification', | 12 | selector: 'my-avatar-notification', |
@@ -14,11 +15,14 @@ import { filter } from 'rxjs/operators' | |||
14 | }) | 15 | }) |
15 | export class AvatarNotificationComponent implements OnInit, OnDestroy { | 16 | export class AvatarNotificationComponent implements OnInit, OnDestroy { |
16 | @ViewChild('popover', { static: true }) popover: NgbPopover | 17 | @ViewChild('popover', { static: true }) popover: NgbPopover |
18 | |||
17 | @Input() user: User | 19 | @Input() user: User |
18 | 20 | ||
19 | unreadNotifications = 0 | 21 | unreadNotifications = 0 |
20 | loaded = false | 22 | loaded = false |
21 | 23 | ||
24 | markAllAsReadSubject = new Subject<boolean>() | ||
25 | |||
22 | private notificationSub: Subscription | 26 | private notificationSub: Subscription |
23 | private routeSub: Subscription | 27 | private routeSub: Subscription |
24 | 28 | ||
@@ -64,14 +68,7 @@ export class AvatarNotificationComponent implements OnInit, OnDestroy { | |||
64 | } | 68 | } |
65 | 69 | ||
66 | markAllAsRead () { | 70 | markAllAsRead () { |
67 | this.userNotificationService.markAllAsRead() | 71 | this.markAllAsReadSubject.next(true) |
68 | .subscribe( | ||
69 | () => { | ||
70 | this.unreadNotifications = 0 | ||
71 | }, | ||
72 | |||
73 | err => this.notifier.error(err.message) | ||
74 | ) | ||
75 | } | 72 | } |
76 | 73 | ||
77 | private async subscribeToNotifications () { | 74 | private async subscribeToNotifications () { |