-
Notifications
You must be signed in to change notification settings - Fork 1
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: Implement offline support through CozyPouchLink #1209
base: feat/meta_offline
Are you sure you want to change the base?
Commits on Sep 25, 2024
-
feat: Add react-native modules for PouchDB
`react-native-quick-sqlite` is enforced to version `8.0.6` in order to be compatible with RN0.72 Related article: https://dev.to/craftzdog/a-performant-way-to-use-pouchdb7-on-react-native-in-2022-24ej
Configuration menu - View commit details
-
Copy full SHA for 9edfd8b - Browse repository at this point
Copy the full SHA 9edfd8bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f9d3ec - Browse repository at this point
Copy the full SHA 6f9d3ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6d95b9d - Browse repository at this point
Copy the full SHA 6d95b9dView commit details -
feat: Configure CozyClient to use CozyPouchLink
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
Configuration menu - View commit details
-
Copy full SHA for 9876b02 - Browse repository at this point
Copy the full SHA 9876b02View commit details -
feat: Configure CozyClient to also use StackLink (when online)
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
Configuration menu - View commit details
-
Copy full SHA for 4f7614c - Browse repository at this point
Copy the full SHA 4f7614cView commit details -
feat: Add PouchDBFind plugin to the PouchDB configuration
This plugin is required by cozy-client to process `find` queries Related PR: cozy/cozy-client#1507
Configuration menu - View commit details
-
Copy full SHA for 4badb35 - Browse repository at this point
Copy the full SHA 4badb35View commit details -
feat: Add clientCachedStorage to handle CozyClient's requests cache
PouchDB can handle only `client.query()` requests For all other requests, like `client.fetchJSON()` we want to be able to store the request result in the device's AsyncStorage so we can re-use this result when the device is offline Data is stored using the client's url and the request content as key (it can be a string or a full request object)
Configuration menu - View commit details
-
Copy full SHA for 28c007f - Browse repository at this point
Copy the full SHA 28c007fView commit details -
feat: Cache
/apps/:slug/open
request for offline support`/apps/:slug/open` request is based on `client.fetchJSON()` and is on the critical execution path for the application to boot So we want to use the new caching mechanism from previous commit in order to retrieve this request's cached result if the application is booted while the device is offline
Configuration menu - View commit details
-
Copy full SHA for 0320297 - Browse repository at this point
Copy the full SHA 0320297View commit details -
feat: Upgrade cozy-intent to
2.23.0
`cozy-intent` has been upgraded to `2.23.0` to retrieve new interfaces for FlagshipLink and files downloading Related PR: cozy/cozy-libs#2562
Configuration menu - View commit details
-
Copy full SHA for b5e9ba0 - Browse repository at this point
Copy the full SHA b5e9ba0View commit details -
feat: Implement FlagshipLinkRequest interface through localMethods
In previous commits we configured the application's cozy-client to use CozyPouchLink This link is configured for all react-native side queries, but not for cozy-app queries as they are served inside of WebViews and use a different cozy-client instance We want cozy-apps to benefits from the CozyPouchLink by redirecting their queries to the react-native side using the new FlagshipLink interface With this interface, all cozy-apps queries can be redirected to the react-native side using cozy-intent/post-me In order to intercept them, then we should declare `FlagshipLinkRequest()` method `localMethods` Related PR: cozy/cozy-client#1505
Configuration menu - View commit details
-
Copy full SHA for 9f7493c - Browse repository at this point
Copy the full SHA 9f7493cView commit details -
feat: Enable CacheMode for CozyProxyWebView on android when offline
When a cozy-app's WebView is served offline, then the cozy-app bundle is served from local folder using the CozyProxyWebview, and since previous commits, the cozy-client's queries are served through `FlagshipLink` With those mechanisms, nearly all data are available offline except two things: - cozy-stack static assets (i.e. some css files, avatar, partners logos etc) - `fetchJSON()` requests This commit tries to handle the static assets part Those assets are often served with HTTP cache activated, and so the WebView should be able to load them correctly when the device is offline. However on Android, the WebView's cache seems not to persist after the application is closed Activating the `cacheMode=LOAD_CACHE_ELSE_NETWORK` seems to fix this behavior. But it prioritizes too much the cache over fresh data, so we want to activate it only when strictly necessary, which is when the application is offline This also allows to load partners logos that are not cached by the cozy-stack (as of today). But we expect to modify the cozy-stack to enable cache on them
Configuration menu - View commit details
-
Copy full SHA for d0ee380 - Browse repository at this point
Copy the full SHA d0ee380View commit details -
feat: Ignore queries warmup on PouchLink
With previous changes, we now expect the CozyPouchLink to be the last link of the chain, so forwarding the query would result to an exception thrown This mean we cannot forward the query when warmup queries are not finished yet So we want to allow CozyPouchLink to ignore the verification step and process the query independently of the warmup queries status To allow this we introduce the `ignoreWarmup` parameter. When set to `true` the CozyPouchLink will process the query even if warmup is not finished yet Related PR: cozy/cozy-client#1506
Configuration menu - View commit details
-
Copy full SHA for 6f784de - Browse repository at this point
Copy the full SHA 6f784deView commit details -
feat: Declare schemas into cozy-client instance
Some cozy-apps declare a data `schema` into cozy-client instance This schema is then used for processing queries As we now process cozy-app queries on the react-native side through FlagshipLinkRequest, we want to declared this schema in the Flagship app's cozy-client For now we only need to implement the one from cozy-home The ideal implementation would be to extract it from the cozy-app's bundle, but we did not implement anything to support this (we should first investigate how to do this). So for now it is hardcoded
Configuration menu - View commit details
-
Copy full SHA for dd1b07a - Browse repository at this point
Copy the full SHA dd1b07aView commit details -
Configuration menu - View commit details
-
Copy full SHA for ffd0b10 - Browse repository at this point
Copy the full SHA ffd0b10View commit details -
feat: Allow to send Pouch databases through email for debug purpose
By adding offline support through PouchDB, we expect database related bugs to happens in the future In order to ease debugging them, we want to allow exploring the local PouchDB files The easier way is to add the ability to extract them from the device and send them through email to cozy's support team
Configuration menu - View commit details
-
Copy full SHA for 8ceea9b - Browse repository at this point
Copy the full SHA 8ceea9bView commit details -
Configuration menu - View commit details
-
Copy full SHA for fa2d727 - Browse repository at this point
Copy the full SHA fa2d727View commit details -
feat: Prevent local PouchDB modification to be replicated to remote DB
For now we don't want to replicate local changes into remote PouchDB as we first want to ensure everything works as expected locally before activating two-way replication in the future
Configuration menu - View commit details
-
Copy full SHA for 749ef40 - Browse repository at this point
Copy the full SHA 749ef40View commit details