Regression: only open dynamic collections after creating a new one

This commit is contained in:
Ming Ming 2023-05-13 02:44:21 +08:00
parent cc3780587b
commit 6b9175de18
8 changed files with 37 additions and 5 deletions

View file

@ -58,6 +58,9 @@ class Collection with EquatableMixin {
CollectionSorter getSorter() => CollectionSorter.fromSortType(itemSort);
/// See [CollectionContentProvider.isDynamicCollection]
bool get isDynamicCollection => contentProvider.isDynamicCollection;
@override
List<Object?> get props => [
name,
@ -127,4 +130,10 @@ abstract class CollectionContentProvider with EquatableMixin {
int height, {
bool? isKeepAspectRatio,
});
/// Return whether this is a dynamic collection
///
/// A collection is defined as a dynamic one when the items are not specified
/// explicitly by the user, but rather derived from some conditions
bool get isDynamicCollection;
}

View file

@ -99,6 +99,9 @@ class CollectionAlbumProvider
}
}
@override
bool get isDynamicCollection => album.provider is! AlbumStaticProvider;
@override
List<Object?> get props => [account, album];

View file

@ -50,6 +50,9 @@ class CollectionLocationGroupProvider
);
}
@override
bool get isDynamicCollection => true;
@override
List<Object?> get props => [account, location];

View file

@ -58,6 +58,9 @@ class CollectionMemoryProvider
));
}
@override
bool get isDynamicCollection => true;
@override
String toString() => _$toString();

View file

@ -73,6 +73,9 @@ class CollectionNcAlbumProvider
}
}
@override
bool get isDynamicCollection => false;
@override
List<Object?> get props => [account, album];

View file

@ -48,6 +48,9 @@ class CollectionPersonProvider
size: math.max(width, height));
}
@override
bool get isDynamicCollection => true;
@override
List<Object?> get props => [account, person];

View file

@ -43,6 +43,9 @@ class CollectionTagProvider
}) =>
null;
@override
bool get isDynamicCollection => true;
@override
List<Object?> get props => [account, tags];

View file

@ -240,11 +240,16 @@ class _WrappedHomeCollectionsState extends State<_WrappedHomeCollections>
if (collection == null) {
return;
}
// open the newly created collection
unawaited(Navigator.of(context).pushNamed(
CollectionBrowser.routeName,
arguments: CollectionBrowserArguments(collection),
));
// Right now we don't have a way to add photos inside the
// CollectionBrowser, eventually we should add that and remove this
// branching
if (collection.isDynamicCollection) {
// open the newly created collection
unawaited(Navigator.of(context).pushNamed(
CollectionBrowser.routeName,
arguments: CollectionBrowserArguments(collection),
));
}
} catch (e, stacktrace) {
_log.shout("[_onNewCollectionPressed] Failed", e, stacktrace);
SnackBarManager().showSnackBar(SnackBar(