New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline support #195
Offline support #195
Conversation
- listen to the browser's offline event
- refactored service worker to async/await
- persist the account data - refresh the data after going online - persist recent transactions
- persist recent transactions
- persist recent transactions - refresh when connecting
- support for mobile
During one of the Ledger code refactors the feature of pinging the Ledger device only when the UI needs the information was lost. This commit reimplements that feature. This is also needed for users of Yubikeys (for which the U2F protocol was created for), to not bombard their non-Ledger devices with U2F requests when it's not needed. See #174.
The LedgerChannel wasn't being closed properly in the ConfirmTransactionDialog logic, thus the background pinging of the device continued indefinitely. This has been fixed. In addition the LedgerChannel was opened for non-Ledger transactions. Now the channel is only openend for accounts of type LEDGER. See #174 for motivations behind these improvements.
- persist recent transactions
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.
Would've been better if this had been broken in to multiple PRs as currently this branch contains various other changes that aren't directly related to offline support feature (file formatting changes, bug fixes, my changes from another PR). Makes reviewing and catching things harder.
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.
Found a bug somewhere with the dirty state probably:
|
Another bug - the account balance isn't persisted after an offline reload.
Sub-bug 2 of this is that at step 5 the connection indicator claims "Connecting" even-though the browser is offline. |
- fixed loading of account cache
- fixed transaction cache timestamp
- fixed "load more" button
- fixed fonts
Somethings wrong with the github's diff, as it doesnt compare with current master. Eg this change isnt a part of the PR, along with others. Local diff shows the real situation. Formatting is a part of precommit which seems to have been skipped for some files in recent commits. We should keep
Fixed.
Browser limitation. Online/offline status is event based. Events fire only when it changes, thus doesnt fire when page is load from a service worker when offline. |
To test the recent changes you need to clean the cache (at least |
This actually turns out not to be true and we can rely on |
Will do another review-pass & test run tomorrow morning to see if I spot anything else. |
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.
Looking good. Didn't find any obvious bugs during my testing either. Just one suggestion about importData()
function signature changes (see comments). Up to you if you want to change this or merge straight away.
src/stores/wallet.ts
Outdated
account.importData(parseAccountReponse(res, local)); | ||
account.loaded = true; | ||
const res = await this.fetchAccountData(id); | ||
account.importData(parseAccountReponse(res, local), true, true); |
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 know that intelliJ shows the argument names, but for the sake of non-intelliJ users it would be nice if the importData()
function took an options object with named fields as the final parameter, instead of regular boolean arguments. E.g:
account.importData(parseAccountReponse(res, local), {
saveCache: true,
markAsLoaded: true
});
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.
Fixed, but an options object for 2 params seems like an overkill.
src/stores/transactions.ts
Outdated
@@ -152,9 +212,11 @@ export class Transaction { | |||
amount: RawAmount; | |||
amountFee: RawAmount; | |||
fee: RawAmount; | |||
/** TODO may be a problem when keeping the same transaction for 2 users */ |
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.
You mean when both the sender account and recipient account are in the same wallet? That worked as expected while I was testing things.
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.
Note for the future, related to #191.
I've reformatted the whole |
This PR adds:
Fixes following issues:
Does not cover the following:
To demo the feature one needs to have a non-localhost server with HTTPS.