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

Commit 4d9438f

Browse files
tanxvalentinewallace
authored andcommitted
Display notification count bubble based on computed notifications
1 parent 386a562 commit 4d9438f

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

src/computed/notification.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { computed, extendObservable } from 'mobx';
2-
import { toCaps } from '../helper';
2+
import { toCaps, formatNumber } from '../helper';
33

44
const ComputedNotification = store => {
55
extendObservable(store, {
@@ -28,6 +28,9 @@ const ComputedNotification = store => {
2828
});
2929
return all;
3030
}),
31+
notificationCountLabel: computed(() =>
32+
formatNumber(store.computedNotifications.length)
33+
),
3134
});
3235
};
3336

src/computed/setting.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ const ComputedSetting = store => {
66
extendObservable(store, {
77
selectedUnitLabel: computed(() => getUnitLabel(store.settings.unit)),
88
selectedFiatLabel: computed(() => FIATS[store.settings.fiat].display),
9-
notificationCountLabel: computed(() =>
10-
formatNumber(store.notifications.length)
11-
),
129
satUnitLabel: computed(() => getUnitLabel('sat')),
1310
bitUnitLabel: computed(() => getUnitLabel('bit')),
1411
btcUnitLabel: computed(() => getUnitLabel('btc')),

test/unit/computed/notification.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('Computed Notification Unit Tests', () => {
1414
expect(store.lastNotification, 'to equal', null);
1515
expect(store.displayNotification, 'to equal', false);
1616
expect(store.computedNotifications, 'to equal', []);
17+
expect(store.notificationCountLabel, 'to equal', '0');
1718
});
1819

1920
it('should set notification attributes', () => {
@@ -54,6 +55,7 @@ describe('Computed Notification Unit Tests', () => {
5455
dateTimeLabel: new Date(1528703821406).toLocaleString(),
5556
},
5657
]);
58+
expect(store.notificationCountLabel, 'to equal', '2');
5759
});
5860
});
5961
});

test/unit/computed/setting.spec.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describe('Computed Settings Unit Tests', () => {
1313
ComputedSetting(store);
1414
expect(store.selectedUnitLabel, 'to equal', 'Bitcoin');
1515
expect(store.selectedFiatLabel, 'to equal', 'US Dollar');
16-
expect(store.notificationCountLabel, 'to equal', '0');
1716
expect(store.satUnitLabel, 'to be ok');
1817
expect(store.bitUnitLabel, 'to be ok');
1918
expect(store.btcUnitLabel, 'to be ok');
@@ -31,11 +30,5 @@ describe('Computed Settings Unit Tests', () => {
3130
/Satoshi {3}\(0[,.]00000001 BTC\)/
3231
);
3332
});
34-
35-
it('should display notification count as a string', () => {
36-
store.notifications.push({ type: 'error' });
37-
ComputedSetting(store);
38-
expect(store.notificationCountLabel, 'to equal', '1');
39-
});
4033
});
4134
});

0 commit comments

Comments
 (0)