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

wip; Store some client settings #1167

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

wip; Store some client settings #1167

wants to merge 11 commits into from

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Dec 17, 2024

Work towards #97.

@PIG208 PIG208 force-pushed the pr-settings branch 2 times, most recently from d5c014e to 370a328 Compare December 17, 2024 00:28
This has been addressed in Greg's upstream PR:
  https://git hub.com/simo lus3/drift/pull/3022

Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
@gnprice
Copy link
Member

gnprice commented Dec 17, 2024

Thanks for taking this on! Looking forward to it.

One first high-level comment: in the branch we merge, let's have at least one of these two settings get added as its own separate commit, complete with a migration. That way we have a nice demonstration of what it'll look like to add each new setting in the future.

The name "unset" was chosen instead of "default" because the latter is a
keyword. We could write a custom `TypeConverter` to use "default"
instead, but `textEnum` is more convenient.

Signed-off-by: Zixuan James Li <[email protected]>
These were supposed to be updated in commit
fc80be1
where we replaced loadGlobalStore with getGlobalStore.

`LiveGlobalBindings.load` is the only thing left analogous to the
previously referred to `loadGlobalStore` method. To avoid direct
referencce to this specific implementation on `GlobalStore`, mention
that loading it for the first time is expected to be asynchronous
instead.

Signed-off-by: Zixuan James Li <[email protected]>
Signed-off-by: Zixuan James Li <[email protected]>
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've skimmed now through more of this code. A few other high-level comments below.

Comment on lines +142 to +147
from2To3: (m, schema) async {
await m.createTable(schema.globalSettings);
},
from3To4: (m, schema) async {
await m.addColumn(
schema.globalSettings, schema.globalSettings.browserPreference);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db: Start generating step by step migration helper

https://drift.simonbinder.eu/migrations/step_by_step/#manual-generation

Hmm, interesting. Yeah, this seems useful — I think this migration to 4 is already an example where this structure lets the new migration get added as just a separate thing, and with the more manual structure we'd have to have logic for it to interact with the migration to 3.

import 'package:drift/drift.dart' as i1;
import 'package:drift/drift.dart'; // ignore_for_file: type=lint,unused_import

// GENERATED BY drift_dev, DO NOT MODIFY.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give this a .g.dart name, so it's clear in a more uniform way that it's generated.

Comment on lines +7 to +8
# Generated code from drift can contain unused local variables.
- lib/model/database.g.dart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reported as a bug in Drift — it's fine for the generated code to do this but then it should contain an ignore comment for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed simolus3/drift#3384 for that.

Comment on lines +46 to +52
/// The visual theme of the app.
///
/// See [zulipThemeData] for how themes are determined.
///
/// Renaming existing enum values will invalidate the database.
/// Write a migration if such a change is necessary.
enum ThemeSetting {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put these enum definitions in a new file lib/model/settings.dart.

Then that can also be the home of other logic we add in the future for individual settings.

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