-
Notifications
You must be signed in to change notification settings - Fork 309
Store some user data locally #13
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
Comments
We'll use SQLite for the database. There are a couple of NoSQL databases written in Dart that have some popularity in the Flutter world: Isar, and its predecessor Hive. But:
Then the next question is what library to use to make it convenient to access SQLite from Dart in a Flutter app. From a bit of searching, there are several options: sqfliteVenerable and popular. The interface The migration support is also very similar to the Android SQLite library, which means migrations are fairly manual: see upstream example. This option is probably a reliable one as far as it goes, but leaving a lot to be done manually, much of that fairly error-prone. FloorThe Android people are well aware that the Android SQLite library leaves a lot of room for useful higher-level abstractions. Their answer to that, introduced several years ago, is the Room persistence library. It offers an ORM-like layer, with compile-time verification of your SQL queries, and a migrations system that supports better-abstracted and more-testable migrations. It seems pretty good. Floor is explicitly inspired by Room, which makes it an appealing idea. Under the hood, it uses Unfortunately, it gives me the feeling that it's incomplete and not actively maintained. For example here's the docs on migrations: On the "not maintained" side, the issue tracker is at https://github.com/pinchbv/floor/issues; see PR 638. Or even before that, issue 577, noting in 2021 that it seemed unmaintained. Or issue 603, which seems a pretty core bug and has no reply from the author/maintainer since it was filed in 2021. DriftThis is also atop SQLite (though with the same authors' sqlite3 rather than The migration support is less appealing than Floor's (or at least Room's) — it's a lot closer to the manual structure of The issue tracker is quite encouraging — it seems to be actively and conscientiously maintained.
ConclusionI plan to try Drift first. If that's unsatisfying, I may try Floor. If we went down to the level of One thing I'll be looking for with Drift, and with Floor if I try that, is that the underlying SQLite schemas are reasonably clean, so that accessing them through a plainer SQLite binding wouldn't be materially worse than it would be for a hand-written schema. We'll want that in order to access the data from platform-native code, and it will also help keep the door open to switching later from Floor to Room or something else if desired. |
Flutter has a "happy paths" recommendation:
Doesn't change any conclusions, I think. There's also a video about Drift, which I haven't watched. Meanwhile I have a draft PR at #22 to use Drift; and I've been making several other changes to prepare for storing data:
More to come. |
We'll need to store some of the user's data in a local database on the device.
The minimum version of this for a fully-functioning Zulip client would be:
In particular, that covers everything the existing RN-based app stores and doesn't discard when you switch between accounts.
A future version would also store the full server data: other users with their names and avatars, streams with their names and subscription colors, recent/unread messages, and so on. But we can go a long way without that — the RN-based app has never made great use of this anyway. So we'll file a separate issue for that later.
The scope of this issue is to have local storage in some reasonable form that we think could be good to use in a production app, and to have some data we store there that can change and is reflected in the UI. We'll then add particular pieces of data to it as needed.
The text was updated successfully, but these errors were encountered: