ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix mark all as read notifications
Chocobozzzbc6f886347f6
diff --git a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.htmlindex daf721f033..dec3b14cc1 100644--- a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html+++ b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.html@@ -4,12 +4,18 @@Notification preferences</a>- <button class="btn" [disabled]="!getUnreadNotifications()" (click)="markAllAsRead()">- <my-global-icon *ngIf="getUnreadNotifications()" iconName="inbox-full"></my-global-icon>- <span i18n *ngIf="getUnreadNotifications()">Mark all as read</span>+ <button class="btn" [disabled]="!hasUnreadNotifications()" (click)="markAllAsRead()">+ <ng-container *ngIf="hasUnreadNotifications()">+ <my-global-icon iconName="inbox-full"></my-global-icon>- <my-global-icon *ngIf="!getUnreadNotifications()" iconName="circle-tick"></my-global-icon>- <span i18n *ngIf="!getUnreadNotifications()">All read</span>+ <span i18n>Mark all as read</span>+ </ng-container>++ <ng-container *ngIf="!hasUnreadNotifications()">+ <my-global-icon iconName="circle-tick"></my-global-icon>++ <span i18n>All read</span>+ </ng-container></button></div>diff --git a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.tsindex 156e7713d4..a50cb0fb94 100644--- a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts+++ b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts@@ -12,7 +12,7 @@ export class MyAccountNotificationsComponent {this.userNotification.markAllAsRead()}- getUnreadNotifications () {- return this.userNotification.notifications.filter(n => n.read === false).length+ hasUnreadNotifications () {+ return this.userNotification.notifications.filter(n => n.read === false).length !== 0}}diff --git a/client/src/app/menu/avatar-notification.component.html b/client/src/app/menu/avatar-notification.component.htmlindex 8ffec46da6..7975afba50 100644--- a/client/src/app/menu/avatar-notification.component.html+++ b/client/src/app/menu/avatar-notification.component.html@@ -31,7 +31,7 @@<my-user-notifications[ignoreLoadingBar]="true" [infiniteScroll]="false" itemsPerPage="10"- (notificationsLoaded)="onNotificationLoaded()"+ [markAllAsReadSubject]="markAllAsReadSubject" (notificationsLoaded)="onNotificationLoaded()"></my-user-notifications><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.tsindex ff830ac1c3..989a11849d 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: UserunreadNotifications = 0loaded = false+ markAllAsReadSubject = new Subject<boolean>()+private notificationSub: Subscriptionprivate 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 () {diff --git a/client/src/app/shared/users/user-notifications.component.ts b/client/src/app/shared/users/user-notifications.component.tsindex 3c9eb369d3..977dd8925c 100644--- a/client/src/app/shared/users/user-notifications.component.ts+++ b/client/src/app/shared/users/user-notifications.component.ts@@ -15,6 +15,7 @@ export class UserNotificationsComponent implements OnInit {@Input() ignoreLoadingBar = false@Input() infiniteScroll = true@Input() itemsPerPage = 20+ @Input() markAllAsReadSubject: Subject<boolean>@Output() notificationsLoaded = new EventEmitter()@@ -40,6 +41,10 @@ export class UserNotificationsComponent implements OnInit {}this.loadMoreNotifications()++ if (this.markAllAsReadSubject) {+ this.markAllAsReadSubject.subscribe(() => this.markAllAsRead())+ }}loadMoreNotifications () {