You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-07 23:03:36 +02:00
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>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
||||
import 'package:immich_mobile/providers/user.provider.dart';
|
||||
import 'package:immich_mobile/services/action.service.dart';
|
||||
@ -55,7 +56,7 @@ class ActionNotifier extends Notifier<void> {
|
||||
final Set<BaseAsset> assets = switch (source) {
|
||||
ActionSource.timeline =>
|
||||
ref.read(multiSelectProvider.select((s) => s.selectedAssets)),
|
||||
ActionSource.viewer => {},
|
||||
ActionSource.viewer => {ref.read(currentAssetNotifier)},
|
||||
};
|
||||
|
||||
return switch (T) {
|
||||
|
@ -3,9 +3,13 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||
|
||||
final currentAssetNotifier =
|
||||
NotifierProvider<CurrentAssetNotifier, BaseAsset>(CurrentAssetNotifier.new);
|
||||
AutoDisposeNotifierProvider<CurrentAssetNotifier, BaseAsset>(
|
||||
CurrentAssetNotifier.new,
|
||||
);
|
||||
|
||||
class CurrentAssetNotifier extends AutoDisposeNotifier<BaseAsset> {
|
||||
KeepAliveLink? _keepAliveLink;
|
||||
|
||||
class CurrentAssetNotifier extends Notifier<BaseAsset> {
|
||||
@override
|
||||
BaseAsset build() {
|
||||
throw UnimplementedError(
|
||||
@ -14,11 +18,17 @@ class CurrentAssetNotifier extends Notifier<BaseAsset> {
|
||||
}
|
||||
|
||||
void setAsset(BaseAsset asset) {
|
||||
_keepAliveLink?.close();
|
||||
state = asset;
|
||||
_keepAliveLink = ref.keepAlive();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_keepAliveLink?.close();
|
||||
}
|
||||
}
|
||||
|
||||
final currentAssetExifProvider = FutureProvider(
|
||||
final currentAssetExifProvider = FutureProvider.autoDispose(
|
||||
(ref) {
|
||||
final currentAsset = ref.watch(currentAssetNotifier);
|
||||
return ref.watch(assetServiceProvider).getExif(currentAsset);
|
||||
|
Reference in New Issue
Block a user