Add Supa account and search changes
This commit is contained in:
@@ -22,6 +22,7 @@ import 'dart:typed_data';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/core/logger.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/providers.dart';
|
||||
import 'package:weblibre/features/user/data/icon_cache_marker.dart';
|
||||
import 'package:weblibre/features/user/data/providers.dart';
|
||||
|
||||
part 'cache.g.dart';
|
||||
@@ -36,7 +37,26 @@ class CacheRepository extends _$CacheRepository {
|
||||
return ref.read(userDatabaseProvider).cacheDao.cacheIcon(url.origin, bytes);
|
||||
}
|
||||
|
||||
Future<Uint8List?> getCachedIcon(String origin) {
|
||||
Future<void> cacheIconIfAbsent(Uri url, Uint8List bytes) {
|
||||
return ref
|
||||
.read(userDatabaseProvider)
|
||||
.cacheDao
|
||||
.cacheIconIfAbsent(url.origin, bytes);
|
||||
}
|
||||
|
||||
Future<void> cacheMissingIcon(Uri url) {
|
||||
return ref.read(userDatabaseProvider).cacheDao.cacheMissingIcon(url.origin);
|
||||
}
|
||||
|
||||
Future<Uint8List?> getCachedIcon(String origin) async {
|
||||
final bytes = await getCachedIconRaw(origin);
|
||||
if (isMissingIconMarker(bytes)) {
|
||||
return null;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Future<Uint8List?> getCachedIconRaw(String origin) {
|
||||
return ref
|
||||
.read(userDatabaseProvider)
|
||||
.cacheDao
|
||||
@@ -44,6 +64,27 @@ class CacheRepository extends _$CacheRepository {
|
||||
.getSingleOrNull();
|
||||
}
|
||||
|
||||
Stream<Uint8List?> watchCachedIcon(String origin) {
|
||||
return ref
|
||||
.read(userDatabaseProvider)
|
||||
.cacheDao
|
||||
.getCachedIcon(origin)
|
||||
.watchSingleOrNull()
|
||||
.map((bytes) => isMissingIconMarker(bytes) ? null : bytes);
|
||||
}
|
||||
|
||||
bool isMissingIconBytes(Uint8List? bytes) {
|
||||
return isMissingIconMarker(bytes);
|
||||
}
|
||||
|
||||
Future<DateTime?> getCachedIconFetchDate(String origin) {
|
||||
return ref
|
||||
.read(userDatabaseProvider)
|
||||
.cacheDao
|
||||
.getCachedIconFetchDate(origin)
|
||||
.getSingleOrNull();
|
||||
}
|
||||
|
||||
@override
|
||||
void build() {
|
||||
final eventService = ref.watch(eventServiceProvider);
|
||||
|
||||
@@ -41,7 +41,7 @@ final class CacheRepositoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$cacheRepositoryHash() => r'e3cd7461aefe9e034a663169cd81ab7f69c2640e';
|
||||
String _$cacheRepositoryHash() => r'60caff8364a3996502a6309925903190db71cd8f';
|
||||
|
||||
abstract class _$CacheRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
@@ -248,6 +248,18 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
||||
'externalAppIntentPolicies': settings['externalAppIntentPolicies']
|
||||
?.readAs(DriftSqlType.string, db.typeMapping)
|
||||
.mapNotNull(jsonDecode),
|
||||
'enableLocalSearchIndex': settings['enableLocalSearchIndex']?.readAs(
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
'indexPrivateTabs': settings['indexPrivateTabs']?.readAs(
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
'acceptSuggestionOnSubmit': settings['acceptSuggestionOnSubmit']?.readAs(
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ final class GeneralSettingsRepositoryProvider
|
||||
}
|
||||
|
||||
String _$generalSettingsRepositoryHash() =>
|
||||
r'5fe717f8bccad163fa0cb8ec3294c4b00847e141';
|
||||
r'b269ac847d1ae1547bdfe0b926d8d4ffc5ec8f7a';
|
||||
|
||||
abstract class _$GeneralSettingsRepository
|
||||
extends $StreamNotifier<GeneralSettings> {
|
||||
|
||||
Reference in New Issue
Block a user