added list view; persist tab view ui settings;

This commit is contained in:
Fabian Freund
2025-12-27 21:09:45 +01:00
parent 27e8dfd38e
commit e7ef8e060e
35 changed files with 2194 additions and 1227 deletions
@@ -65,6 +65,18 @@ class TabDao extends DatabaseAccessor<TabDatabase> with $TabDaoMixin {
return query.map((row) => row.read(db.tab.containerId));
}
Selectable<MapEntry<String, String?>> getTabsContainerId(
Iterable<String> tabIds,
) {
final query = selectOnly(db.tab)
..addColumns([db.tab.id, db.tab.containerId])
..where(db.tab.id.isIn(tabIds));
return query.map(
(row) => MapEntry(row.read(db.tab.id)!, row.read(db.tab.containerId)),
);
}
Future<String> _generateOrderKey({
required Value<String?> parentId,
required Value<String?> containerId,
@@ -140,6 +140,7 @@ queryTabsBasic WITH TabQueryResult:
)
SELECT
t.id,
t.container_id,
t.title,
CAST(t.url AS TEXT) AS url,
t.url AS clean_url,
@@ -166,6 +167,7 @@ queryTabsFullContent WITH TabQueryResult:
)
SELECT
t.id,
t.container_id,
highlight(tab_fts, 0, :beforeMatch, :afterMatch) AS title,
highlight(tab_fts, 1, :beforeMatch, :afterMatch) AS url,
snippet(tab_fts, 2, :beforeMatch, :afterMatch, :ellipsis, :snippetLength) AS extracted_content,
@@ -2161,12 +2161,13 @@ class DefinitionsDrift extends i7.ModularAccessor {
i0.Selectable<i8.TabQueryResult> queryTabsBasic({required String query}) {
return customSelect(
'WITH weights AS (SELECT 10.0 AS title_weight, 5.0 AS url_weight) SELECT t.id, t.title, CAST(t.url AS TEXT) AS url, t.url AS clean_url, bm25(tab_fts, weights.title_weight, weights.url_weight) AS weighted_rank FROM tab_fts AS fts INNER JOIN tab AS t ON t."rowid" = fts."rowid" CROSS JOIN weights WHERE fts.title LIKE ?1 OR fts.url LIKE ?1 ORDER BY weighted_rank ASC, t.timestamp DESC',
'WITH weights AS (SELECT 10.0 AS title_weight, 5.0 AS url_weight) SELECT t.id, t.container_id, t.title, CAST(t.url AS TEXT) AS url, t.url AS clean_url, bm25(tab_fts, weights.title_weight, weights.url_weight) AS weighted_rank FROM tab_fts AS fts INNER JOIN tab AS t ON t."rowid" = fts."rowid" CROSS JOIN weights WHERE fts.title LIKE ?1 OR fts.url LIKE ?1 ORDER BY weighted_rank ASC, t.timestamp DESC',
variables: [i0.Variable<String>(query)],
readsFrom: {tab, tabFts},
).map(
(i0.QueryRow row) => i8.TabQueryResult(
id: row.read<String>('id'),
containerId: row.readNullable<String>('container_id'),
title: row.readNullable<String>('title'),
url: row.readNullable<String>('url'),
cleanUrl: i3.Tab.$converterurl.fromSql(
@@ -2185,7 +2186,7 @@ class DefinitionsDrift extends i7.ModularAccessor {
required String query,
}) {
return customSelect(
'WITH weights AS (SELECT 10.0 AS title_weight, 5.0 AS url_weight, 3.0 AS extracted_weight, 1.0 AS full_weight) SELECT t.id, highlight(tab_fts, 0, ?1, ?2) AS title, highlight(tab_fts, 1, ?1, ?2) AS url, snippet(tab_fts, 2, ?1, ?2, ?3, ?4) AS extracted_content, snippet(tab_fts, 3, ?1, ?2, ?3, ?4) AS full_content, t.url AS clean_url,(bm25(tab_fts, weights.title_weight, weights.url_weight, weights.extracted_weight, weights.full_weight))AS weighted_rank FROM tab_fts(?5)AS fts INNER JOIN tab AS t ON t."rowid" = fts."rowid" CROSS JOIN weights ORDER BY weighted_rank ASC, t.timestamp DESC',
'WITH weights AS (SELECT 10.0 AS title_weight, 5.0 AS url_weight, 3.0 AS extracted_weight, 1.0 AS full_weight) SELECT t.id, t.container_id, highlight(tab_fts, 0, ?1, ?2) AS title, highlight(tab_fts, 1, ?1, ?2) AS url, snippet(tab_fts, 2, ?1, ?2, ?3, ?4) AS extracted_content, snippet(tab_fts, 3, ?1, ?2, ?3, ?4) AS full_content, t.url AS clean_url,(bm25(tab_fts, weights.title_weight, weights.url_weight, weights.extracted_weight, weights.full_weight))AS weighted_rank FROM tab_fts(?5)AS fts INNER JOIN tab AS t ON t."rowid" = fts."rowid" CROSS JOIN weights ORDER BY weighted_rank ASC, t.timestamp DESC',
variables: [
i0.Variable<String>(beforeMatch),
i0.Variable<String>(afterMatch),
@@ -2197,6 +2198,7 @@ class DefinitionsDrift extends i7.ModularAccessor {
).map(
(i0.QueryRow row) => i8.TabQueryResult(
id: row.read<String>('id'),
containerId: row.readNullable<String>('container_id'),
title: row.readNullable<String>('title'),
url: row.readNullable<String>('url'),
cleanUrl: i3.Tab.$converterurl.fromSql(
@@ -26,23 +26,29 @@ sealed class TabEntity with FastEquatable {
class DefaultTabEntity extends TabEntity {
@override
final String tabId;
final String? containerId;
DefaultTabEntity({required this.tabId});
DefaultTabEntity({required this.tabId, required this.containerId});
@override
List<Object?> get hashParameters => [tabId];
List<Object?> get hashParameters => [tabId, containerId];
}
class SearchResultTabEntity extends TabEntity {
@override
final String tabId;
final String? containerId;
final String searchQuery;
SearchResultTabEntity({required this.tabId, required this.searchQuery});
SearchResultTabEntity({
required this.tabId,
required this.searchQuery,
required this.containerId,
});
@override
List<Object?> get hashParameters => [tabId, searchQuery];
List<Object?> get hashParameters => [tabId, searchQuery, containerId];
}
class TabTreeEntity extends TabEntity {
@@ -21,6 +21,7 @@ import 'package:fast_equatable/fast_equatable.dart';
class TabQueryResult with FastEquatable {
final String id;
final String? containerId;
final String? title;
final Uri? cleanUrl;
@@ -33,6 +34,7 @@ class TabQueryResult with FastEquatable {
TabQueryResult({
required this.id,
required this.containerId,
required this.title,
required this.url,
required this.cleanUrl,
@@ -44,6 +46,7 @@ class TabQueryResult with FastEquatable {
@override
List<Object?> get hashParameters => [
id,
containerId,
title,
cleanUrl,
url,