Skip to content

Commit

Permalink
db: Support setting browser preference
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 committed Dec 26, 2024
1 parent f4bfc31 commit 609b3cf
Show file tree
Hide file tree
Showing 18 changed files with 861 additions and 17 deletions.
4 changes: 4 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"@settingsPageTitle": {
"description": "Title for the settings page."
},
"settingsUseExternal": "Use external browser",
"@settingsUseExternal": {
"description": "Whether to open links with external browser or not"
},
"switchAccountButton": "Switch account",
"@switchAccountButton": {
"description": "Label for main-menu button leading to the choose-account page."
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ abstract class ZulipLocalizations {
/// **'Settings'**
String get settingsPageTitle;

/// Whether to open links with external browser or not
///
/// In en, this message translates to:
/// **'Use external browser'**
String get settingsUseExternal;

/// Label for main-menu button leading to the choose-account page.
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
@override
String get settingsPageTitle => 'Settings';

@override
String get settingsUseExternal => 'Use external browser';

@override
String get switchAccountButton => 'Switch account';

Expand Down
9 changes: 8 additions & 1 deletion lib/model/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Accounts extends Table {
class GlobalSettings extends Table {
Column<String> get themeSetting => textEnum<ThemeSetting>()
.withDefault(const Variable('unset'))();

Column<String> get browserPreference => textEnum<BrowserPreference>()
.nullable()();
}

class UriConverter extends TypeConverter<Uri, String> {
Expand All @@ -73,7 +76,7 @@ class AppDatabase extends _$AppDatabase {
// * Write a migration in `onUpgrade` below.
// * Write tests.
@override
int get schemaVersion => 3; // See note.
int get schemaVersion => 4; // See note.

@override
MigrationStrategy get migration {
Expand Down Expand Up @@ -104,6 +107,10 @@ class AppDatabase extends _$AppDatabase {
from2To3: (m, schema) async {
await m.createTable(schema.globalSettings);
},
from3To4: (m, schema) async {
await m.addColumn(
schema.globalSettings, schema.globalSettings.browserPreference);
},
));
});
}
Expand Down
92 changes: 85 additions & 7 deletions lib/model/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 609b3cf

Please sign in to comment.