mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
refactor(mobile): improve naming for clarity, refactor code
This commit is contained in:
parent
b3013244b1
commit
eb4817486d
15 changed files with 68 additions and 72 deletions
|
|
@ -42,10 +42,6 @@ extension TimelineOriginX on TimelineOrigin {
|
|||
bool get isDeepLink => this == TimelineOrigin.deepLink || this == TimelineOrigin.deepLinkTrash;
|
||||
|
||||
bool get isTrash => this == TimelineOrigin.trash || this == TimelineOrigin.deepLinkTrash;
|
||||
|
||||
bool get isNotDeepLink => !isDeepLink;
|
||||
|
||||
bool get isNotTrash => !isTrash;
|
||||
}
|
||||
|
||||
class TimelineFactory {
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
|||
}
|
||||
|
||||
BaseAsset displayAsset = asset;
|
||||
final showAssetStack = ref.watch(timelineServiceProvider.select((s) => s.origin.isNotTrash));
|
||||
final showAssetStack = ref.watch(timelineServiceProvider.select((s) => !s.origin.isTrash));
|
||||
final stackChildren = showAssetStack ? ref.watch(stackChildrenNotifier(asset)).valueOrNull : null;
|
||||
if (stackChildren != null && stackChildren.isNotEmpty) {
|
||||
final safeStackIndex = stackIndex.clamp(0, stackChildren.length - 1);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart'
|
|||
import 'package:immich_mobile/providers/cast.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/utils/system_ui.utils.dart';
|
||||
import 'package:immich_mobile/widgets/photo_view/photo_view.dart';
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||
return true;
|
||||
}
|
||||
|
||||
final localAssetId = ref.read(viewIntentCurrentProvider)?.localAssetId;
|
||||
final localAssetId = ref.read(activeViewIntentPayloadProvider)?.localAssetId;
|
||||
return localAssetId != null && currentAsset.localId == localAssetId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|||
import 'package:immich_mobile/platform/view_intent_api.g.dart';
|
||||
import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/services/foreground_upload.service.dart';
|
||||
import 'package:immich_mobile/services/view_intent.service.dart';
|
||||
|
|
@ -27,7 +27,7 @@ class AssetUploadCoordinator {
|
|||
required Completer<void> cancelToken,
|
||||
required UploadCallbacks callbacks,
|
||||
}) async {
|
||||
final activeViewIntent = source == ActionSource.viewer ? _ref.read(viewIntentCurrentProvider) : null;
|
||||
final activeViewIntent = source == ActionSource.viewer ? _ref.read(activeViewIntentPayloadProvider) : null;
|
||||
final viewIntentFilePath = source == ActionSource.viewer ? _ref.read(viewIntentFilePathProvider) : null;
|
||||
if (viewIntentFilePath == null) {
|
||||
final viewerAsset = source == ActionSource.viewer && assets.length == 1 ? assets.single : null;
|
||||
|
|
@ -59,7 +59,7 @@ class AssetUploadCoordinator {
|
|||
final remoteAsset = await _waitForRemoteAsset(remoteAssetId);
|
||||
final latestAsset = _ref.read(assetViewerProvider).currentAsset;
|
||||
final isCurrentViewIntent =
|
||||
activeViewIntent == null || identical(_ref.read(viewIntentCurrentProvider), activeViewIntent);
|
||||
activeViewIntent == null || identical(_ref.read(activeViewIntentPayloadProvider), activeViewIntent);
|
||||
if (remoteAsset == null ||
|
||||
latestAsset == null ||
|
||||
!latestAsset.refersToSameAsset(viewerAsset) ||
|
||||
|
|
@ -147,7 +147,7 @@ class AssetUploadCoordinator {
|
|||
}
|
||||
|
||||
bool _isCurrentUpload(LocalAsset asset, String path, ViewIntentPayload? activeViewIntent) {
|
||||
if (activeViewIntent != null && !identical(_ref.read(viewIntentCurrentProvider), activeViewIntent)) {
|
||||
if (activeViewIntent != null && !identical(_ref.read(activeViewIntentPayloadProvider), activeViewIntent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/platform/view_intent_api.g.dart';
|
||||
|
||||
class ViewIntentCurrentNotifier extends Notifier<ViewIntentPayload?> {
|
||||
class ActiveViewIntentNotifier extends Notifier<ViewIntentPayload?> {
|
||||
@override
|
||||
ViewIntentPayload? build() => null;
|
||||
|
||||
|
|
@ -21,6 +21,6 @@ class ViewIntentCurrentNotifier extends Notifier<ViewIntentPayload?> {
|
|||
}
|
||||
}
|
||||
|
||||
final viewIntentCurrentProvider = NotifierProvider<ViewIntentCurrentNotifier, ViewIntentPayload?>(
|
||||
ViewIntentCurrentNotifier.new,
|
||||
final activeViewIntentPayloadProvider = NotifierProvider<ActiveViewIntentNotifier, ViewIntentPayload?>(
|
||||
ActiveViewIntentNotifier.new,
|
||||
);
|
||||
|
|
@ -4,7 +4,7 @@ import 'package:immich_mobile/domain/services/timeline.service.dart';
|
|||
import 'package:immich_mobile/platform/view_intent_api.g.dart';
|
||||
import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_handler.provider.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
|
@ -13,10 +13,10 @@ import 'package:logging/logging.dart';
|
|||
final viewIntentAssetActionCoordinatorProvider = Provider((ref) {
|
||||
return ViewIntentAssetActionCoordinator(
|
||||
ref,
|
||||
viewIntent: ref.watch(viewIntentCurrentProvider),
|
||||
viewIntent: ref.watch(activeViewIntentPayloadProvider),
|
||||
isFileBacked: ref.watch(viewIntentFilePathProvider) != null,
|
||||
);
|
||||
}, dependencies: [assetViewerProvider, timelineServiceProvider, viewIntentCurrentProvider, viewIntentFilePathProvider]);
|
||||
}, dependencies: [assetViewerProvider, timelineServiceProvider, activeViewIntentPayloadProvider, viewIntentFilePathProvider]);
|
||||
|
||||
class ViewIntentAssetActionCoordinator {
|
||||
const ViewIntentAssetActionCoordinator(this._ref, {required this._viewIntent, required this._isFileBacked});
|
||||
|
|
@ -66,7 +66,7 @@ class ViewIntentAssetActionCoordinator {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!identical(_ref.read(viewIntentCurrentProvider), _viewIntent)) {
|
||||
if (!identical(_ref.read(activeViewIntentPayloadProvider), _viewIntent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ abstract class ViewIntentHandler {
|
|||
|
||||
Future<void> flushDeferredViewIntent();
|
||||
|
||||
Future<void> handle(ViewIntentPayload attachment);
|
||||
Future<void> handle(ViewIntentPayload payload);
|
||||
|
||||
Future<bool> reopenRemoteAsset(String remoteAssetId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import 'package:immich_mobile/providers/auth.provider.dart';
|
|||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/toast.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_handler.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_pending.provider.dart';
|
||||
|
|
@ -78,27 +78,27 @@ class AndroidViewIntentHandler implements ViewIntentHandler {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> handle(ViewIntentPayload attachment) async {
|
||||
Future<void> handle(ViewIntentPayload payload) async {
|
||||
_logger.info(
|
||||
'handle attachment, mimeType:${attachment.mimeType}, localAssetId=${attachment.localAssetId}, path=${attachment.path}, isAuthenticated:${_ref.read(authProvider).isAuthenticated}',
|
||||
'handle attachment, mimeType:${payload.mimeType}, localAssetId=${payload.localAssetId}, path=${payload.path}, isAuthenticated:${_ref.read(authProvider).isAuthenticated}',
|
||||
);
|
||||
|
||||
if (!_ref.read(authProvider).isAuthenticated) {
|
||||
_clearCurrentViewIntent();
|
||||
_ref.read(viewIntentPendingProvider.notifier).defer(attachment);
|
||||
_ref.read(viewIntentPendingProvider.notifier).defer(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
_activateViewIntent(attachment);
|
||||
_activateViewIntent(payload);
|
||||
|
||||
final ViewIntentResolvedAsset resolvedAsset;
|
||||
final ViewIntentResolution resolvedAsset;
|
||||
try {
|
||||
resolvedAsset = await _viewIntentAssetResolver.resolve(attachment);
|
||||
resolvedAsset = await _viewIntentAssetResolver.resolve(payload);
|
||||
} catch (_) {
|
||||
_ref.read(viewIntentCurrentProvider.notifier).clearIfMatch(attachment);
|
||||
_ref.read(activeViewIntentPayloadProvider.notifier).clearIfMatch(payload);
|
||||
rethrow;
|
||||
}
|
||||
if (!identical(_ref.read(viewIntentCurrentProvider), attachment)) {
|
||||
if (!identical(_ref.read(activeViewIntentPayloadProvider), payload)) {
|
||||
await resolvedAsset.timelineService.dispose();
|
||||
return;
|
||||
}
|
||||
|
|
@ -107,20 +107,20 @@ class AndroidViewIntentHandler implements ViewIntentHandler {
|
|||
await _openAssetViewer(
|
||||
asset: resolvedAsset.asset,
|
||||
timelineService: resolvedAsset.timelineService,
|
||||
attachment: attachment,
|
||||
attachment: payload,
|
||||
viewIntentFilePath: resolvedAsset.viewIntentFilePath,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> reopenRemoteAsset(String remoteAssetId) async {
|
||||
final attachment = _ref.read(viewIntentCurrentProvider);
|
||||
final attachment = _ref.read(activeViewIntentPayloadProvider);
|
||||
if (attachment == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final asset = await _ref.read(assetServiceProvider).getRemoteAsset(remoteAssetId);
|
||||
if (asset == null || !identical(_ref.read(viewIntentCurrentProvider), attachment)) {
|
||||
if (asset == null || !identical(_ref.read(activeViewIntentPayloadProvider), attachment)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -145,14 +145,14 @@ class AndroidViewIntentHandler implements ViewIntentHandler {
|
|||
}
|
||||
|
||||
void _activateViewIntent(ViewIntentPayload attachment) {
|
||||
_ref.read(viewIntentCurrentProvider.notifier).setPayload(attachment);
|
||||
_ref.read(activeViewIntentPayloadProvider.notifier).setPayload(attachment);
|
||||
_ref.read(viewIntentFilePathProvider.notifier).clear();
|
||||
unawaited(_viewIntentService.cleanupManagedTempFile());
|
||||
_router.popUntilRoot();
|
||||
}
|
||||
|
||||
void _clearCurrentViewIntent() {
|
||||
_ref.read(viewIntentCurrentProvider.notifier).clear();
|
||||
_ref.read(activeViewIntentPayloadProvider.notifier).clear();
|
||||
_ref.read(viewIntentFilePathProvider.notifier).clear();
|
||||
unawaited(_viewIntentService.cleanupManagedTempFile());
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ class AndroidViewIntentHandler implements ViewIntentHandler {
|
|||
try {
|
||||
await _router.push(AssetViewerRoute(initialIndex: 0, timelineService: timelineService));
|
||||
} finally {
|
||||
_ref.read(viewIntentCurrentProvider.notifier).clearIfMatch(attachment);
|
||||
_ref.read(activeViewIntentPayloadProvider.notifier).clearIfMatch(attachment);
|
||||
if (viewIntentFilePath != null) {
|
||||
_ref.read(viewIntentFilePathProvider.notifier).clearIfMatch(viewIntentFilePath);
|
||||
await _viewIntentService.cleanupManagedTempFileIfCurrent(viewIntentFilePath);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class StubViewIntentHandler implements ViewIntentHandler {
|
|||
Future<void> flushDeferredViewIntent() async {}
|
||||
|
||||
@override
|
||||
Future<void> handle(ViewIntentPayload attachment) async {}
|
||||
Future<void> handle(ViewIntentPayload payload) async {}
|
||||
|
||||
@override
|
||||
Future<bool> reopenRemoteAsset(String remoteAssetId) async => false;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
|||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class ViewIntentResolvedAsset {
|
||||
class ViewIntentResolution {
|
||||
final BaseAsset asset;
|
||||
final TimelineService timelineService;
|
||||
|
||||
final String? viewIntentFilePath;
|
||||
|
||||
const ViewIntentResolvedAsset({required this.asset, required this.timelineService, this.viewIntentFilePath});
|
||||
const ViewIntentResolution({required this.asset, required this.timelineService, this.viewIntentFilePath});
|
||||
}
|
||||
|
||||
final viewIntentAssetResolverProvider = Provider<ViewIntentAssetResolver>(
|
||||
|
|
@ -43,7 +43,7 @@ class ViewIntentAssetResolver {
|
|||
required this._timelineFactory,
|
||||
});
|
||||
|
||||
Future<ViewIntentResolvedAsset> resolve(ViewIntentPayload attachment) async {
|
||||
Future<ViewIntentResolution> resolve(ViewIntentPayload attachment) async {
|
||||
final localAssetId = attachment.localAssetId;
|
||||
final path = attachment.path;
|
||||
_logger.fine('resolve start, localAssetId=$localAssetId, path=$path, mimeType=${attachment.mimeType}');
|
||||
|
|
@ -61,13 +61,13 @@ class ViewIntentAssetResolver {
|
|||
checksum: resolvedLocal.checksum,
|
||||
);
|
||||
if (remoteAsset != null) {
|
||||
return ViewIntentResolvedAsset(asset: remoteAsset, timelineService: _timelineFor(remoteAsset));
|
||||
return ViewIntentResolution(asset: remoteAsset, timelineService: _timelineFor(remoteAsset));
|
||||
}
|
||||
}
|
||||
|
||||
final asset = resolvedLocal.asset ?? _toTransientAsset(attachment, resolvedLocal.checksum);
|
||||
|
||||
return ViewIntentResolvedAsset(
|
||||
return ViewIntentResolution(
|
||||
asset: asset,
|
||||
timelineService: _timelineFor(asset),
|
||||
viewIntentFilePath: resolvedLocal.asset == null ? path : null,
|
||||
|
|
|
|||
|
|
@ -135,13 +135,13 @@ enum ActionButtonType {
|
|||
context.selectedCount == 1,
|
||||
ActionButtonType.unstack =>
|
||||
context.isOwner && //
|
||||
context.timelineOrigin.isNotTrash &&
|
||||
!context.timelineOrigin.isTrash &&
|
||||
!context.isInLockedView && //
|
||||
context.isStacked,
|
||||
ActionButtonType.openInBrowser => context.asset.hasRemote && !context.isInLockedView,
|
||||
ActionButtonType.likeActivity =>
|
||||
!context.isInLockedView &&
|
||||
context.timelineOrigin.isNotDeepLink &&
|
||||
!context.timelineOrigin.isDeepLink &&
|
||||
context.currentAlbum != null &&
|
||||
context.currentAlbum!.isActivityEnabled &&
|
||||
context.currentAlbum!.isShared,
|
||||
|
|
@ -155,8 +155,8 @@ enum ActionButtonType {
|
|||
ActionButtonType.openInfo => true,
|
||||
ActionButtonType.viewInTimeline =>
|
||||
context.timelineOrigin != TimelineOrigin.main &&
|
||||
context.timelineOrigin.isNotDeepLink &&
|
||||
context.timelineOrigin.isNotTrash &&
|
||||
!context.timelineOrigin.isDeepLink &&
|
||||
!context.timelineOrigin.isTrash &&
|
||||
context.timelineOrigin != TimelineOrigin.lockedFolder &&
|
||||
context.timelineOrigin != TimelineOrigin.archive &&
|
||||
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import 'package:immich_mobile/platform/view_intent_api.g.dart';
|
|||
import 'package:immich_mobile/providers/asset_upload_coordinator.provider.dart';
|
||||
import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/services/foreground_upload.service.dart';
|
||||
import 'package:immich_mobile/services/view_intent.service.dart';
|
||||
|
|
@ -90,7 +90,7 @@ void main() {
|
|||
final remoteController = StreamController<RemoteAsset?>.broadcast();
|
||||
addTearDown(remoteController.close);
|
||||
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(oldPayload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(oldPayload);
|
||||
container.read(assetViewerProvider.notifier).setAsset(localAsset);
|
||||
when(() => assetService.watchRemoteAsset(remoteAsset.id)).thenAnswer((_) => remoteController.stream);
|
||||
when(
|
||||
|
|
@ -114,7 +114,7 @@ void main() {
|
|||
);
|
||||
await pumpEventQueue();
|
||||
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(newPayload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(newPayload);
|
||||
remoteController.add(remoteAsset);
|
||||
await upload;
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ void main() {
|
|||
final remoteController = StreamController<RemoteAsset?>.broadcast();
|
||||
addTearDown(remoteController.close);
|
||||
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(oldPayload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(oldPayload);
|
||||
container.read(viewIntentFilePathProvider.notifier).setPath(path);
|
||||
container.read(assetViewerProvider.notifier).setAsset(localAsset);
|
||||
when(() => viewIntentService.markUploadActive(path)).thenReturn(null);
|
||||
|
|
@ -354,7 +354,7 @@ void main() {
|
|||
);
|
||||
await pumpEventQueue();
|
||||
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(newPayload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(newPayload);
|
||||
remoteController.add(uploadedRemote);
|
||||
await upload;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import 'package:immich_mobile/domain/services/timeline.service.dart';
|
|||
import 'package:immich_mobile/platform/view_intent_api.g.dart';
|
||||
import 'package:immich_mobile/providers/asset_viewer/asset_viewer.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_asset_action_coordinator.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_handler.provider.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
|
@ -29,7 +29,7 @@ class _TestViewIntentHandler implements ViewIntentHandler {
|
|||
Future<void> flushDeferredViewIntent() async {}
|
||||
|
||||
@override
|
||||
Future<void> handle(ViewIntentPayload attachment) async {}
|
||||
Future<void> handle(ViewIntentPayload payload) async {}
|
||||
|
||||
@override
|
||||
void init() {}
|
||||
|
|
@ -100,7 +100,7 @@ void main() {
|
|||
final scope = ProviderScope.containerOf(tester.element(find.byKey(const Key('root'))), listen: false);
|
||||
if (activeViewIntent) {
|
||||
scope
|
||||
.read(viewIntentCurrentProvider.notifier)
|
||||
.read(activeViewIntentPayloadProvider.notifier)
|
||||
.setPayload(
|
||||
ViewIntentPayload(path: '/tmp/view-intent.jpg', mimeType: 'image/jpeg', localAssetId: asset.localId),
|
||||
);
|
||||
|
|
@ -181,7 +181,7 @@ void main() {
|
|||
mimeType: 'image/jpeg',
|
||||
localAssetId: 'newer-local',
|
||||
);
|
||||
harness.scope.read(viewIntentCurrentProvider.notifier).setPayload(newerPayload);
|
||||
harness.scope.read(activeViewIntentPayloadProvider.notifier).setPayload(newerPayload);
|
||||
|
||||
await harness.coordinator.afterDelete(source: ActionSource.viewer, remoteAssetIds: [asset.id], movedToTrash: false);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import 'package:immich_mobile/providers/auth.provider.dart';
|
|||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/toast.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_current.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/active_view_intent_payload_provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_file_path.provider.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_handler_android.dart';
|
||||
import 'package:immich_mobile/providers/view_intent/view_intent_pending.provider.dart';
|
||||
|
|
@ -205,7 +205,7 @@ void main() {
|
|||
authNotifier.setAuthenticated(true);
|
||||
|
||||
when(() => resolver.resolve(payload)).thenAnswer((_) async {
|
||||
return ViewIntentResolvedAsset(asset: deepLinkAsset, timelineService: deepLinkTimelineService);
|
||||
return ViewIntentResolution(asset: deepLinkAsset, timelineService: deepLinkTimelineService);
|
||||
});
|
||||
|
||||
unawaited(handler.flushDeferredViewIntent());
|
||||
|
|
@ -256,7 +256,7 @@ void main() {
|
|||
viewIntentService.consumedAttachment = payload;
|
||||
when(
|
||||
() => resolver.resolve(payload),
|
||||
).thenAnswer((_) async => ViewIntentResolvedAsset(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
).thenAnswer((_) async => ViewIntentResolution(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
|
||||
unawaited(handler.onAppResumed());
|
||||
await tester.pump();
|
||||
|
|
@ -284,19 +284,19 @@ void main() {
|
|||
|
||||
when(
|
||||
() => resolver.resolve(payload),
|
||||
).thenAnswer((_) async => ViewIntentResolvedAsset(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
).thenAnswer((_) async => ViewIntentResolution(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
when(
|
||||
() => resolver.resolve(secondPayload),
|
||||
).thenAnswer((_) async => ViewIntentResolvedAsset(asset: secondAsset, timelineService: secondTimelineService));
|
||||
).thenAnswer((_) async => ViewIntentResolution(asset: secondAsset, timelineService: secondTimelineService));
|
||||
|
||||
await handler.handle(payload);
|
||||
expect(container.read(assetViewerProvider).currentAsset, deepLinkAsset);
|
||||
expect(container.read(viewIntentCurrentProvider), isNull);
|
||||
expect(container.read(activeViewIntentPayloadProvider), isNull);
|
||||
|
||||
await handler.handle(secondPayload);
|
||||
|
||||
expect(container.read(assetViewerProvider).currentAsset, secondAsset);
|
||||
expect(container.read(viewIntentCurrentProvider), isNull);
|
||||
expect(container.read(activeViewIntentPayloadProvider), isNull);
|
||||
verify(() => resolver.resolve(payload)).called(1);
|
||||
verify(() => resolver.resolve(secondPayload)).called(1);
|
||||
verify(() => router.popUntilRoot()).called(2);
|
||||
|
|
@ -306,7 +306,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('a slower view intent cannot replace a newer one', () async {
|
||||
final firstResolution = Completer<ViewIntentResolvedAsset>();
|
||||
final firstResolution = Completer<ViewIntentResolution>();
|
||||
final secondPayload = ViewIntentPayload(
|
||||
path: '/tmp/incoming-b.jpg',
|
||||
mimeType: 'image/jpeg',
|
||||
|
|
@ -319,17 +319,17 @@ void main() {
|
|||
when(() => resolver.resolve(payload)).thenAnswer((_) => firstResolution.future);
|
||||
when(
|
||||
() => resolver.resolve(secondPayload),
|
||||
).thenAnswer((_) async => ViewIntentResolvedAsset(asset: secondAsset, timelineService: secondTimelineService));
|
||||
).thenAnswer((_) async => ViewIntentResolution(asset: secondAsset, timelineService: secondTimelineService));
|
||||
|
||||
final firstHandle = handler.handle(payload);
|
||||
await pumpEventQueue();
|
||||
await handler.handle(secondPayload);
|
||||
|
||||
firstResolution.complete(ViewIntentResolvedAsset(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
firstResolution.complete(ViewIntentResolution(asset: deepLinkAsset, timelineService: deepLinkTimelineService));
|
||||
await firstHandle;
|
||||
|
||||
expect(container.read(assetViewerProvider).currentAsset, secondAsset);
|
||||
expect(container.read(viewIntentCurrentProvider), isNull);
|
||||
expect(container.read(activeViewIntentPayloadProvider), isNull);
|
||||
verify(() => router.popUntilRoot()).called(2);
|
||||
verify(() => router.push<Object?>(any())).called(1);
|
||||
});
|
||||
|
|
@ -339,7 +339,7 @@ void main() {
|
|||
final routeClosed = Completer<Object?>();
|
||||
when(() => router.push<Object?>(any())).thenAnswer((_) => routeClosed.future);
|
||||
when(() => resolver.resolve(payload)).thenAnswer(
|
||||
(_) async => ViewIntentResolvedAsset(
|
||||
(_) async => ViewIntentResolution(
|
||||
asset: deepLinkAsset,
|
||||
timelineService: deepLinkTimelineService,
|
||||
viewIntentFilePath: path,
|
||||
|
|
@ -349,13 +349,13 @@ void main() {
|
|||
final handling = handler.handle(payload);
|
||||
await pumpEventQueue();
|
||||
|
||||
expect(container.read(viewIntentCurrentProvider), same(payload));
|
||||
expect(container.read(activeViewIntentPayloadProvider), same(payload));
|
||||
expect(container.read(viewIntentFilePathProvider), path);
|
||||
|
||||
routeClosed.complete(null);
|
||||
await handling;
|
||||
|
||||
expect(container.read(viewIntentCurrentProvider), isNull);
|
||||
expect(container.read(activeViewIntentPayloadProvider), isNull);
|
||||
expect(container.read(viewIntentFilePathProvider), isNull);
|
||||
expect(viewIntentService.cleanedManagedTempPaths, [path]);
|
||||
});
|
||||
|
|
@ -364,7 +364,7 @@ void main() {
|
|||
final restoredAsset = _remoteAsset(id: 'remote-1', localId: 'local-1');
|
||||
final restoredTimeline = await _createReadyTimelineService([restoredAsset], TimelineOrigin.deepLink);
|
||||
addTearDown(restoredTimeline.dispose);
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(payload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(payload);
|
||||
|
||||
when(() => assetService.getRemoteAsset(restoredAsset.id)).thenAnswer((_) async => restoredAsset);
|
||||
when(() => timelineFactory.fromAssets(any(), TimelineOrigin.deepLink)).thenReturn(restoredTimeline);
|
||||
|
|
@ -384,7 +384,7 @@ void main() {
|
|||
final trashedAsset = _remoteAsset(id: 'remote-trashed', localId: 'local-1', deletedAt: DateTime(2026, 8, 4));
|
||||
final trashTimeline = await _createReadyTimelineService([trashedAsset], TimelineOrigin.deepLinkTrash);
|
||||
addTearDown(trashTimeline.dispose);
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(payload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(payload);
|
||||
|
||||
when(() => assetService.getRemoteAsset(trashedAsset.id)).thenAnswer((_) async => trashedAsset);
|
||||
when(() => timelineFactory.fromAssets(any(), TimelineOrigin.deepLinkTrash)).thenReturn(trashTimeline);
|
||||
|
|
@ -404,12 +404,12 @@ void main() {
|
|||
final restoredAsset = _remoteAsset(id: 'remote-delayed', localId: 'local-1');
|
||||
final lookup = Completer<RemoteAsset?>();
|
||||
final newerPayload = ViewIntentPayload(path: '/tmp/newer.jpg', mimeType: 'image/jpeg', localAssetId: 'local-2');
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(payload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(payload);
|
||||
when(() => assetService.getRemoteAsset(restoredAsset.id)).thenAnswer((_) => lookup.future);
|
||||
|
||||
final reopening = handler.reopenRemoteAsset(restoredAsset.id);
|
||||
await pumpEventQueue();
|
||||
container.read(viewIntentCurrentProvider.notifier).setPayload(newerPayload);
|
||||
container.read(activeViewIntentPayloadProvider.notifier).setPayload(newerPayload);
|
||||
lookup.complete(restoredAsset);
|
||||
|
||||
expect(await reopening, isFalse);
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ void main() {
|
|||
});
|
||||
}
|
||||
|
||||
Future<ViewIntentResolvedAsset> _resolve(ProviderContainer container, ViewIntentPayload payload) {
|
||||
Future<ViewIntentResolution> _resolve(ProviderContainer container, ViewIntentPayload payload) {
|
||||
return container.read(viewIntentAssetResolverProvider).resolve(payload);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue