Skip to content

Offline delay #153

@Nico04

Description

@Nico04

Plugin works great in normal conditions.
But if, after cache is first initiated, device goes offline, the getDocuments methods takes a while before returning cached data.
Looking at the code, it may come from the line await cacheDocRef.get(); in isFetchDocuments, which tries to get the date from the server first, even if offline. Then after a while (I guess the default Firestore timeout), it returns the cached data then return cached data.
Is there any way to improve this ? If it's offline, no need to check date at all, don't you think ?

EDIT : Maybe just add a new parameter ignoreServer (or cacheOnly) to getDocuments that completly ignore server date check, returning cached data directly ? And application will then set that to true when it detected that device is offline.

EDIT2 : Another feature idea could be to add a new method getDocumentsSnapshots that returns a Stream just like the Firestore snapshots() method, but returning cached data immediatly, than checks server's data, download it if needed, and return fresh new data in the stream if needed. That way, UI will display cached data immediatly, then updates if new version is available (if online).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions