-
Notifications
You must be signed in to change notification settings - Fork 12
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
Meta PR: Implement offline support through CozyPouchLink #1507
Open
Ldoppea
wants to merge
79
commits into
master
Choose a base branch
from
feat/meta_offline
base: master
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.
+4,640
−1,475
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
Ldoppea
force-pushed
the
feat/meta_offline
branch
from
July 26, 2024 14:54
16237f8
to
0049a23
Compare
2 tasks
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Jul 30, 2024
We want the Flagship app to work when offline To make this possible we configure cozy-client with CozyPouchLink which role will be to synchronize necessary doctypes into a local PouchDB and serve them from it instead of from the cozy-stack when the device is offline For now the list of synchronized doctypes is hardcoded but in the future we expect to implement a dynamic list based on cozy-apps' manifests Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Jul 30, 2024
In previous commit we configured cozy-client to use CozyPouchLink for its queries This commit also adds StackLink as the first Link so by default it will do its queries through the remote cozy-stack CozyClient has been modified to handle offline mode and redirect to the next link when it is detected Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Jul 30, 2024
This plugin is required by cozy-client to process `find` queries Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
We want the Flagship app to work when offline To make this possible we configure cozy-client with CozyPouchLink which role will be to synchronize necessary doctypes into a local PouchDB and serve them from it instead of from the cozy-stack when the device is offline For now the list of synchronized doctypes is hardcoded but in the future we expect to implement a dynamic list based on cozy-apps' manifests Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
In previous commit we configured cozy-client to use CozyPouchLink for its queries This commit also adds StackLink as the first Link so by default it will do its queries through the remote cozy-stack CozyClient has been modified to handle offline mode and redirect to the next link when it is detected Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
This plugin is required by cozy-client to process `find` queries Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
We want the Flagship app to work when offline To make this possible we configure cozy-client with CozyPouchLink which role will be to synchronize necessary doctypes into a local PouchDB and serve them from it instead of from the cozy-stack when the device is offline For now the list of synchronized doctypes is hardcoded but in the future we expect to implement a dynamic list based on cozy-apps' manifests Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
In previous commit we configured cozy-client to use CozyPouchLink for its queries This commit also adds StackLink as the first Link so by default it will do its queries through the remote cozy-stack CozyClient has been modified to handle offline mode and redirect to the next link when it is detected Related PR: cozy/cozy-client#1507
Ldoppea
added a commit
to cozy/cozy-flagship-app
that referenced
this pull request
Aug 26, 2024
This plugin is required by cozy-client to process `find` queries Related PR: cozy/cozy-client#1507
2 tasks
Ldoppea
added a commit
to cozy/mespapiers
that referenced
this pull request
Aug 26, 2024
We want mespapiers to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
Ldoppea
added a commit
to cozy/mespapiers
that referenced
this pull request
Aug 27, 2024
We want mespapiers to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
4 tasks
This was referenced Sep 4, 2024
Ldoppea
force-pushed
the
feat/meta_offline
branch
from
September 9, 2024 14:25
3eb3aa7
to
4f3e14e
Compare
Ldoppea
added a commit
to cozy/mespapiers
that referenced
this pull request
Sep 13, 2024
We want mespapiers to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
1 task
Ldoppea
added a commit
to cozy/mespapiers
that referenced
this pull request
Sep 13, 2024
We want mespapiers to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
Ldoppea
added a commit
to cozy/cozy-home
that referenced
this pull request
Sep 16, 2024
We want cozy-home to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
Ldoppea
added a commit
to cozy/cozy-home
that referenced
this pull request
Sep 19, 2024
We want cozy-home to be compatible with the new Flagship app's Offline mode When hosted in a Flagship app's WebView we now want to use FlagshipLink instead of StackLink in cozy-client This link will allow to redirect all queries to the Flagship app that will handle data access when offline but also when online Related PR: cozy/cozy-client#1507 Related PR: cozy/cozy-flagship-app#1239
3 tasks
Ldoppea
force-pushed
the
feat/meta_offline
branch
from
September 19, 2024 13:21
1540391
to
d1aee07
Compare
When calling `yarn types` all cozy-client's types are generated inside of the `cozy-client/types` folder However, there is no mechanism to remove types when their corresponding class is deleted To fix this, we want to clean the types folder before regenerating types so we ensure no fantom type would persist
For the Flagship app offline feature, we want to make some files available offline To make this possible, we want the cozy-apps to download files as usual except when they are hosted in the FlagshipApp In that scenario, we want the cozy-app to call the new `downloadFile` intent Also to ease future compatibility, we want to implement a new method hosted in the `file` model instead of in the collection as before So in order to handle offline files, the cozy-app will now need to call `downloadFile()` method from `models/file`
In order to prevent implementation errors, we want to check that storageEngine implements the correct methods This replies to #1483 (comment)
We want to extract this code logic into its own method in order to ease readability and testing Also we refactored the code to make it easier to read This replies to #1506 (comment)
This replies to #1486 (comment)
This commit is a copy of #1517 applied to CozyPouchLink When specifying fields in a query, e.g. `Q('io.cozy.todos').where({done: true}).select(['date'])`, the revision was missing if not explicitly given. This is now problematic because we rely on the revision existence to identify "virtual" documents, i.e. not persisted in CouchDB, that never have any revision. See #1486 for more insights.
With CouchDB, it is possible to make a mango query on an index without having any predicate on an sorted field in the selector It is not possible with PouchDB that requires to have any sorted fields to be in the selector We automatically handle that to avoid breaking existing queries
This guard has been added to handle documents with no `meta.rev` but since we added a check on `_rev` (in addition to `meta.rev`) to trigger the persistence, then we don't need this guard anymore This replies to #1486 (comment) Related commit: b797eb3 Related commit: 62290ed
Previous implementation was from a misunderstanding of CozyPouchLink mechanisms As we don't need to specify warmup queries in CozyPouchLink instanciation, we don't need the `ignoreWarmup` as we would result to the same behavior of having no warmup queries Warmup queries concept is meant to be removed into the future as we won't be able to use them when offline and the scenario that needed them (cozy-banks and cozy-drive apps) does not exist anymore This replies to #1506 (comment) Related commit: bb43ae9
Those doc's attributes are specific to the JSON API and should not be inserted into the Pouch database This implies that we will have a difference on documents regarding if they are served through the cozy-stack or through a local PouchDB, the first one may include those fields in their result, but not the second one So from now we should avoid, as much as possible, to relies on the `attributes` member to prevent bugs on Offline mode. Multiple commits to fix usages of `attributes` in cozy-client will be done after this one Usage of `attributes` and `meta` members on cozy-app will also have to be fixed. This will be a requirement to implement Offline mode on cozy-apps This replies to #1486 (comment)
By doing so we add unnecessary values to the capabilities object that will now contain more data than just `.attributes` As those are supernumerary values we consider that this is not problematic, but we may want to find a cleaner solution in the future
Calls of `isInstalled` and all related methods have been checked and `apps` parameter is always a result of `client.query()` so we know that `.slug` can be used in replacement of `.attributes.slug`
Calls of those methods have been checked and `instanceInfo` parameter is always a result of `useInstanceInfo` so we know that `.attributes` can be omited
For some reason the Pouch engine would ignore any partialFilter if it is not included in the selector This may be the same reason we had to do this fix: 7c69838#diff-41848dd46551544674c134f359a5d7cddea46dd1e47c21da6814e1d1d585173dR482-R489
Previous implementation would not be backward compatible with older Flagship app versions By checking for method availability, we ensure the code is called only on the correct Flagship app versions, otherwise the old process is called Related PR: #1518
In previous implementation we did not await for the `persistVirtualDocuments()` result before completing the request This was done because the persistance was not mandatory for the request's result and doing it in parallel would be a good way to optimize timings But in some recent experiments we found a scenario where we would benefit from the `await` in order to some external code until the data is actually persisted Related PR: #1486
Ldoppea
force-pushed
the
feat/meta_offline
branch
from
September 19, 2024 14:01
d1aee07
to
09c2314
Compare
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.
This PR is a temporary "main" for all Offline features until everything is ready to be merged into our main branch
PR List:
StackLink.request()
when offline #1487downloadFile
method infile
model #1518reset()
method #1533Related PRs:
downloadFile()
method from cozy-client cozy-ui#2690downloadFile()
method from cozy-client cozy-libs#2581