From c69786b0395b59e9b2849a71ff430eb26309cfa0 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 31 Oct 2025 08:42:01 -0500 Subject: [PATCH] fix: button condition rendering (#23400) --- .../asset_viewer/bottom_sheet.widget.dart | 22 +++++++++++++++---- mobile/lib/utils/action_button.utils.dart | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart b/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart index 00e16fa870..9271c99ae9 100644 --- a/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart +++ b/mobile/lib/presentation/widgets/asset_viewer/bottom_sheet.widget.dart @@ -141,14 +141,28 @@ class _AssetDetailBottomSheet extends ConsumerWidget { } Widget _buildAppearsInList(WidgetRef ref, BuildContext context) { - final isRemote = ref.watch(currentAssetNotifier)?.hasRemote ?? false; - if (!isRemote) { + final aseet = ref.watch(currentAssetNotifier); + if (aseet == null) { + return const SizedBox.shrink(); + } + + if (!aseet.hasRemote) { + return const SizedBox.shrink(); + } + + String? remoteAssetId; + if (aseet is RemoteAsset) { + remoteAssetId = aseet.id; + } else if (aseet is LocalAsset) { + remoteAssetId = aseet.remoteAssetId; + } + + if (remoteAssetId == null) { return const SizedBox.shrink(); } - final remoteAsset = ref.watch(currentAssetNotifier) as RemoteAsset; final userId = ref.watch(currentUserProvider)?.id; - final assetAlbums = ref.watch(albumsContainingAssetProvider(remoteAsset.id)); + final assetAlbums = ref.watch(albumsContainingAssetProvider(remoteAssetId)); return assetAlbums.when( data: (albums) { diff --git a/mobile/lib/utils/action_button.utils.dart b/mobile/lib/utils/action_button.utils.dart index de606c83d3..42729becc9 100644 --- a/mobile/lib/utils/action_button.utils.dart +++ b/mobile/lib/utils/action_button.utils.dart @@ -127,7 +127,7 @@ enum ActionButtonType { context.currentAlbum!.isShared, ActionButtonType.similarPhotos => !context.isInLockedView && // - context.asset.hasRemote, + context.asset is RemoteAsset, }; }