resizing the screen causes js errors
Closed this issue · 6 comments
Could the logic for this method be simplified?
setLastBlockFull(state, block) {
if (state.lastBlockFull) {
if (block && block.number) {
if (state.lastBlockFull.number < block.number) {
state.lastBlockFull = block;
}
}
} else {
state.lastBlockFull = block;
}
},
to this...
setLastBlockFull(state, block) {
if (block && block.number) {
if (!state.lastBlockFull || state.lastBlockFull.number < block.number) {
state.lastBlockFull = block;
}
} else {
state.lastBlockFull = undefined;
}
},
The part that I'm not sure is if/why block would be undefined/null. I'd rather see it explicitly set to undefined instead because that creates self documenting code.
With your version when we will receive an incomplete block or undefined we will also delete the data about last correct block... Regarding why we receive bad data...it's an Infura issue i guess, maybe they only know that a new block was mined but they don't have full header of that block and when we ask for that block we get undefined or incomplete data..
Ah, I get it. Thanks for the explanation. Hmm... then the other code style would be to remove all the nesting so that there is only one assignment... I could go either way really... this is just semantics at this point and I don't mean to be a pain.
setLastBlockFull(state, block) {
if (!state.lastBlockFull ||
(block && block.number && state.lastBlockFull.number < block.number)) {
state.lastBlockFull = block;
}
},
I will test your final version and if it works (i think it will work) i will use it because it's not so nested :)
Thank you!