Skip to content

Commit fc30108

Browse files
committed
chore: mark unread notifications with a different background color
1 parent 6f84575 commit fc30108

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/app/modules/popup/layout/layout.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
</main>
5050
</div>
5151

52-
<aside mdcDrawerContainer="temporary" class="right" [(open)]="openNotifications">
52+
<aside mdcDrawerContainer="temporary" class="right" [(open)]="openNotifications" (openChange)="onOpenNotificationsChange($event)">
5353
<nav mdcDrawer>
5454
<div mdcDrawerToolbarSpacer></div>
5555
<div mdcDrawerHeader>

src/app/modules/popup/layout/layout.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class LayoutComponent implements OnInit {
1313

1414
openMenu: boolean = false;
1515
openNotifications: boolean = false;
16+
private wasNotificationsOpened: boolean = false;
1617
@Input() view: View = null;
1718
@Input() isLoading: boolean = false;
1819
@Output() private isLoadingChange: EventEmitter<boolean> = new EventEmitter();
@@ -41,13 +42,13 @@ export class LayoutComponent implements OnInit {
4142

4243
toggleNotifications() {
4344
this.openNotifications = !this.openNotifications;
44-
if (this.openNotifications) {
45-
this.notifications.markAllAsRead();
46-
}
45+
this.wasNotificationsOpened = this.openNotifications;
4746
}
4847

49-
closeNotifications() {
50-
this.openNotifications = false;
48+
onOpenNotificationsChange(open: boolean) {
49+
if (!open && this.wasNotificationsOpened) {
50+
this.notifications.markAllAsRead();
51+
}
5152
}
5253

5354
onSearchTap() {

src/app/modules/popup/notifications/notifications.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ng-container *ngIf="notifications.get().length > 0; else noNotificationsTpl">
33
<div mdcListGroup>
44
<nav mdcList *ngFor="let notification of notifications.get()">
5-
<a mdcListItem>
5+
<a mdcListItem [class.unread]="notification.status === notificationStatus.Unread">
66
<ng-container
77
[ngTemplateOutlet]="notificationIconTpl"
88
[ngTemplateOutletContext]="{ $implicit: notification }"

src/app/modules/popup/notifications/notifications.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
color: $green-color;
1313
}
1414

15+
.unread {
16+
background-color: #ECF8FE;
17+
}
18+
1519
.no-notifications-container {
1620
display: flex;
1721
width: 100%;

src/app/modules/popup/notifications/notifications.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { Notification, NotificationType } from 'src/app/models/notification';
2+
import { NotificationType, NotificationStatus } from 'src/app/models/notification';
33
import { NotificationsService } from 'src/app/services/notifications.service';
44

55
@Component({
@@ -10,6 +10,7 @@ import { NotificationsService } from 'src/app/services/notifications.service';
1010
export class NotificationsComponent implements OnInit {
1111

1212
notificationTypes: typeof NotificationType = NotificationType;
13+
notificationStatus: typeof NotificationStatus = NotificationStatus;
1314

1415
constructor(public notifications: NotificationsService) { }
1516

0 commit comments

Comments
 (0)