immich/mobile/lib/providers/infrastructure/asset_viewer/current_asset.provider.dart
shenlong 181efb9010
refactor: reduce timeline rebuilds (#19704)
* reduce timeline rebuilds

* feat: adds bottom sheet map and actions (#19692)

* adds bottom sheet map and actions

* PR feedbacks

* only reload the asset viewer if asset is changed

* styling tweak

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>

* rename singleton and remove event prefix

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
2025-07-04 10:30:34 -05:00

37 lines
963 B
Dart

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
final currentAssetNotifier =
AutoDisposeNotifierProvider<CurrentAssetNotifier, BaseAsset>(
CurrentAssetNotifier.new,
);
class CurrentAssetNotifier extends AutoDisposeNotifier<BaseAsset> {
KeepAliveLink? _keepAliveLink;
@override
BaseAsset build() {
throw UnimplementedError(
'An asset must be set before using the currentAssetProvider.',
);
}
void setAsset(BaseAsset asset) {
_keepAliveLink?.close();
state = asset;
_keepAliveLink = ref.keepAlive();
}
void dispose() {
_keepAliveLink?.close();
}
}
final currentAssetExifProvider = FutureProvider.autoDispose(
(ref) {
final currentAsset = ref.watch(currentAssetNotifier);
return ref.watch(assetServiceProvider).getExif(currentAsset);
},
);