Source Code added
This commit is contained in:
parent
800376eafd
commit
9efa9bc6dd
3912 changed files with 754770 additions and 2 deletions
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||
|
||||
final currentRemoteAlbumScopedProvider = Provider<RemoteAlbum?>((ref) => null);
|
||||
final currentRemoteAlbumProvider = NotifierProvider<CurrentAlbumNotifier, RemoteAlbum?>(
|
||||
CurrentAlbumNotifier.new,
|
||||
dependencies: [currentRemoteAlbumScopedProvider, remoteAlbumServiceProvider],
|
||||
);
|
||||
|
||||
class CurrentAlbumNotifier extends Notifier<RemoteAlbum?> {
|
||||
@override
|
||||
RemoteAlbum? build() {
|
||||
final album = ref.watch(currentRemoteAlbumScopedProvider);
|
||||
|
||||
if (album == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final watcher = ref.watch(remoteAlbumServiceProvider).watchAlbum(album.id).listen((updatedAlbum) {
|
||||
if (updatedAlbum != null) {
|
||||
state = updatedAlbum;
|
||||
}
|
||||
});
|
||||
|
||||
ref.onDispose(watcher.cancel);
|
||||
|
||||
return album;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue