Show uncat colleciton during restore

This commit is contained in:
Neeraj Gupta 2023-08-28 08:29:00 +05:30
parent c392d67677
commit 67e7bf0220
2 changed files with 12 additions and 2 deletions

View file

@ -305,6 +305,7 @@ class CollectionsService {
List<Collection> getCollectionsForUI({ List<Collection> getCollectionsForUI({
bool includedShared = false, bool includedShared = false,
bool includeCollab = false, bool includeCollab = false,
bool includeUncategorized = false,
}) { }) {
final Set<CollectionParticipantRole> allowedRoles = { final Set<CollectionParticipantRole> allowedRoles = {
CollectionParticipantRole.owner, CollectionParticipantRole.owner,
@ -320,7 +321,8 @@ class CollectionsService {
.where( .where(
(c) => (c) =>
!c.isDeleted && !c.isDeleted &&
c.type != CollectionType.uncategorized && (includeUncategorized ||
c.type != CollectionType.uncategorized) &&
!c.isHidden() && !c.isHidden() &&
allowedRoles.contains(c.getRole(userID)), allowedRoles.contains(c.getRole(userID)),
) )

View file

@ -247,11 +247,14 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
} }
Future<List<Collection>> _getCollectionsWithThumbnail() async { Future<List<Collection>> _getCollectionsWithThumbnail() async {
final bool includeUncategorized =
widget.actionType == CollectionActionType.restoreFiles;
final List<Collection> collections = final List<Collection> collections =
CollectionsService.instance.getCollectionsForUI( CollectionsService.instance.getCollectionsForUI(
// in collections where user is a collaborator, only addTo and remove // in collections where user is a collaborator, only addTo and remove
// action can to be performed // action can to be performed
includeCollab: widget.actionType == CollectionActionType.addFiles, includeCollab: widget.actionType == CollectionActionType.addFiles,
includeUncategorized: includeUncategorized,
); );
collections.sort((first, second) { collections.sort((first, second) {
return compareAsciiLowerCaseNatural( return compareAsciiLowerCaseNatural(
@ -261,10 +264,15 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
}); });
final List<Collection> pinned = []; final List<Collection> pinned = [];
final List<Collection> unpinned = []; final List<Collection> unpinned = [];
// show uncategorized collection only for restore files action
Collection? uncategorized;
for (final collection in collections) { for (final collection in collections) {
if (collection.isQuickLinkCollection() || if (collection.isQuickLinkCollection() ||
collection.type == CollectionType.favorites || collection.type == CollectionType.favorites ||
collection.type == CollectionType.uncategorized) { collection.type == CollectionType.uncategorized) {
if(collection.type == CollectionType.uncategorized && includeUncategorized) {
uncategorized = collection;
}
continue; continue;
} }
if (collection.isPinned) { if (collection.isPinned) {
@ -273,7 +281,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
unpinned.add(collection); unpinned.add(collection);
} }
} }
return pinned + unpinned; return pinned + unpinned + (uncategorized != null ? [uncategorized] : []);
} }
void _removeIncomingCollections(List<Collection> items) { void _removeIncomingCollections(List<Collection> items) {