-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Don't pop-up notifications after network switch #4076
Changes from 7 commits
719a1fa
c6f18f4
983dcf1
cce9225
316da79
bdeea95
8f71a02
bf28bcb
9c13b10
956137a
5f7115b
e088a43
fccec02
42554de
101ee24
1489544
1dbc434
580782d
9eda90c
f589df6
7c5b8e1
5c097ff
61637d2
db67df5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,13 +124,13 @@ export default class Ws extends JsonRpcBase { | |
} | ||
|
||
_onOpen = (event) => { | ||
console.log('ws:onOpen'); | ||
|
||
this._connected = true; | ||
this._connecting = false; | ||
this._autoConnect = true; | ||
this._retries = 0; | ||
|
||
this.emit('open'); | ||
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. Only ws? We have 2 transports, needs to be in-sync. Additionally, since it is done on the API layer, we need to have tests that prove that is does what it is supposed to for all the transports. 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. Well the HTTP layer will never close nor open right (or at each request)? 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. It still has the isConnected & connected property. Basically when connected is set to true it should emit open, when set to false (errors), it should be emit false. (Since we actually have the polling to say connected/not-connected the emitter will actually add value) |
||
|
||
Object.keys(this._messages) | ||
.filter((id) => this._messages[id].queued) | ||
.forEach(this._send); | ||
|
@@ -148,6 +148,8 @@ export default class Ws extends JsonRpcBase { | |
event.timestamp = Date.now(); | ||
this._lastError = event; | ||
|
||
this.emit('close'); | ||
|
||
if (this._autoConnect) { | ||
const timeout = this.retryTimeout; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ const ETH = { | |
image: imagesEthereum | ||
}; | ||
|
||
function setBalances (_balances) { | ||
function setBalances (_balances, skipNotifications = false) { | ||
return (dispatch, getState) => { | ||
const state = getState(); | ||
|
||
|
@@ -65,12 +65,12 @@ function setBalances (_balances) { | |
const oldValue = nextTokens[tokenIndex].value; | ||
|
||
// If received a token/eth (old value < new value), notify | ||
if (oldValue.lt(value) && accounts[address]) { | ||
if (oldValue.lt(value) && accounts[address] && !skipNotifications) { | ||
const account = accounts[address]; | ||
const txValue = value.minus(oldValue); | ||
|
||
const redirectToAccount = () => { | ||
const route = `/account/${account.address}`; | ||
const route = `/accounts/${account.address}`; | ||
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. Picked this up last night as well. I guess we actually need to externalise the route definitions somehow so we don't miss these again in the future. 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. Might be worth it yes. Note that this route is still working |
||
dispatch(push(route)); | ||
}; | ||
|
||
|
@@ -170,7 +170,7 @@ export function fetchTokens (_tokenIds) { | |
}; | ||
} | ||
|
||
export function fetchBalances (_addresses) { | ||
export function fetchBalances (_addresses, skipNotifications = false) { | ||
return (dispatch, getState) => { | ||
const { api, personal } = getState(); | ||
const { visibleAccounts, accounts } = personal; | ||
|
@@ -192,7 +192,7 @@ export function fetchBalances (_addresses) { | |
balances[addr] = accountsBalances[idx]; | ||
}); | ||
|
||
dispatch(setBalances(balances)); | ||
dispatch(setBalances(balances, skipNotifications)); | ||
updateTokensFilter(addresses)(dispatch, getState); | ||
}) | ||
.catch((error) => { | ||
|
@@ -326,7 +326,7 @@ export function queryTokensFilter (tokensFilter) { | |
}; | ||
} | ||
|
||
export function fetchTokensBalances (_addresses = null, _tokens = null) { | ||
export function fetchTokensBalances (_addresses = null, _tokens = null, skipNotifications = false) { | ||
return (dispatch, getState) => { | ||
const { api, personal, balances } = getState(); | ||
const { visibleAccounts, accounts } = personal; | ||
|
@@ -348,7 +348,7 @@ export function fetchTokensBalances (_addresses = null, _tokens = null) { | |
balances[addr] = tokensBalances[idx]; | ||
}); | ||
|
||
dispatch(setBalances(balances)); | ||
dispatch(setBalances(balances, skipNotifications)); | ||
}) | ||
.catch((error) => { | ||
console.warn('balances::fetchTokensBalances', error); | ||
|
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.
I think these should have been in the JsonRpc base - so both implementations are consistent with the flags they set and the events they emit (at least the base flags, not the internal extensions).