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

Commit 386a562

Browse files
tanxvalentinewallace
authored andcommitted
List waiting notification only once in notification list
1 parent 2558c6e commit 386a562

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/computed/notification.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ const ComputedNotification = store => {
1313
}),
1414
computedNotifications: computed(() => {
1515
const { notifications } = store;
16-
const all = notifications ? notifications.slice() : [];
16+
const all = [];
17+
notifications.forEach(n => {
18+
if (n.waiting && all.find(a => a.waiting)) {
19+
return;
20+
}
21+
all.push(n);
22+
});
1723
all.sort((a, b) => b.date.getTime() - a.date.getTime());
1824
all.forEach(n => {
1925
n.typeLabel = toCaps(n.type);

test/unit/computed/notification.spec.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,30 @@ describe('Computed Notification Unit Tests', () => {
2323
date: new Date(1528703821406),
2424
display: true,
2525
});
26+
store.notifications.push({
27+
type: 'info',
28+
message: 'Syncing to chain',
29+
date: new Date(1528703821407),
30+
display: true,
31+
waiting: true,
32+
});
33+
store.notifications.push({
34+
type: 'info',
35+
message: 'Syncing to chain',
36+
date: new Date(1528703821408),
37+
display: true,
38+
waiting: true,
39+
});
2640
ComputedNotification(store);
27-
expect(store.lastNotification.type, 'to equal', 'error');
41+
expect(store.lastNotification.type, 'to equal', 'info');
2842
expect(store.displayNotification, 'to equal', true);
2943
expect(store.computedNotifications, 'to satisfy', [
44+
{
45+
typeLabel: 'Info',
46+
message: 'Syncing to chain',
47+
dateLabel: new Date(1528703821407).toLocaleDateString(),
48+
dateTimeLabel: new Date(1528703821407).toLocaleString(),
49+
},
3050
{
3151
typeLabel: 'Error',
3252
message: 'Oops something went wrong',

0 commit comments

Comments
 (0)