Skip to content
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 #1239

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open

Meta PR: Implement offline support #1239

wants to merge 86 commits into from

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Aug 26, 2024

This PR is a temporary "main" for all Offline features until everything is ready to be merged into our main branch

PR List:

Related PRs:

### ✨ Features

* Add support for Offline mode (for now only on cozy-home and mespapiers)

### 🐛 Bug Fixes

*

### 🔧 Tech

*

TODO:

@Ldoppea Ldoppea requested review from acezard and zatteo as code owners August 26, 2024 16:09
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
@zatteo
Copy link
Contributor

zatteo commented Sep 2, 2024

🎉🎉

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/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
Ldoppea added a commit to cozy/cozy-home that referenced this pull request Sep 24, 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/mespapiers that referenced this pull request Sep 24, 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 Sep 25, 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
zatteo and others added 13 commits December 11, 2024 16:40
Gemfile, Podfile and package.json updates come from React Native Upgrade Helper.

Package updated to support RN0.73 :
- @react-native-community/datetimepicker
- react-native-svg-transformer
- react-native-flipper

react-native-flipper could be updated more but it is not working anyway for the moment so I just updated it to make it compile.

`react-native run-android --variant=devDebug` CLI command has been changed to `react-native run-android --mode=devDebug`
This is needed to fix `ld: symbol(s) not found for architecture arm64`
error on iOS CI

This happens because Flipper is not meant to be built in release mode
and because ReactNative removed direct support for Flipper since latest
versions
`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
Ldoppea and others added 28 commits January 17, 2025 11:05
By default, `react-native-performance-flipper-reporter` does not
support custom measurement categories

This commit patches `react-native-performance-flipper-reporter` so it
will display as many categories as provided to the
`rnperformances.measure()` method calls
Since our previous upgrades we can now use MMKV instead of AsyncStorage

This migration is done in order to improve performances. MMKV being
faster by multiple order of magnitude than AsyncStorage

Code taken from #1097

Co-authored-by: Théo Poizat <[email protected]>
Since we migrated to MMKV, existing users' data should be migrated from
the old AsyncStorage to MMKV

Code taken from #1097

Co-authored-by: Théo Poizat <[email protected]>
In #1209 we added CozyPouchLink to CozyClient's instance

By default CozyPouchLink starts replicating all its database directly
after being initialized

This is problematic as this happens during the App's startup and so it
will unnecessary slow the startup process

This is unnecessary because on startup, either the app is offline and
so replication cannot be done, either the app is online and so it will
use the cozy-stack. So replication can be delayed

We want to defer the replication to a short delay after the startup
(for now 30s)
Downloading important files on startup may slow down the startup
process, so we want to delay it (for now 30s after the startup)
Call to `synchronize()` may slow down the startup process but is not
necessary for the app to work

It is here only to update the cozy-settings's OAuth clients list to
display the last connexion to the app

So we chose to delay this call a short delay after the startup (for now
10s)

By doing so, we may fail calling the `synchronize()` method if the user
closes the app less than 10s after opening it, but as this is used only
for display purpose, we chose to consider this as not-critical
Icons caching may slow down the startup process but is not necessary
for the app to work

If not called in time, this would only impact cozy-apps opening
animation that will use generic icons (if never called before) or
potentially old icons (in the rare cases when we update a cozy-app
icon)

So we chose to delay this call a short delay after the startup (for now
30s)
With previous implementation, NetService would be configured too late
and so it would have time to do reachability test on google servers
before we configure it with Cozy's servers

This commit move the configuration outside of the React components and
so we ensure it is called as soon as possible
With previous implementation, NetService would do reachability tests
too often and sometimes multiple times in parallel (as we can call
`isOnline` from multiple parallel `client.query()` calls)

This is problematic as it can unnecessary slow down the app processes

This commit caches the isOnline result and register to the `NetInfo`
event listener so stay up-to-date, so we can drastically reduce
reachability tests on Cozy's servers
This upgrade is made possible due to recent RN73 upgrade and will allow
to use `op-sqlite` instead of `react-native-quick-sqlite`
`cozy-client` and `cozy-pouch-link` has been upgraded to `52.0.0` in
order to retrieve the ability to enforce StackLink usage for a query

Related PR: cozy/cozy-client#1575
When doing a backup, we don't want instable network to make the
CozyClient use local PouchLink for some queries that need to read files
paths

In cozy/cozy-client#1575 we implemented the `forceStack` option that
allows to enforce the usage of StackLink instead of other links that
may retrieve local incomplete data

This commit enforce the stack on backup related queries

Related PR: cozy/cozy-client#1575
Previous implementation was incorrect because `lastOpened` prop was
stored as a string in the device's storage and so it was retrieved as
string

Then the date-fns `differenceInMonths` was failing comparing dates as
it accepts only `Date` objects and no string

This commit fixes this by parsing the persisted date into a `Date` and
by fixing related TS typings
For some reasons, the ReactNative API fails to resolve
`cozy-dataproxy-lib/api` path so we must use `/dist` version instead

On the opposite, Jest will fail to resolve the `/dist` version so we
cannot mock cozy-dataproxy-lib

To fix this, we wrap the imports in a local file so we can mock this
local file in Jest
Ldoppea added a commit to cozy/cozy-home that referenced this pull request Jan 20, 2025
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
CozyClient.registerPlugin typing requires an `option` parameter to be
defined

But the RealtimePlugin expect this parameter to be optional or to be an
object

If `null` is given, then the application would crash. We injected
`null` in #1279 because the CI did reject the initial attempt with no
parameter, but this was not the correct solution, the correct one would
be to inject an empty object

In the future we may want to make this parameter optional in the
`registerPlugin` definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants