Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix state

AmanRajSinghMouryac6aabdbca923
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
index cdc5052b13..cf817ebd4a 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/edit_album_details_sheet.dart
@@ -45,8 +45,15 @@ Future<void> showEditAlbumDetailsSheet({
initialName: collection.displayName,
initialDescription: collection.displayDescription ?? "",
initialCover: initialCover,
- onSelectCover: () async {
- final coverID = await showPickCoverPhotoSheet(sheetContext, collection);
+ onSelectCover: (pendingCoverID) async {
+ final hasEffectiveCustomCover = pendingCoverID == null
+ ? collection.hasCover
+ : pendingCoverID != 0;
+ final coverID = await showPickCoverPhotoSheet(
+ sheetContext,
+ collection,
+ hasEffectiveCustomCover: hasEffectiveCustomCover,
+ );
if (coverID == null) {
return null;
}
@@ -77,7 +84,8 @@ class EditAlbumDetailsSheet extends StatefulWidget {
final String initialName;
final String initialDescription;
final Future<EnteFile?> initialCover;
- final Future<AlbumCoverSelection?> Function() onSelectCover;
+ final Future<AlbumCoverSelection?> Function(int? pendingCoverID)
+ onSelectCover;
final Future<void> Function(AlbumDetailsUpdate update) onSave;
@override
@@ -221,7 +229,7 @@ class _EditAlbumDetailsSheetState extends State<EditAlbumDetailsSheet> {
}
Future<void> _selectCover() async {
- final selection = await widget.onSelectCover();
+ final selection = await widget.onSelectCover(_pendingCoverID);
if (!mounted || selection == null) {
return;
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
index d0c649677f..70c5f657dc 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/hooks/pick_cover_photo.dart
@@ -14,19 +14,28 @@ import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.da
Future<int?> showPickCoverPhotoSheet(
BuildContext context,
- Collection collection,
-) {
+ Collection collection, {
+ required bool hasEffectiveCustomCover,
+}) {
return showBottomSheetComponent<int>(
context: context,
- builder: (_) => PickCoverPhotoWidget(collection),
+ builder: (_) => PickCoverPhotoWidget(
+ collection,
+ hasEffectiveCustomCover: hasEffectiveCustomCover,
+ ),
enableDrag: true,
);
}
class PickCoverPhotoWidget extends StatefulWidget {
final Collection collection;
+ final bool hasEffectiveCustomCover;
- const PickCoverPhotoWidget(this.collection, {super.key});
+ const PickCoverPhotoWidget(
+ this.collection, {
+ super.key,
+ required this.hasEffectiveCustomCover,
+ });
@override
State<PickCoverPhotoWidget> createState() => _PickCoverPhotoWidgetState();
@@ -120,7 +129,7 @@ class _PickCoverPhotoWidgetState extends State<PickCoverPhotoWidget> {
}
: null,
),
- if (widget.collection.hasCover) ...[
+ if (widget.hasEffectiveCustomCover) ...[
const SizedBox(height: Spacing.md),
ButtonComponent(
variant: ButtonComponentVariant.secondary,