-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
MOBILE-4547 blog: Support offline blog #4043
base: main
Are you sure you want to change the base?
Conversation
087b0b8
to
88c2243
Compare
88c2243
to
bd0fe8f
Compare
if (!CoreNetwork.isOnline()) { | ||
const attachmentsId = await this.uploadOrStoreFiles(this.entry.id); | ||
|
||
return await this.saveEntry({ attachmentsId }); | ||
} |
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 code is not enough, we also want to save the data if the server is down. This is how the app works in all other cases. This problem also happens when creating a new entry.
Also, if the user is editing an offline entry but he's online when the Save button is pressed you will create the entry twice, because this function will send the data to the server (creating the entry) but the app will still have the offline data that will be sent later when synchronised. This can be fixed with the "forceOffline" parameter I tell you below.
If you look at this calendar code you'll see that the "storeOffline" function is called in 3 cases:
- When the user is offline.
- If the "forceOffline" parameter is true. You should use this when the user is editing an offline entry, that way you will save the data in offline even if the user is online now, and the sync process will be the one to send the entry to the server. In order for this to work properly, the index page should try to synchronize the data when opened as we do in many other places, I'll leave another comment about this.
- If a WS call returns an error and it's not a "WebService error" (function
CoreUtils.isWebServiceError
). The WS calls can return errors like the ones telling you don't have permissions to do the action, in that case we don't want to store the data in offline because the user cannot perform the action. But if the error is not a WebService error, e.g. is an error 500, or a timeout or something like this we store the data to try again later.
This is just a personal opinion, but I usually prefer putting this logic to check network, erros and so on in a service instead of in the page (like calendar does). But if you prefer to leave it in the page it's ok for now since this is the only place creating entries.
bd0fe8f
to
5d85ad0
Compare
01b88d6
to
7871c94
Compare
7871c94
to
4c0cb67
Compare
No description provided.