Don't pop-up notifications after network switch (#4076)

* Better notifications

* Don't pollute with notifs if switched networks

* Better connection close/open events / No more notifs on change network

* PR Grumbles

* Add close and open events to HTTP // Add tests

* Fix tests

* WIP Signer Fix

* Fix Signer // Better reconnection handling

* PR Grumbles

* PR Grumbles

* Fixes wrong fetching of balances + Notifications

* Secure API WIP

* Updated Secure API Connection + Status

* Linting

* Linting

* Updated Secure API Logic

* Proper handling of token updates // Fixing poping notifications

* PR Grumbles

* PR Grumbles

* Fixing tests
This commit is contained in:
Nicolas Gotchac
2017-01-12 14:25:32 +01:00
committed by Jaco Greeff
parent bc2ebdc564
commit 81beec1352
22 changed files with 904 additions and 287 deletions

View File

@@ -16,7 +16,6 @@
import Push from 'push.js';
import BigNumber from 'bignumber.js';
import { noop } from 'lodash';
import { fromWei } from '~/api/util/wei';
@@ -33,13 +32,34 @@ export function notifyTransaction (account, token, _value, onClick) {
? ethereumIcon
: (token.image || unkownIcon);
Push.create(`${name}`, {
body: `You just received ${value.toFormat()} ${token.tag.toUpperCase()}`,
icon: {
x16: icon,
x32: icon
},
timeout: 20000,
onClick: onClick || noop
});
let _notification = null;
Push
.create(`${name}`, {
body: `You just received ${value.toFormat(3)} ${token.tag.toUpperCase()}`,
icon: {
x16: icon,
x32: icon
},
timeout: 20000,
onClick: () => {
// Focus on the UI
try {
window.focus();
} catch (e) {}
if (onClick && typeof onClick === 'function') {
onClick();
}
// Close the notification
if (_notification) {
_notification.close();
_notification = null;
}
}
})
.then((notification) => {
_notification = notification;
});
}