Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit c60bb5c

Browse files
authored
Merge pull request #747 from lightninglabs/hide-seen-ntfns
Don't show notification count after navigating to view.
2 parents 69594e6 + 8fb2baf commit c60bb5c

File tree

8 files changed

+10
-2
lines changed

8 files changed

+10
-2
lines changed

src/action/nav-mobile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class NavAction {
142142
}
143143

144144
goNotifications() {
145+
this._store.unseenNtfnCount = 0;
145146
this._navigate('Notifications');
146147
}
147148

src/action/nav.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class NavAction {
143143
}
144144

145145
goNotifications() {
146+
this._store.unseenNtfnCount = 0;
146147
this._store.route = 'Notifications';
147148
}
148149

src/action/notification.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class NotificationAction {
4040
handlerLbl: handlerLbl || (err ? 'Show error logs' : null),
4141
display: true,
4242
});
43+
if (!wait) this._store.unseenNtfnCount += 1;
4344
clearTimeout(this.tdisplay);
4445
this.tdisplay = setTimeout(() => this.close(), NOTIFICATION_DELAY);
4546
}

src/computed/notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const ComputedNotification = store => {
3434
return all;
3535
},
3636
get notificationCountLabel() {
37-
return formatNumber(store.computedNotifications.length);
37+
return formatNumber(store.unseenNtfnCount);
3838
},
3939
});
4040
};

src/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export class Store {
8282
paymentRequest: null,
8383
seedMnemonic: [],
8484
notifications: [],
85+
unseenNtfnCount: 0,
8586
logs: '',
8687

8788
// Persistent data

test/unit/action/nav.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ describe('Action Nav Unit Tests', () => {
217217
});
218218

219219
describe('goNotifications()', () => {
220-
it('should set correct route', () => {
220+
it('should set correct route and zero unseen ntfns', () => {
221+
store.unseenNtfnCount = 10;
221222
nav.goNotifications();
222223
expect(store.route, 'to equal', 'Notifications');
224+
expect(store.unseenNtfnCount, 'to be', 0);
223225
});
224226
});
225227

test/unit/action/notification.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Action Notification Unit Tests', () => {
3636
expect(log.info, 'was not called');
3737
await nap(10);
3838
expect(store.notifications[0].display, 'to be', false);
39+
expect(store.unseenNtfnCount, 'to equal', 1);
3940
});
4041

4142
it('create warning notification when type is set', () => {

test/unit/computed/notification.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('Computed Notification Unit Tests', () => {
3838
display: true,
3939
waiting: true,
4040
});
41+
store.unseenNtfnCount = 2;
4142
ComputedNotification(store);
4243
expect(store.lastNotification.type, 'to equal', 'info');
4344
expect(store.displayNotification, 'to equal', true);

0 commit comments

Comments
 (0)