This repository was archived by the owner on Feb 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
List only 1 'syncing to chain' ntfn #458
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
036c37b
List only 1 'syncing to chain' ntfn
valentinewallace 2558c6e
Revert "List only 1 'syncing to chain' ntfn"
tanx 386a562
List waiting notification only once in notification list
tanx 4d9438f
Display notification count bubble based on computed notifications
tanx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { computed, extendObservable } from 'mobx'; | ||
| import { toCaps } from '../helper'; | ||
| import { toCaps, formatNumber } from '../helper'; | ||
|
|
||
| const ComputedNotification = store => { | ||
| extendObservable(store, { | ||
|
|
@@ -13,7 +13,13 @@ const ComputedNotification = store => { | |
| }), | ||
| computedNotifications: computed(() => { | ||
| const { notifications } = store; | ||
| const all = notifications ? notifications.slice() : []; | ||
| const all = []; | ||
| notifications.forEach(n => { | ||
| if (n.waiting && all.find(a => a.waiting)) { | ||
| return; | ||
| } | ||
| all.push(n); | ||
| }); | ||
| all.sort((a, b) => b.date.getTime() - a.date.getTime()); | ||
| all.forEach(n => { | ||
| n.typeLabel = toCaps(n.type); | ||
|
|
@@ -22,6 +28,9 @@ const ComputedNotification = store => { | |
| }); | ||
| return all; | ||
| }), | ||
| notificationCountLabel: computed(() => | ||
| formatNumber(store.computedNotifications.length) | ||
| ), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also moved this here to be computed based on the |
||
| }); | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ describe('Computed Notification Unit Tests', () => { | |
| expect(store.lastNotification, 'to equal', null); | ||
| expect(store.displayNotification, 'to equal', false); | ||
| expect(store.computedNotifications, 'to equal', []); | ||
| expect(store.notificationCountLabel, 'to equal', '0'); | ||
| }); | ||
|
|
||
| it('should set notification attributes', () => { | ||
|
|
@@ -23,17 +24,38 @@ describe('Computed Notification Unit Tests', () => { | |
| date: new Date(1528703821406), | ||
| display: true, | ||
| }); | ||
| store.notifications.push({ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Went in to add this test, I see you've already added it 💯 |
||
| type: 'info', | ||
| message: 'Syncing to chain', | ||
| date: new Date(1528703821407), | ||
| display: true, | ||
| waiting: true, | ||
| }); | ||
| store.notifications.push({ | ||
| type: 'info', | ||
| message: 'Syncing to chain', | ||
| date: new Date(1528703821408), | ||
| display: true, | ||
| waiting: true, | ||
| }); | ||
| ComputedNotification(store); | ||
| expect(store.lastNotification.type, 'to equal', 'error'); | ||
| expect(store.lastNotification.type, 'to equal', 'info'); | ||
| expect(store.displayNotification, 'to equal', true); | ||
| expect(store.computedNotifications, 'to satisfy', [ | ||
| { | ||
| typeLabel: 'Info', | ||
| message: 'Syncing to chain', | ||
| dateLabel: new Date(1528703821407).toLocaleDateString(), | ||
| dateTimeLabel: new Date(1528703821407).toLocaleString(), | ||
| }, | ||
| { | ||
| typeLabel: 'Error', | ||
| message: 'Oops something went wrong', | ||
| dateLabel: new Date(1528703821406).toLocaleDateString(), | ||
| dateTimeLabel: new Date(1528703821406).toLocaleString(), | ||
| }, | ||
| ]); | ||
| expect(store.notificationCountLabel, 'to equal', '2'); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This displays only the first
waitingnotification.