Add Supa account and search changes

This commit is contained in:
Fabian Freund
2026-05-22 18:10:22 +02:00
parent 3a19865b2e
commit 51289f1266
374 changed files with 54061 additions and 5013 deletions
@@ -17,6 +17,8 @@
* 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 'dart:typed_data';
import 'package:exceptions/exceptions.dart';
import 'package:nullability/nullability.dart';
import 'package:riverpod/riverpod.dart';
@@ -27,6 +29,7 @@ import 'package:weblibre/domain/entities/profile.dart';
import 'package:weblibre/features/user/data/providers.dart';
import 'package:weblibre/features/user/domain/entities/fingerprint_overrides.dart';
import 'package:weblibre/features/user/domain/providers/backup_directory.dart';
import 'package:weblibre/features/user/domain/repositories/cache.dart';
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
import 'package:weblibre/features/user/domain/repositories/profile.dart';
@@ -41,6 +44,11 @@ Stream<double> iconCacheSizeMegabytes(Ref ref) {
return repository.cacheDao.getIconCacheSize().watchSingle();
}
@Riverpod()
Stream<Uint8List?> watchCachedIconBytes(Ref ref, String origin) {
return ref.watch(cacheRepositoryProvider.notifier).watchCachedIcon(origin);
}
@Riverpod()
bool incognitoModeEnabled(Ref ref) {
return ref.watch(
@@ -43,6 +43,81 @@ final class IconCacheSizeMegabytesProvider
String _$iconCacheSizeMegabytesHash() =>
r'5d7f5f6485060b08ce4fd8fa634f07bf8bfdbd2d';
@ProviderFor(watchCachedIconBytes)
final watchCachedIconBytesProvider = WatchCachedIconBytesFamily._();
final class WatchCachedIconBytesProvider
extends
$FunctionalProvider<
AsyncValue<Uint8List?>,
Uint8List?,
Stream<Uint8List?>
>
with $FutureModifier<Uint8List?>, $StreamProvider<Uint8List?> {
WatchCachedIconBytesProvider._({
required WatchCachedIconBytesFamily super.from,
required String super.argument,
}) : super(
retry: null,
name: r'watchCachedIconBytesProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$watchCachedIconBytesHash();
@override
String toString() {
return r'watchCachedIconBytesProvider'
''
'($argument)';
}
@$internal
@override
$StreamProviderElement<Uint8List?> $createElement($ProviderPointer pointer) =>
$StreamProviderElement(pointer);
@override
Stream<Uint8List?> create(Ref ref) {
final argument = this.argument as String;
return watchCachedIconBytes(ref, argument);
}
@override
bool operator ==(Object other) {
return other is WatchCachedIconBytesProvider && other.argument == argument;
}
@override
int get hashCode {
return argument.hashCode;
}
}
String _$watchCachedIconBytesHash() =>
r'65881670bd19f2d55e05e68118e1e23b28871c13';
final class WatchCachedIconBytesFamily extends $Family
with $FunctionalFamilyOverride<Stream<Uint8List?>, String> {
WatchCachedIconBytesFamily._()
: super(
retry: null,
name: r'watchCachedIconBytesProvider',
dependencies: null,
$allTransitiveDependencies: null,
isAutoDispose: true,
);
WatchCachedIconBytesProvider call(String origin) =>
WatchCachedIconBytesProvider._(argument: origin, from: this);
@override
String toString() => r'watchCachedIconBytesProvider';
}
@ProviderFor(incognitoModeEnabled)
final incognitoModeEnabledProvider = IncognitoModeEnabledProvider._();
@@ -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> {