improve weblibre search

This commit is contained in:
Fabian Freund
2026-06-01 07:17:37 +02:00
parent 88f128621f
commit 453e1a6c30
23 changed files with 1095 additions and 796 deletions
@@ -21,7 +21,6 @@ import 'package:exceptions/exceptions.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:weblibre/features/bangs/data/database/database.dart';
import 'package:weblibre/features/bangs/data/models/bang_group.dart';
import 'package:weblibre/features/bangs/data/models/web_search_bang.dart';
import 'package:weblibre/features/bangs/data/providers.dart';
import 'package:weblibre/features/bangs/data/services/data_source.dart';
@@ -70,12 +69,6 @@ class BangSyncRepository extends _$BangSyncRepository {
);
}
if (group.remote == null) {
return Result.failure(
const ErrorMessage(source: 'BangSync', message: 'No remote source'),
);
}
final lastSync = await db.syncDao
.getLastSyncOfGroup(group)
.getSingleOrNull();
@@ -171,21 +164,6 @@ class BangSyncRepository extends _$BangSyncRepository {
.watchSingleOrNull();
}
Future<Result<void>> _syncSyntheticBangs() async {
try {
await ref.read(bangDatabaseProvider).bangDao.upsertBang(webSearchBang);
return Result.success(null);
} catch (e) {
return Result.failure(
ErrorMessage(
message: 'Failed to sync synthetic Bangs',
source: 'BangSync',
details: e,
),
);
}
}
Future<Map<BangGroup, Result<void>>> syncBundledBangGroups({
Set<BangGroup>? groups,
}) async {
@@ -199,10 +177,7 @@ class BangSyncRepository extends _$BangSyncRepository {
).then((result) => MapEntry(source, result)),
);
return {
...Map.fromEntries(await Future.wait(futures)),
BangGroup.weblibre: await _syncSyntheticBangs(),
};
return Map.fromEntries(await Future.wait(futures));
}
@override
@@ -42,7 +42,7 @@ final class BangSyncRepositoryProvider
}
String _$bangSyncRepositoryHash() =>
r'cdb78ef0243224fdb7b3a8660f0920c471987296';
r'd1c6709f099165c17db535ab03334fcd1c610492';
abstract class _$BangSyncRepository extends $Notifier<void> {
void build();