diff --git a/mobile/lib/modules/album/providers/album.provider.dart b/mobile/lib/modules/album/providers/album.provider.dart index 5618ea91d4..2522e97bcc 100644 --- a/mobile/lib/modules/album/providers/album.provider.dart +++ b/mobile/lib/modules/album/providers/album.provider.dart @@ -16,7 +16,11 @@ class AlbumNotifier extends StateNotifier> { final query = db.albums .filter() .owner((q) => q.isarIdEqualTo(Store.get(StoreKey.currentUser).isarId)); - query.findAll().then((value) => state = value); + query.findAll().then((value) { + if (mounted) { + state = value; + } + }); _streamSub = query.watch().listen((data) => state = data); } final AlbumService _albumService; diff --git a/mobile/lib/modules/album/providers/shared_album.provider.dart b/mobile/lib/modules/album/providers/shared_album.provider.dart index b864e855fb..83eed53010 100644 --- a/mobile/lib/modules/album/providers/shared_album.provider.dart +++ b/mobile/lib/modules/album/providers/shared_album.provider.dart @@ -12,7 +12,11 @@ import 'package:isar/isar.dart'; class SharedAlbumNotifier extends StateNotifier> { SharedAlbumNotifier(this._albumService, Isar db) : super([]) { final query = db.albums.filter().sharedEqualTo(true).sortByCreatedAtDesc(); - query.findAll().then((value) => state = value); + query.findAll().then((value) { + if (mounted) { + state = value; + } + }); _streamSub = query.watch().listen((data) => state = data); }