-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
feat: Offline Shopping List #3760
Open
michael-genson
wants to merge
37
commits into
mealie-recipes:mealie-next
Choose a base branch
from
michael-genson:feat/offline-shopping-list
base: mealie-next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Offline Shopping List #3760
michael-genson
wants to merge
37
commits into
mealie-recipes:mealie-next
from
michael-genson:feat/offline-shopping-list
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5a2f079
to
bef4f4f
Compare
bef4f4f
to
1a8fdb9
Compare
8b542a0
to
2660524
Compare
2660524
to
dd240b7
Compare
The things noted under |
All the code LGTM. I just want to do a bit more playing around with it before approving. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This PR lets the shopping list work while offline. It does this by queueing requests, mirroring them locally, then sending them to the server whenever we can. There are a few caveats:
A few changes were made to get this to work:
Since not everything works offline (adding/removing recipes, changing the owner, etc.) we disable some features when we detect a network error (which will happen any time an item is created/updated/deleted, or during the normal 5 second polling period where we fetch the new list). I also added a warning banner letting the user know they're offline:
Which issue(s) this PR fixes:
(REQUIRED)
Fixes #3718
Special notes for your reviewer:
(fill-in or delete this section)
One implementation detail I simplified was the queue timeout. I mentioned that if the offline queue is too far behind the server (i.e. someone made changes a while ago) we just dump the queue. Ideally, we compare the timestamp of each item on the server, and only dump items with conflicts (e.g. if the offline user edits an item that an online user edited, dump that, but if the offline user edited an item that the online user didn't edit, keep that). However, this would be a lot more complex to implement (and probably be rather slow with large requests), and would probably only affect a handful of users. If this feature is requested later down the line we can consider adding it, but for now I think the existing behavior is fine.
I mentioned that updates are only sent to the server if the user is viewing the shopping list while online, and there is no background processing. PWAs do support this kind of background task using service workers, including using our nuxtjs PWA, (which fires even if the user isn't using the app), but hell if I can figure out how to get that to work.
Testing
(fill-in or delete this section)
Constantly testing the frontend online and offline. The online experience is unaffected (even though it's very different under the hood), aside from being a little more reactive (which is a nice plus).