import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/modules/sharing/models/shared_album.model.dart'; import 'package:immich_mobile/modules/sharing/services/shared_album.service.dart'; class SharedAlbumNotifier extends StateNotifier> { SharedAlbumNotifier() : super([]); final SharedAlbumService _sharedAlbumService = SharedAlbumService(); getAllSharedAlbums() async { List sharedAlbums = await _sharedAlbumService.getAllSharedAlbum(); state = sharedAlbums; } Future deleteAlbum(String albumId) async { var res = await _sharedAlbumService.deleteAlbum(albumId); if (res) { state = state.where((album) => album.id != albumId).toList(); return true; } else { return false; } } Future leaveAlbum(String albumId) async { var res = await _sharedAlbumService.leaveAlbum(albumId); if (res) { state = state.where((album) => album.id != albumId).toList(); return true; } else { return false; } } Future removeAssetFromAlbum(String albumId, List assetIds) async { var res = await _sharedAlbumService.removeAssetFromAlbum(albumId, assetIds); if (res) { return true; } else { return false; } } } final sharedAlbumProvider = StateNotifierProvider>((ref) { return SharedAlbumNotifier(); }); final sharedAlbumDetailProvider = FutureProvider.autoDispose.family((ref, albumId) async { final SharedAlbumService _sharedAlbumService = SharedAlbumService(); return await _sharedAlbumService.getAlbumDetail(albumId); });