From dfab32c8f21606d301a33f07ff4264ece053d846 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Fri, 4 Apr 2025 09:05:50 +0530 Subject: [PATCH] fix(mobile): ignore invalid store keys (#17370) Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- .../repositories/store.repository.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mobile/lib/infrastructure/repositories/store.repository.dart b/mobile/lib/infrastructure/repositories/store.repository.dart index 86dfaf4452..e8769c5084 100644 --- a/mobile/lib/infrastructure/repositories/store.repository.dart +++ b/mobile/lib/infrastructure/repositories/store.repository.dart @@ -9,7 +9,9 @@ import 'package:isar/isar.dart'; class IsarStoreRepository extends IsarDatabaseRepository implements IStoreRepository { final Isar _db; - const IsarStoreRepository(super.db) : _db = db; + final validStoreKeys = StoreKey.values.map((e) => e.id).toSet(); + + IsarStoreRepository(super.db) : _db = db; @override Future deleteAll() async { @@ -21,9 +23,14 @@ class IsarStoreRepository extends IsarDatabaseRepository @override Stream watchAll() { - return _db.storeValues.where().watch(fireImmediately: true).asyncExpand( - (entities) => - Stream.fromFutures(entities.map((e) async => _toUpdateEvent(e))), + return _db.storeValues + .filter() + .anyOf(validStoreKeys, (query, id) => query.idEqualTo(id)) + .watch(fireImmediately: true) + .asyncExpand( + (entities) => Stream.fromFutures( + entities.map((e) async => _toUpdateEvent(e)), + ), ); }