markRead method now has all notifications by default

This commit is contained in:
Edi Cziszter 2021-10-28 12:28:17 +03:00
parent a9159eda22
commit 3b64e75ae2
2 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@
</div>
<div
(click)="markRead($event, notification)"
(click)="markRead($event, [notification.id])"
*ngFor="let notification of group.notifications | sortBy: 'desc':'creationDate'"
[class.unread]="!notification.readDate"
class="notification"
@ -29,7 +29,7 @@
<div class="small-label mt-2">{{ notification.time }}</div>
</div>
<div
(click)="markRead($event, notification, !notification.readDate)"
(click)="markRead($event, [notification.id], !notification.readDate)"
class="dot"
matTooltip="{{ 'notifications.mark-as' | translate: { type: notification.readDate ? 'unread' : 'read' } }}"
matTooltipPosition="before"

View File

@ -8,6 +8,7 @@ import { NotificationsService } from '@services/notifications.service';
import { Notification } from '@red/domain';
import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
import { BehaviorSubject, Observable } from 'rxjs';
import { List } from '@iqser/common-ui';
interface NotificationsGroup {
date: string;
@ -47,10 +48,9 @@ export class NotificationsComponent implements OnInit {
await this._loadData();
}
async markRead($event, notification?: Notification, isRead = true): Promise<void> {
async markRead($event, notifications: List<string> = this._notifications$.getValue().map(n => n.id), isRead = true): Promise<void> {
$event.stopPropagation();
const body = notification ? [notification.id] : this._notifications$.getValue().map(n => n.id);
await this._notificationsService.toggleNotificationRead(body, isRead).toPromise();
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
await this._loadData();
}