fix(mobile): ignore invalid store keys (#17370)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2025-04-04 09:05:50 +05:30 committed by GitHub
parent 60174d662d
commit dfab32c8f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<bool> deleteAll() async {
@ -21,9 +23,14 @@ class IsarStoreRepository extends IsarDatabaseRepository
@override
Stream<StoreUpdateEvent> 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)),
),
);
}