Add Supa account and search changes
This commit is contained in:
@@ -99,11 +99,17 @@ class BangDataRepository extends _$BangDataRepository {
|
||||
}
|
||||
|
||||
Stream<List<SearchHistoryEntry>> watchSearchHistory({required int limit}) {
|
||||
return ref
|
||||
final query = ref
|
||||
.read(bangDatabaseProvider)
|
||||
.definitionsDrift
|
||||
.searchHistoryEntries(limit: limit)
|
||||
.watch();
|
||||
.searchHistoryEntries(limit: limit);
|
||||
|
||||
return () async* {
|
||||
// Emit a direct read first so Recent Searches is populated immediately
|
||||
// on app start instead of waiting for the next bang_history write.
|
||||
yield await query.get();
|
||||
yield* query.watch();
|
||||
}();
|
||||
}
|
||||
|
||||
Future<void> increaseFrequency(BangKey key) {
|
||||
|
||||
@@ -42,7 +42,7 @@ final class BangDataRepositoryProvider
|
||||
}
|
||||
|
||||
String _$bangDataRepositoryHash() =>
|
||||
r'c562ef10d75ca6dee13805f84d2491cf2a89aaac';
|
||||
r'c8e2b17214117a8d88b5246bdcc565bc15e8e4ac';
|
||||
|
||||
abstract class _$BangDataRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
@@ -21,6 +21,7 @@ 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';
|
||||
|
||||
@@ -170,6 +171,21 @@ 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 {
|
||||
@@ -183,7 +199,10 @@ class BangSyncRepository extends _$BangSyncRepository {
|
||||
).then((result) => MapEntry(source, result)),
|
||||
);
|
||||
|
||||
return Map.fromEntries(await Future.wait(futures));
|
||||
return {
|
||||
...Map.fromEntries(await Future.wait(futures)),
|
||||
BangGroup.weblibre: await _syncSyntheticBangs(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -42,7 +42,7 @@ final class BangSyncRepositoryProvider
|
||||
}
|
||||
|
||||
String _$bangSyncRepositoryHash() =>
|
||||
r'1347dcbd03f6a1a4fa3bbbae5d9302098d260c50';
|
||||
r'cdb78ef0243224fdb7b3a8660f0920c471987296';
|
||||
|
||||
abstract class _$BangSyncRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
Reference in New Issue
Block a user