fix(mobile): items not deselecting on back button (#17403)

* fix: items not deselecting on back button

* chore: add comments
This commit is contained in:
Yaros 2025-04-07 16:35:27 +02:00 committed by GitHub
parent 1e4b9ae5b7
commit a724f147fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -546,15 +546,16 @@ class ImmichAssetGridViewState extends ConsumerState<ImmichAssetGridView> {
if (didPop) { if (didPop) {
return; return;
} else { } else {
if (widget.preselectedAssets == null) { /// `preselectedAssets` is only present when opening the asset grid from the
Navigator.of(context).canPop() ? Navigator.of(context).pop() : null; /// "add to album" button.
} ///
if (_selectedAssets.length != widget.preselectedAssets!.length && /// `_selectedAssets` includes `preselectedAssets` on initialization.
!widget.preselectedAssets!.containsAll(_selectedAssets)) { if (_selectedAssets.length >
{ (widget.preselectedAssets?.length ?? 0)) {
_deselectAll(); /// `_deselectAll` only deselects the selected assets,
return; /// doesn't affect the preselected ones.
} _deselectAll();
return;
} else { } else {
Navigator.of(context).canPop() ? Navigator.of(context).pop() : null; Navigator.of(context).canPop() ? Navigator.of(context).pop() : null;
} }