mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
fix(mobile): ensure notifier is mounted before updating state (#6308)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
902977f165
commit
0e0a472de1
@ -16,7 +16,11 @@ class AlbumNotifier extends StateNotifier<List<Album>> {
|
|||||||
final query = db.albums
|
final query = db.albums
|
||||||
.filter()
|
.filter()
|
||||||
.owner((q) => q.isarIdEqualTo(Store.get(StoreKey.currentUser).isarId));
|
.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);
|
_streamSub = query.watch().listen((data) => state = data);
|
||||||
}
|
}
|
||||||
final AlbumService _albumService;
|
final AlbumService _albumService;
|
||||||
|
@ -12,7 +12,11 @@ import 'package:isar/isar.dart';
|
|||||||
class SharedAlbumNotifier extends StateNotifier<List<Album>> {
|
class SharedAlbumNotifier extends StateNotifier<List<Album>> {
|
||||||
SharedAlbumNotifier(this._albumService, Isar db) : super([]) {
|
SharedAlbumNotifier(this._albumService, Isar db) : super([]) {
|
||||||
final query = db.albums.filter().sharedEqualTo(true).sortByCreatedAtDesc();
|
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);
|
_streamSub = query.watch().listen((data) => state = data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user