customize quick tab switcher buttons
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2026 Fabian Freund.
|
||||
*
|
||||
* This file is part of WebLibre
|
||||
* (see https://weblibre.eu).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/quick_switcher_button_config.drift.dart';
|
||||
import 'package:weblibre/features/user/data/database/database.dart';
|
||||
import 'package:weblibre/features/user/data/database/definitions.drift.dart';
|
||||
|
||||
/// Mirror of [ToolbarButtonConfigDao] against the separate
|
||||
/// `quick_switcher_button_configs` table. See that DAO for the rationale behind
|
||||
/// each visibility-partitioned order-key operation.
|
||||
@DriftAccessor()
|
||||
class QuickSwitcherButtonConfigDao extends DatabaseAccessor<UserDatabase>
|
||||
with $QuickSwitcherButtonConfigDaoMixin {
|
||||
QuickSwitcherButtonConfigDao(super.attachedDatabase);
|
||||
|
||||
Selectable<QuickSwitcherButtonConfig> selectAll() =>
|
||||
db.quickSwitcherButtonConfigs.select()
|
||||
..orderBy([(t) => OrderingTerm.asc(t.orderKey)]);
|
||||
|
||||
Stream<List<QuickSwitcherButtonConfig>> watchAll() => selectAll().watch();
|
||||
|
||||
Future<List<QuickSwitcherButtonConfig>> getAll() => selectAll().get();
|
||||
|
||||
Future<void> upsert(QuickSwitcherButtonConfig config) =>
|
||||
into(db.quickSwitcherButtonConfigs).insertOnConflictUpdate(config);
|
||||
|
||||
Future<void> assignOrderKey(String buttonId, {required String orderKey}) =>
|
||||
(update(
|
||||
db.quickSwitcherButtonConfigs,
|
||||
)..where((t) => t.buttonId.equals(buttonId))).write(
|
||||
QuickSwitcherButtonConfigsCompanion(orderKey: Value(orderKey)),
|
||||
);
|
||||
|
||||
Future<void> assignVisibility(String buttonId, {required bool visible}) =>
|
||||
transaction(() async {
|
||||
// Land the toggled button at the trailing edge of its *new* section so
|
||||
// its order_key always stays inside the visibility partition.
|
||||
final orderKey = await generateTrailingOrderKey(
|
||||
isVisible: visible,
|
||||
).getSingle();
|
||||
|
||||
await (update(
|
||||
db.quickSwitcherButtonConfigs,
|
||||
)..where((t) => t.buttonId.equals(buttonId))).write(
|
||||
QuickSwitcherButtonConfigsCompanion(
|
||||
isVisible: Value(visible),
|
||||
orderKey: Value(orderKey),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
Future<void> assignFallback(String buttonId, String? fallbackId) =>
|
||||
(update(
|
||||
db.quickSwitcherButtonConfigs,
|
||||
)..where((t) => t.buttonId.equals(buttonId))).write(
|
||||
QuickSwitcherButtonConfigsCompanion(fallbackId: Value(fallbackId)),
|
||||
);
|
||||
|
||||
Future<void> replaceAll(List<QuickSwitcherButtonConfig> configs) =>
|
||||
transaction(() async {
|
||||
await delete(db.quickSwitcherButtonConfigs).go();
|
||||
await _insertWithDeferredFallbacks(configs);
|
||||
});
|
||||
|
||||
Future<void> seedMissing(
|
||||
List<({String buttonId, bool defaultVisible, String? defaultFallback})>
|
||||
defaults,
|
||||
) async {
|
||||
final existing = await getAll();
|
||||
final existingIds = {for (final r in existing) r.buttonId};
|
||||
|
||||
final missing = defaults
|
||||
.where((d) => !existingIds.contains(d.buttonId))
|
||||
.toList();
|
||||
if (missing.isEmpty) return;
|
||||
|
||||
await transaction(() async {
|
||||
final inserted = <QuickSwitcherButtonConfig>[];
|
||||
for (final def in missing) {
|
||||
final orderKey = await generateTrailingOrderKey(
|
||||
isVisible: def.defaultVisible,
|
||||
).getSingle();
|
||||
inserted.add(
|
||||
QuickSwitcherButtonConfig(
|
||||
buttonId: def.buttonId,
|
||||
orderKey: orderKey,
|
||||
isVisible: def.defaultVisible,
|
||||
fallbackId: def.defaultFallback,
|
||||
),
|
||||
);
|
||||
await into(db.quickSwitcherButtonConfigs).insert(
|
||||
QuickSwitcherButtonConfig(
|
||||
buttonId: def.buttonId,
|
||||
orderKey: orderKey,
|
||||
isVisible: def.defaultVisible,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await _assignFallbacks(inserted);
|
||||
});
|
||||
}
|
||||
|
||||
SingleSelectable<String> generateLeadingOrderKey({
|
||||
int bucket = 0,
|
||||
required bool isVisible,
|
||||
}) => db.definitionsDrift.quickSwitcherLeadingOrderKey(
|
||||
bucket: bucket,
|
||||
isVisible: isVisible,
|
||||
);
|
||||
|
||||
SingleSelectable<String> generateTrailingOrderKey({
|
||||
int bucket = 0,
|
||||
required bool isVisible,
|
||||
}) => db.definitionsDrift.quickSwitcherTrailingOrderKey(
|
||||
bucket: bucket,
|
||||
isVisible: isVisible,
|
||||
);
|
||||
|
||||
SingleOrNullSelectable<String> generateOrderKeyAfterButtonId(
|
||||
String buttonId, {
|
||||
required bool isVisible,
|
||||
}) => db.definitionsDrift.quickSwitcherOrderKeyAfterButton(
|
||||
buttonId: buttonId,
|
||||
isVisible: isVisible,
|
||||
);
|
||||
|
||||
SingleSelectable<String> generateOrderKeyBeforeButtonId(
|
||||
String buttonId, {
|
||||
required bool isVisible,
|
||||
}) => db.definitionsDrift.quickSwitcherOrderKeyBeforeButton(
|
||||
buttonId: buttonId,
|
||||
isVisible: isVisible,
|
||||
);
|
||||
|
||||
Future<void> _insertWithDeferredFallbacks(
|
||||
List<QuickSwitcherButtonConfig> configs,
|
||||
) async {
|
||||
for (final config in configs) {
|
||||
await into(db.quickSwitcherButtonConfigs).insert(
|
||||
QuickSwitcherButtonConfig(
|
||||
buttonId: config.buttonId,
|
||||
orderKey: config.orderKey,
|
||||
isVisible: config.isVisible,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await _assignFallbacks(configs);
|
||||
}
|
||||
|
||||
Future<void> _assignFallbacks(List<QuickSwitcherButtonConfig> configs) async {
|
||||
for (final config in configs) {
|
||||
if (config.fallbackId == null) continue;
|
||||
await assignFallback(config.buttonId, config.fallbackId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// dart format width=80
|
||||
// ignore_for_file: type=lint
|
||||
import 'package:drift/drift.dart' as i0;
|
||||
import 'package:weblibre/features/user/data/database/database.dart' as i1;
|
||||
|
||||
mixin $QuickSwitcherButtonConfigDaoMixin
|
||||
on i0.DatabaseAccessor<i1.UserDatabase> {
|
||||
QuickSwitcherButtonConfigDaoManager get managers =>
|
||||
QuickSwitcherButtonConfigDaoManager(this);
|
||||
}
|
||||
|
||||
class QuickSwitcherButtonConfigDaoManager {
|
||||
final $QuickSwitcherButtonConfigDaoMixin _db;
|
||||
QuickSwitcherButtonConfigDaoManager(this._db);
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/cache.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/onboarding.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/quick_switcher_button_config.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/search_tokens.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/setting.dart';
|
||||
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.dart';
|
||||
@@ -37,13 +38,14 @@ import 'package:weblibre/features/user/data/database/database.steps.dart';
|
||||
CacheDao,
|
||||
OnboardingDao,
|
||||
ToolbarButtonConfigDao,
|
||||
QuickSwitcherButtonConfigDao,
|
||||
SearchTokensDao,
|
||||
ProxyProfileDao,
|
||||
],
|
||||
)
|
||||
class UserDatabase extends $UserDatabase {
|
||||
@override
|
||||
final int schemaVersion = 8;
|
||||
final int schemaVersion = 9;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
@@ -121,5 +123,9 @@ class UserDatabase extends $UserDatabase {
|
||||
'DROP TABLE IF EXISTS proxy_routing_setting',
|
||||
);
|
||||
},
|
||||
from8To9: (m, schema) async {
|
||||
await m.createTable(schema.quickSwitcherButtonConfigs);
|
||||
await m.createIndex(schema.idxQuickSwitcherOrderKey);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,14 @@ import 'package:weblibre/features/user/data/database/daos/onboarding.dart'
|
||||
as i5;
|
||||
import 'package:weblibre/features/user/data/database/daos/toolbar_button_config.dart'
|
||||
as i6;
|
||||
import 'package:weblibre/features/user/data/database/daos/search_tokens.dart'
|
||||
import 'package:weblibre/features/user/data/database/daos/quick_switcher_button_config.dart'
|
||||
as i7;
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.dart'
|
||||
import 'package:weblibre/features/user/data/database/daos/search_tokens.dart'
|
||||
as i8;
|
||||
import 'package:drift/internal/modular.dart' as i9;
|
||||
import 'package:sqlite3/common.dart' as i10;
|
||||
import 'package:weblibre/features/user/data/database/daos/proxy_profile.dart'
|
||||
as i9;
|
||||
import 'package:drift/internal/modular.dart' as i10;
|
||||
import 'package:sqlite3/common.dart' as i11;
|
||||
|
||||
abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
$UserDatabase(i0.QueryExecutor e) : super(e);
|
||||
@@ -27,6 +29,8 @@ abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
late final i1.Riverpod riverpod = i1.Riverpod(this);
|
||||
late final i1.ToolbarButtonConfigs toolbarButtonConfigs =
|
||||
i1.ToolbarButtonConfigs(this);
|
||||
late final i1.QuickSwitcherButtonConfigs quickSwitcherButtonConfigs =
|
||||
i1.QuickSwitcherButtonConfigs(this);
|
||||
late final i1.SearchTokens searchTokens = i1.SearchTokens(this);
|
||||
late final i2.SettingDao settingDao = i2.SettingDao(this as i3.UserDatabase);
|
||||
late final i4.CacheDao cacheDao = i4.CacheDao(this as i3.UserDatabase);
|
||||
@@ -35,13 +39,15 @@ abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
);
|
||||
late final i6.ToolbarButtonConfigDao toolbarButtonConfigDao =
|
||||
i6.ToolbarButtonConfigDao(this as i3.UserDatabase);
|
||||
late final i7.SearchTokensDao searchTokensDao = i7.SearchTokensDao(
|
||||
late final i7.QuickSwitcherButtonConfigDao quickSwitcherButtonConfigDao =
|
||||
i7.QuickSwitcherButtonConfigDao(this as i3.UserDatabase);
|
||||
late final i8.SearchTokensDao searchTokensDao = i8.SearchTokensDao(
|
||||
this as i3.UserDatabase,
|
||||
);
|
||||
late final i8.ProxyProfileDao proxyProfileDao = i8.ProxyProfileDao(
|
||||
late final i9.ProxyProfileDao proxyProfileDao = i9.ProxyProfileDao(
|
||||
this as i3.UserDatabase,
|
||||
);
|
||||
i1.DefinitionsDrift get definitionsDrift => i9.ReadDatabaseContainer(
|
||||
i1.DefinitionsDrift get definitionsDrift => i10.ReadDatabaseContainer(
|
||||
this,
|
||||
).accessor<i1.DefinitionsDrift>(i1.DefinitionsDrift.new);
|
||||
@override
|
||||
@@ -57,6 +63,8 @@ abstract class $UserDatabase extends i0.GeneratedDatabase {
|
||||
riverpod,
|
||||
toolbarButtonConfigs,
|
||||
i1.idxToolbarOrderKey,
|
||||
quickSwitcherButtonConfigs,
|
||||
i1.idxQuickSwitcherOrderKey,
|
||||
searchTokens,
|
||||
i1.idxSearchTokensInsertedAt,
|
||||
i1.idxSearchTokensReservedAt,
|
||||
@@ -78,11 +86,16 @@ class $UserDatabaseManager {
|
||||
i1.$RiverpodTableManager(_db, _db.riverpod);
|
||||
i1.$ToolbarButtonConfigsTableManager get toolbarButtonConfigs =>
|
||||
i1.$ToolbarButtonConfigsTableManager(_db, _db.toolbarButtonConfigs);
|
||||
i1.$QuickSwitcherButtonConfigsTableManager get quickSwitcherButtonConfigs =>
|
||||
i1.$QuickSwitcherButtonConfigsTableManager(
|
||||
_db,
|
||||
_db.quickSwitcherButtonConfigs,
|
||||
);
|
||||
i1.$SearchTokensTableManager get searchTokens =>
|
||||
i1.$SearchTokensTableManager(_db, _db.searchTokens);
|
||||
}
|
||||
|
||||
extension DefineFunctions on i10.CommonDatabase {
|
||||
extension DefineFunctions on i11.CommonDatabase {
|
||||
void defineFunctions({
|
||||
required String Function(int, String?) lexoRankNext,
|
||||
required String Function(int, String?) lexoRankPrevious,
|
||||
@@ -96,7 +109,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
}) {
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_next',
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
argumentCount: const i11.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as int;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -105,7 +118,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_previous',
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
argumentCount: const i11.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as int;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -114,7 +127,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_reorder_after',
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
argumentCount: const i11.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -123,7 +136,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'lexo_rank_reorder_before',
|
||||
argumentCount: const i10.AllowedArgumentCount(2),
|
||||
argumentCount: const i11.AllowedArgumentCount(2),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
final arg1 = args[1] as String?;
|
||||
@@ -132,14 +145,14 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'generate_content_hash',
|
||||
argumentCount: const i10.AllowedArgumentCount(0),
|
||||
argumentCount: const i11.AllowedArgumentCount(0),
|
||||
function: (args) {
|
||||
return generateContentHash();
|
||||
},
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_indexable',
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
argumentCount: const i11.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlIndexable(arg0);
|
||||
@@ -147,7 +160,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_canonical',
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
argumentCount: const i11.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlCanonical(arg0);
|
||||
@@ -155,7 +168,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_host',
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
argumentCount: const i11.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlHost(arg0);
|
||||
@@ -163,7 +176,7 @@ extension DefineFunctions on i10.CommonDatabase {
|
||||
);
|
||||
createFunction(
|
||||
functionName: 'url_path',
|
||||
argumentCount: const i10.AllowedArgumentCount(1),
|
||||
argumentCount: const i11.AllowedArgumentCount(1),
|
||||
function: (args) {
|
||||
final arg0 = args[0] as String?;
|
||||
return urlPath(arg0);
|
||||
|
||||
@@ -1085,6 +1085,161 @@ final class Schema8 extends i0.VersionedSchema {
|
||||
);
|
||||
}
|
||||
|
||||
final class Schema9 extends i0.VersionedSchema {
|
||||
Schema9({required super.database}) : super(version: 9);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
setting,
|
||||
proxyProfile,
|
||||
idxProxyProfileUpdatedAt,
|
||||
iconCache,
|
||||
onboarding,
|
||||
riverpod,
|
||||
toolbarButtonConfigs,
|
||||
idxToolbarOrderKey,
|
||||
quickSwitcherButtonConfigs,
|
||||
idxQuickSwitcherOrderKey,
|
||||
searchTokens,
|
||||
idxSearchTokensInsertedAt,
|
||||
idxSearchTokensReservedAt,
|
||||
];
|
||||
late final Shape0 setting = Shape0(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'setting',
|
||||
withoutRowId: false,
|
||||
isStrict: true,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_1, _column_2],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape9 proxyProfile = Shape9(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'proxy_profile',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_20,
|
||||
_column_21,
|
||||
_column_22,
|
||||
_column_23,
|
||||
_column_30,
|
||||
_column_24,
|
||||
_column_25,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxProxyProfileUpdatedAt = i1.Index(
|
||||
'idx_proxy_profile_updated_at',
|
||||
'CREATE INDEX idx_proxy_profile_updated_at ON proxy_profile (updated_at)',
|
||||
);
|
||||
late final Shape1 iconCache = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'icon_cache',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_3, _column_4, _column_5],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape2 onboarding = Shape2(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'onboarding',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_6, _column_7],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape3 riverpod = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'riverpod',
|
||||
withoutRowId: true,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_0, _column_8, _column_9, _column_10],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
late final Shape4 toolbarButtonConfigs = Shape4(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'toolbar_button_configs',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_11, _column_12, _column_13, _column_14],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxToolbarOrderKey = i1.Index(
|
||||
'idx_toolbar_order_key',
|
||||
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
|
||||
);
|
||||
late final Shape4 quickSwitcherButtonConfigs = Shape4(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'quick_switcher_button_configs',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_11, _column_12, _column_31, _column_32],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxQuickSwitcherOrderKey = i1.Index(
|
||||
'idx_quick_switcher_order_key',
|
||||
'CREATE INDEX idx_quick_switcher_order_key ON quick_switcher_button_configs (order_key)',
|
||||
);
|
||||
late final Shape6 searchTokens = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'search_tokens',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [_column_15, _column_16, _column_17, _column_18, _column_19],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null,
|
||||
);
|
||||
final i1.Index idxSearchTokensInsertedAt = i1.Index(
|
||||
'idx_search_tokens_inserted_at',
|
||||
'CREATE INDEX idx_search_tokens_inserted_at ON search_tokens (inserted_at)',
|
||||
);
|
||||
final i1.Index idxSearchTokensReservedAt = i1.Index(
|
||||
'idx_search_tokens_reserved_at',
|
||||
'CREATE INDEX idx_search_tokens_reserved_at ON search_tokens (reserved_at)',
|
||||
);
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<int> _column_31(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>(
|
||||
'is_visible',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i1.DriftSqlType.int,
|
||||
$customConstraints: 'NOT NULL DEFAULT FALSE',
|
||||
defaultValue: const i1.CustomExpression('FALSE'),
|
||||
);
|
||||
i1.GeneratedColumn<String> _column_32(
|
||||
String aliasedName,
|
||||
) => i1.GeneratedColumn<String>(
|
||||
'fallback_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i1.DriftSqlType.string,
|
||||
$customConstraints:
|
||||
'REFERENCES quick_switcher_button_configs(button_id)ON DELETE SET NULL',
|
||||
);
|
||||
i0.MigrationStepWithVersion migrationSteps({
|
||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||
@@ -1093,6 +1248,7 @@ i0.MigrationStepWithVersion migrationSteps({
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
required Future<void> Function(i1.Migrator m, Schema7 schema) from6To7,
|
||||
required Future<void> Function(i1.Migrator m, Schema8 schema) from7To8,
|
||||
required Future<void> Function(i1.Migrator m, Schema9 schema) from8To9,
|
||||
}) {
|
||||
return (currentVersion, database) async {
|
||||
switch (currentVersion) {
|
||||
@@ -1131,6 +1287,11 @@ i0.MigrationStepWithVersion migrationSteps({
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from7To8(migrator, schema);
|
||||
return 8;
|
||||
case 8:
|
||||
final schema = Schema9(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from8To9(migrator, schema);
|
||||
return 9;
|
||||
default:
|
||||
throw ArgumentError.value('Unknown migration from $currentVersion');
|
||||
}
|
||||
@@ -1145,6 +1306,7 @@ i1.OnUpgrade stepByStep({
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
required Future<void> Function(i1.Migrator m, Schema7 schema) from6To7,
|
||||
required Future<void> Function(i1.Migrator m, Schema8 schema) from7To8,
|
||||
required Future<void> Function(i1.Migrator m, Schema9 schema) from8To9,
|
||||
}) => i0.VersionedSchema.stepByStepHelper(
|
||||
step: migrationSteps(
|
||||
from1To2: from1To2,
|
||||
@@ -1154,5 +1316,6 @@ i1.OnUpgrade stepByStep({
|
||||
from5To6: from5To6,
|
||||
from6To7: from6To7,
|
||||
from7To8: from7To8,
|
||||
from8To9: from8To9,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -45,6 +45,18 @@ CREATE TABLE toolbar_button_configs (
|
||||
|
||||
CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs(order_key);
|
||||
|
||||
-- Independently-configured button set for the quick tab switcher's trailing
|
||||
-- cluster. Same shape as toolbar_button_configs but a separate table so the two
|
||||
-- toolbars keep fully isolated ordering/visibility/fallbacks.
|
||||
CREATE TABLE quick_switcher_button_configs (
|
||||
button_id TEXT NOT NULL PRIMARY KEY,
|
||||
order_key TEXT NOT NULL,
|
||||
is_visible BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
fallback_id TEXT REFERENCES quick_switcher_button_configs(button_id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_quick_switcher_order_key ON quick_switcher_button_configs(order_key);
|
||||
|
||||
CREATE TABLE search_tokens (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
token BLOB NOT NULL,
|
||||
@@ -111,6 +123,58 @@ toolbarOrderKeyBeforeButton(:button_id AS TEXT, :is_visible AS BOOL):
|
||||
FROM ordered_table
|
||||
WHERE button_id = :button_id;
|
||||
|
||||
-- Quick-switcher variants of the order-key helpers above, scoped to the
|
||||
-- quick_switcher_button_configs table (see the toolbar* queries for rationale).
|
||||
quickSwitcherLeadingOrderKey(:bucket AS INTEGER, :is_visible AS BOOL):
|
||||
SELECT lexo_rank_previous(
|
||||
:bucket,
|
||||
(
|
||||
SELECT order_key
|
||||
FROM quick_switcher_button_configs
|
||||
WHERE is_visible = :is_visible
|
||||
ORDER BY order_key
|
||||
LIMIT 1
|
||||
)
|
||||
);
|
||||
|
||||
quickSwitcherTrailingOrderKey(:bucket AS INTEGER, :is_visible AS BOOL):
|
||||
SELECT lexo_rank_next(
|
||||
:bucket,
|
||||
(
|
||||
SELECT order_key
|
||||
FROM quick_switcher_button_configs
|
||||
WHERE is_visible = :is_visible
|
||||
ORDER BY order_key DESC
|
||||
LIMIT 1
|
||||
)
|
||||
);
|
||||
|
||||
quickSwitcherOrderKeyAfterButton(:button_id AS TEXT, :is_visible AS BOOL):
|
||||
WITH ordered_table AS (
|
||||
SELECT
|
||||
button_id,
|
||||
order_key,
|
||||
LEAD(order_key) OVER (ORDER BY order_key) AS next_order_key
|
||||
FROM quick_switcher_button_configs
|
||||
WHERE is_visible = :is_visible
|
||||
)
|
||||
SELECT lexo_rank_reorder_after(order_key, next_order_key)
|
||||
FROM ordered_table
|
||||
WHERE button_id = :button_id;
|
||||
|
||||
quickSwitcherOrderKeyBeforeButton(:button_id AS TEXT, :is_visible AS BOOL):
|
||||
WITH ordered_table AS (
|
||||
SELECT
|
||||
button_id,
|
||||
order_key,
|
||||
LAG(order_key) OVER (ORDER BY order_key) AS prev_order_key
|
||||
FROM quick_switcher_button_configs
|
||||
WHERE is_visible = :is_visible
|
||||
)
|
||||
SELECT lexo_rank_reorder_before(order_key, prev_order_key)
|
||||
FROM ordered_table
|
||||
WHERE button_id = :button_id;
|
||||
|
||||
evictCacheEntries:
|
||||
DELETE FROM icon_cache
|
||||
WHERE rowid IN (
|
||||
|
||||
@@ -1123,6 +1123,208 @@ typedef $ToolbarButtonConfigsProcessedTableManager =
|
||||
i1.ToolbarButtonConfig,
|
||||
i0.PrefetchHooks Function()
|
||||
>;
|
||||
typedef $QuickSwitcherButtonConfigsCreateCompanionBuilder =
|
||||
i1.QuickSwitcherButtonConfigsCompanion Function({
|
||||
required String buttonId,
|
||||
required String orderKey,
|
||||
i0.Value<bool> isVisible,
|
||||
i0.Value<String?> fallbackId,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
typedef $QuickSwitcherButtonConfigsUpdateCompanionBuilder =
|
||||
i1.QuickSwitcherButtonConfigsCompanion Function({
|
||||
i0.Value<String> buttonId,
|
||||
i0.Value<String> orderKey,
|
||||
i0.Value<bool> isVisible,
|
||||
i0.Value<String?> fallbackId,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
|
||||
class $QuickSwitcherButtonConfigsFilterComposer
|
||||
extends i0.Composer<i0.GeneratedDatabase, i1.QuickSwitcherButtonConfigs> {
|
||||
$QuickSwitcherButtonConfigsFilterComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
i0.ColumnFilters<String> get buttonId => $composableBuilder(
|
||||
column: $table.buttonId,
|
||||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
|
||||
i0.ColumnFilters<String> get orderKey => $composableBuilder(
|
||||
column: $table.orderKey,
|
||||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
|
||||
i0.ColumnFilters<bool> get isVisible => $composableBuilder(
|
||||
column: $table.isVisible,
|
||||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
|
||||
i0.ColumnFilters<String> get fallbackId => $composableBuilder(
|
||||
column: $table.fallbackId,
|
||||
builder: (column) => i0.ColumnFilters(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $QuickSwitcherButtonConfigsOrderingComposer
|
||||
extends i0.Composer<i0.GeneratedDatabase, i1.QuickSwitcherButtonConfigs> {
|
||||
$QuickSwitcherButtonConfigsOrderingComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
i0.ColumnOrderings<String> get buttonId => $composableBuilder(
|
||||
column: $table.buttonId,
|
||||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
|
||||
i0.ColumnOrderings<String> get orderKey => $composableBuilder(
|
||||
column: $table.orderKey,
|
||||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
|
||||
i0.ColumnOrderings<bool> get isVisible => $composableBuilder(
|
||||
column: $table.isVisible,
|
||||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
|
||||
i0.ColumnOrderings<String> get fallbackId => $composableBuilder(
|
||||
column: $table.fallbackId,
|
||||
builder: (column) => i0.ColumnOrderings(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $QuickSwitcherButtonConfigsAnnotationComposer
|
||||
extends i0.Composer<i0.GeneratedDatabase, i1.QuickSwitcherButtonConfigs> {
|
||||
$QuickSwitcherButtonConfigsAnnotationComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
i0.GeneratedColumn<String> get buttonId =>
|
||||
$composableBuilder(column: $table.buttonId, builder: (column) => column);
|
||||
|
||||
i0.GeneratedColumn<String> get orderKey =>
|
||||
$composableBuilder(column: $table.orderKey, builder: (column) => column);
|
||||
|
||||
i0.GeneratedColumn<bool> get isVisible =>
|
||||
$composableBuilder(column: $table.isVisible, builder: (column) => column);
|
||||
|
||||
i0.GeneratedColumn<String> get fallbackId => $composableBuilder(
|
||||
column: $table.fallbackId,
|
||||
builder: (column) => column,
|
||||
);
|
||||
}
|
||||
|
||||
class $QuickSwitcherButtonConfigsTableManager
|
||||
extends
|
||||
i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.QuickSwitcherButtonConfigs,
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i1.$QuickSwitcherButtonConfigsFilterComposer,
|
||||
i1.$QuickSwitcherButtonConfigsOrderingComposer,
|
||||
i1.$QuickSwitcherButtonConfigsAnnotationComposer,
|
||||
$QuickSwitcherButtonConfigsCreateCompanionBuilder,
|
||||
$QuickSwitcherButtonConfigsUpdateCompanionBuilder,
|
||||
(
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i0.BaseReferences<
|
||||
i0.GeneratedDatabase,
|
||||
i1.QuickSwitcherButtonConfigs,
|
||||
i1.QuickSwitcherButtonConfig
|
||||
>,
|
||||
),
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i0.PrefetchHooks Function()
|
||||
> {
|
||||
$QuickSwitcherButtonConfigsTableManager(
|
||||
i0.GeneratedDatabase db,
|
||||
i1.QuickSwitcherButtonConfigs table,
|
||||
) : super(
|
||||
i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
createFilteringComposer: () =>
|
||||
i1.$QuickSwitcherButtonConfigsFilterComposer(
|
||||
$db: db,
|
||||
$table: table,
|
||||
),
|
||||
createOrderingComposer: () =>
|
||||
i1.$QuickSwitcherButtonConfigsOrderingComposer(
|
||||
$db: db,
|
||||
$table: table,
|
||||
),
|
||||
createComputedFieldComposer: () =>
|
||||
i1.$QuickSwitcherButtonConfigsAnnotationComposer(
|
||||
$db: db,
|
||||
$table: table,
|
||||
),
|
||||
updateCompanionCallback:
|
||||
({
|
||||
i0.Value<String> buttonId = const i0.Value.absent(),
|
||||
i0.Value<String> orderKey = const i0.Value.absent(),
|
||||
i0.Value<bool> isVisible = const i0.Value.absent(),
|
||||
i0.Value<String?> fallbackId = const i0.Value.absent(),
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) => i1.QuickSwitcherButtonConfigsCompanion(
|
||||
buttonId: buttonId,
|
||||
orderKey: orderKey,
|
||||
isVisible: isVisible,
|
||||
fallbackId: fallbackId,
|
||||
rowid: rowid,
|
||||
),
|
||||
createCompanionCallback:
|
||||
({
|
||||
required String buttonId,
|
||||
required String orderKey,
|
||||
i0.Value<bool> isVisible = const i0.Value.absent(),
|
||||
i0.Value<String?> fallbackId = const i0.Value.absent(),
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) => i1.QuickSwitcherButtonConfigsCompanion.insert(
|
||||
buttonId: buttonId,
|
||||
orderKey: orderKey,
|
||||
isVisible: isVisible,
|
||||
fallbackId: fallbackId,
|
||||
rowid: rowid,
|
||||
),
|
||||
withReferenceMapper: (p0) => p0
|
||||
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
|
||||
.toList(),
|
||||
prefetchHooksCallback: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
typedef $QuickSwitcherButtonConfigsProcessedTableManager =
|
||||
i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.QuickSwitcherButtonConfigs,
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i1.$QuickSwitcherButtonConfigsFilterComposer,
|
||||
i1.$QuickSwitcherButtonConfigsOrderingComposer,
|
||||
i1.$QuickSwitcherButtonConfigsAnnotationComposer,
|
||||
$QuickSwitcherButtonConfigsCreateCompanionBuilder,
|
||||
$QuickSwitcherButtonConfigsUpdateCompanionBuilder,
|
||||
(
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i0.BaseReferences<
|
||||
i0.GeneratedDatabase,
|
||||
i1.QuickSwitcherButtonConfigs,
|
||||
i1.QuickSwitcherButtonConfig
|
||||
>,
|
||||
),
|
||||
i1.QuickSwitcherButtonConfig,
|
||||
i0.PrefetchHooks Function()
|
||||
>;
|
||||
typedef $SearchTokensCreateCompanionBuilder =
|
||||
i1.SearchTokensCompanion Function({
|
||||
i0.Value<int> id,
|
||||
@@ -2902,6 +3104,283 @@ i0.Index get idxToolbarOrderKey => i0.Index(
|
||||
'CREATE INDEX idx_toolbar_order_key ON toolbar_button_configs (order_key)',
|
||||
);
|
||||
|
||||
class QuickSwitcherButtonConfigs extends i0.Table
|
||||
with
|
||||
i0.TableInfo<QuickSwitcherButtonConfigs, i1.QuickSwitcherButtonConfig> {
|
||||
@override
|
||||
final i0.GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
QuickSwitcherButtonConfigs(this.attachedDatabase, [this._alias]);
|
||||
late final i0.GeneratedColumn<String> buttonId = i0.GeneratedColumn<String>(
|
||||
'button_id',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i0.DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
$customConstraints: 'NOT NULL PRIMARY KEY',
|
||||
);
|
||||
late final i0.GeneratedColumn<String> orderKey = i0.GeneratedColumn<String>(
|
||||
'order_key',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i0.DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
$customConstraints: 'NOT NULL',
|
||||
);
|
||||
late final i0.GeneratedColumn<bool> isVisible = i0.GeneratedColumn<bool>(
|
||||
'is_visible',
|
||||
aliasedName,
|
||||
false,
|
||||
type: i0.DriftSqlType.bool,
|
||||
requiredDuringInsert: false,
|
||||
$customConstraints: 'NOT NULL DEFAULT FALSE',
|
||||
defaultValue: const i0.CustomExpression('FALSE'),
|
||||
);
|
||||
late final i0.GeneratedColumn<String> fallbackId = i0.GeneratedColumn<String>(
|
||||
'fallback_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: i0.DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
$customConstraints:
|
||||
'REFERENCES quick_switcher_button_configs(button_id)ON DELETE SET NULL',
|
||||
);
|
||||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [
|
||||
buttonId,
|
||||
orderKey,
|
||||
isVisible,
|
||||
fallbackId,
|
||||
];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'quick_switcher_button_configs';
|
||||
@override
|
||||
Set<i0.GeneratedColumn> get $primaryKey => {buttonId};
|
||||
@override
|
||||
i1.QuickSwitcherButtonConfig map(
|
||||
Map<String, dynamic> data, {
|
||||
String? tablePrefix,
|
||||
}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return i1.QuickSwitcherButtonConfig(
|
||||
buttonId: attachedDatabase.typeMapping.read(
|
||||
i0.DriftSqlType.string,
|
||||
data['${effectivePrefix}button_id'],
|
||||
)!,
|
||||
orderKey: attachedDatabase.typeMapping.read(
|
||||
i0.DriftSqlType.string,
|
||||
data['${effectivePrefix}order_key'],
|
||||
)!,
|
||||
isVisible: attachedDatabase.typeMapping.read(
|
||||
i0.DriftSqlType.bool,
|
||||
data['${effectivePrefix}is_visible'],
|
||||
)!,
|
||||
fallbackId: attachedDatabase.typeMapping.read(
|
||||
i0.DriftSqlType.string,
|
||||
data['${effectivePrefix}fallback_id'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
QuickSwitcherButtonConfigs createAlias(String alias) {
|
||||
return QuickSwitcherButtonConfigs(attachedDatabase, alias);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get dontWriteConstraints => true;
|
||||
}
|
||||
|
||||
class QuickSwitcherButtonConfig extends i0.DataClass
|
||||
implements i0.Insertable<i1.QuickSwitcherButtonConfig> {
|
||||
final String buttonId;
|
||||
final String orderKey;
|
||||
final bool isVisible;
|
||||
final String? fallbackId;
|
||||
const QuickSwitcherButtonConfig({
|
||||
required this.buttonId,
|
||||
required this.orderKey,
|
||||
required this.isVisible,
|
||||
this.fallbackId,
|
||||
});
|
||||
@override
|
||||
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, i0.Expression>{};
|
||||
map['button_id'] = i0.Variable<String>(buttonId);
|
||||
map['order_key'] = i0.Variable<String>(orderKey);
|
||||
map['is_visible'] = i0.Variable<bool>(isVisible);
|
||||
if (!nullToAbsent || fallbackId != null) {
|
||||
map['fallback_id'] = i0.Variable<String>(fallbackId);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
factory QuickSwitcherButtonConfig.fromJson(
|
||||
Map<String, dynamic> json, {
|
||||
i0.ValueSerializer? serializer,
|
||||
}) {
|
||||
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
|
||||
return QuickSwitcherButtonConfig(
|
||||
buttonId: serializer.fromJson<String>(json['button_id']),
|
||||
orderKey: serializer.fromJson<String>(json['order_key']),
|
||||
isVisible: serializer.fromJson<bool>(json['is_visible']),
|
||||
fallbackId: serializer.fromJson<String?>(json['fallback_id']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({i0.ValueSerializer? serializer}) {
|
||||
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'button_id': serializer.toJson<String>(buttonId),
|
||||
'order_key': serializer.toJson<String>(orderKey),
|
||||
'is_visible': serializer.toJson<bool>(isVisible),
|
||||
'fallback_id': serializer.toJson<String?>(fallbackId),
|
||||
};
|
||||
}
|
||||
|
||||
i1.QuickSwitcherButtonConfig copyWith({
|
||||
String? buttonId,
|
||||
String? orderKey,
|
||||
bool? isVisible,
|
||||
i0.Value<String?> fallbackId = const i0.Value.absent(),
|
||||
}) => i1.QuickSwitcherButtonConfig(
|
||||
buttonId: buttonId ?? this.buttonId,
|
||||
orderKey: orderKey ?? this.orderKey,
|
||||
isVisible: isVisible ?? this.isVisible,
|
||||
fallbackId: fallbackId.present ? fallbackId.value : this.fallbackId,
|
||||
);
|
||||
QuickSwitcherButtonConfig copyWithCompanion(
|
||||
i1.QuickSwitcherButtonConfigsCompanion data,
|
||||
) {
|
||||
return QuickSwitcherButtonConfig(
|
||||
buttonId: data.buttonId.present ? data.buttonId.value : this.buttonId,
|
||||
orderKey: data.orderKey.present ? data.orderKey.value : this.orderKey,
|
||||
isVisible: data.isVisible.present ? data.isVisible.value : this.isVisible,
|
||||
fallbackId: data.fallbackId.present
|
||||
? data.fallbackId.value
|
||||
: this.fallbackId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('QuickSwitcherButtonConfig(')
|
||||
..write('buttonId: $buttonId, ')
|
||||
..write('orderKey: $orderKey, ')
|
||||
..write('isVisible: $isVisible, ')
|
||||
..write('fallbackId: $fallbackId')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(buttonId, orderKey, isVisible, fallbackId);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is i1.QuickSwitcherButtonConfig &&
|
||||
other.buttonId == this.buttonId &&
|
||||
other.orderKey == this.orderKey &&
|
||||
other.isVisible == this.isVisible &&
|
||||
other.fallbackId == this.fallbackId);
|
||||
}
|
||||
|
||||
class QuickSwitcherButtonConfigsCompanion
|
||||
extends i0.UpdateCompanion<i1.QuickSwitcherButtonConfig> {
|
||||
final i0.Value<String> buttonId;
|
||||
final i0.Value<String> orderKey;
|
||||
final i0.Value<bool> isVisible;
|
||||
final i0.Value<String?> fallbackId;
|
||||
final i0.Value<int> rowid;
|
||||
const QuickSwitcherButtonConfigsCompanion({
|
||||
this.buttonId = const i0.Value.absent(),
|
||||
this.orderKey = const i0.Value.absent(),
|
||||
this.isVisible = const i0.Value.absent(),
|
||||
this.fallbackId = const i0.Value.absent(),
|
||||
this.rowid = const i0.Value.absent(),
|
||||
});
|
||||
QuickSwitcherButtonConfigsCompanion.insert({
|
||||
required String buttonId,
|
||||
required String orderKey,
|
||||
this.isVisible = const i0.Value.absent(),
|
||||
this.fallbackId = const i0.Value.absent(),
|
||||
this.rowid = const i0.Value.absent(),
|
||||
}) : buttonId = i0.Value(buttonId),
|
||||
orderKey = i0.Value(orderKey);
|
||||
static i0.Insertable<i1.QuickSwitcherButtonConfig> custom({
|
||||
i0.Expression<String>? buttonId,
|
||||
i0.Expression<String>? orderKey,
|
||||
i0.Expression<bool>? isVisible,
|
||||
i0.Expression<String>? fallbackId,
|
||||
i0.Expression<int>? rowid,
|
||||
}) {
|
||||
return i0.RawValuesInsertable({
|
||||
if (buttonId != null) 'button_id': buttonId,
|
||||
if (orderKey != null) 'order_key': orderKey,
|
||||
if (isVisible != null) 'is_visible': isVisible,
|
||||
if (fallbackId != null) 'fallback_id': fallbackId,
|
||||
if (rowid != null) 'rowid': rowid,
|
||||
});
|
||||
}
|
||||
|
||||
i1.QuickSwitcherButtonConfigsCompanion copyWith({
|
||||
i0.Value<String>? buttonId,
|
||||
i0.Value<String>? orderKey,
|
||||
i0.Value<bool>? isVisible,
|
||||
i0.Value<String?>? fallbackId,
|
||||
i0.Value<int>? rowid,
|
||||
}) {
|
||||
return i1.QuickSwitcherButtonConfigsCompanion(
|
||||
buttonId: buttonId ?? this.buttonId,
|
||||
orderKey: orderKey ?? this.orderKey,
|
||||
isVisible: isVisible ?? this.isVisible,
|
||||
fallbackId: fallbackId ?? this.fallbackId,
|
||||
rowid: rowid ?? this.rowid,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, i0.Expression>{};
|
||||
if (buttonId.present) {
|
||||
map['button_id'] = i0.Variable<String>(buttonId.value);
|
||||
}
|
||||
if (orderKey.present) {
|
||||
map['order_key'] = i0.Variable<String>(orderKey.value);
|
||||
}
|
||||
if (isVisible.present) {
|
||||
map['is_visible'] = i0.Variable<bool>(isVisible.value);
|
||||
}
|
||||
if (fallbackId.present) {
|
||||
map['fallback_id'] = i0.Variable<String>(fallbackId.value);
|
||||
}
|
||||
if (rowid.present) {
|
||||
map['rowid'] = i0.Variable<int>(rowid.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('QuickSwitcherButtonConfigsCompanion(')
|
||||
..write('buttonId: $buttonId, ')
|
||||
..write('orderKey: $orderKey, ')
|
||||
..write('isVisible: $isVisible, ')
|
||||
..write('fallbackId: $fallbackId, ')
|
||||
..write('rowid: $rowid')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
i0.Index get idxQuickSwitcherOrderKey => i0.Index(
|
||||
'idx_quick_switcher_order_key',
|
||||
'CREATE INDEX idx_quick_switcher_order_key ON quick_switcher_button_configs (order_key)',
|
||||
);
|
||||
|
||||
class SearchTokens extends i0.Table
|
||||
with i0.TableInfo<SearchTokens, i1.SearchToken> {
|
||||
@override
|
||||
@@ -3259,6 +3738,50 @@ class DefinitionsDrift extends i4.ModularAccessor {
|
||||
).map((i0.QueryRow row) => row.read<String>('_c0'));
|
||||
}
|
||||
|
||||
i0.Selectable<String> quickSwitcherLeadingOrderKey({
|
||||
required int bucket,
|
||||
required bool isVisible,
|
||||
}) {
|
||||
return customSelect(
|
||||
'SELECT lexo_rank_previous(?1, (SELECT order_key FROM quick_switcher_button_configs WHERE is_visible = ?2 ORDER BY order_key LIMIT 1)) AS _c0',
|
||||
variables: [i0.Variable<int>(bucket), i0.Variable<bool>(isVisible)],
|
||||
readsFrom: {quickSwitcherButtonConfigs},
|
||||
).map((i0.QueryRow row) => row.read<String>('_c0'));
|
||||
}
|
||||
|
||||
i0.Selectable<String> quickSwitcherTrailingOrderKey({
|
||||
required int bucket,
|
||||
required bool isVisible,
|
||||
}) {
|
||||
return customSelect(
|
||||
'SELECT lexo_rank_next(?1, (SELECT order_key FROM quick_switcher_button_configs WHERE is_visible = ?2 ORDER BY order_key DESC LIMIT 1)) AS _c0',
|
||||
variables: [i0.Variable<int>(bucket), i0.Variable<bool>(isVisible)],
|
||||
readsFrom: {quickSwitcherButtonConfigs},
|
||||
).map((i0.QueryRow row) => row.read<String>('_c0'));
|
||||
}
|
||||
|
||||
i0.Selectable<String> quickSwitcherOrderKeyAfterButton({
|
||||
required bool isVisible,
|
||||
required String buttonId,
|
||||
}) {
|
||||
return customSelect(
|
||||
'WITH ordered_table AS (SELECT button_id, order_key, LEAD(order_key)OVER (ORDER BY order_key RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS next_order_key FROM quick_switcher_button_configs WHERE is_visible = ?1) SELECT lexo_rank_reorder_after(order_key, next_order_key) AS _c0 FROM ordered_table WHERE button_id = ?2',
|
||||
variables: [i0.Variable<bool>(isVisible), i0.Variable<String>(buttonId)],
|
||||
readsFrom: {quickSwitcherButtonConfigs},
|
||||
).map((i0.QueryRow row) => row.read<String>('_c0'));
|
||||
}
|
||||
|
||||
i0.Selectable<String> quickSwitcherOrderKeyBeforeButton({
|
||||
required bool isVisible,
|
||||
required String buttonId,
|
||||
}) {
|
||||
return customSelect(
|
||||
'WITH ordered_table AS (SELECT button_id, order_key, LAG(order_key)OVER (ORDER BY order_key RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS prev_order_key FROM quick_switcher_button_configs WHERE is_visible = ?1) SELECT lexo_rank_reorder_before(order_key, prev_order_key) AS _c0 FROM ordered_table WHERE button_id = ?2',
|
||||
variables: [i0.Variable<bool>(isVisible), i0.Variable<String>(buttonId)],
|
||||
readsFrom: {quickSwitcherButtonConfigs},
|
||||
).map((i0.QueryRow row) => row.read<String>('_c0'));
|
||||
}
|
||||
|
||||
Future<int> evictCacheEntries({required int limit}) {
|
||||
return customUpdate(
|
||||
'DELETE FROM icon_cache WHERE "rowid" IN (SELECT "rowid" FROM icon_cache ORDER BY fetch_date DESC LIMIT -1 OFFSET ?1)',
|
||||
@@ -3271,6 +3794,12 @@ class DefinitionsDrift extends i4.ModularAccessor {
|
||||
i1.ToolbarButtonConfigs get toolbarButtonConfigs => i4.ReadDatabaseContainer(
|
||||
attachedDatabase,
|
||||
).resultSet<i1.ToolbarButtonConfigs>('toolbar_button_configs');
|
||||
i1.QuickSwitcherButtonConfigs get quickSwitcherButtonConfigs =>
|
||||
i4.ReadDatabaseContainer(
|
||||
attachedDatabase,
|
||||
).resultSet<i1.QuickSwitcherButtonConfigs>(
|
||||
'quick_switcher_button_configs',
|
||||
);
|
||||
i1.IconCache get iconCache => i4.ReadDatabaseContainer(
|
||||
attachedDatabase,
|
||||
).resultSet<i1.IconCache>('icon_cache');
|
||||
|
||||
Reference in New Issue
Block a user