aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-06 15:59:17 +0100
committerChocobozzz <me@florianbigard.com>2020-01-06 15:59:17 +0100
commitbc6f886347f676220847461600122cde86edc272 (patch)
treea922e2ffe5bb536432a726793f025a1ed7bb2722 /client/src/app/menu
parent93d54cc769d88ecb2d7ead3ca293dac52653c13f (diff)
downloadPeerTube-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.html2
-rw-r--r--client/src/app/menu/avatar-notification.component.ts15
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 @@
1import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core' 1import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'
2import { User } from '../shared/users/user.model' 2import { User } from '../shared/users/user.model'
3import { UserNotificationService } from '@app/shared/users/user-notification.service' 3import { UserNotificationService } from '@app/shared/users/user-notification.service'
4import { Subscription } from 'rxjs' 4import { Subject, Subscription } from 'rxjs'
5import { Notifier, UserNotificationSocket } from '@app/core' 5import { Notifier, UserNotificationSocket } from '@app/core'
6import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' 6import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
7import { NavigationEnd, Router } from '@angular/router' 7import { NavigationEnd, Router } from '@angular/router'
8import { filter } from 'rxjs/operators' 8import { filter } from 'rxjs/operators'
9import { 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})
15export class AvatarNotificationComponent implements OnInit, OnDestroy { 16export 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 () {