Fix first upload to uncategorized collection (#1186)

This commit is contained in:
Abhinav Kumar 2023-06-14 21:32:43 +05:30 committed by GitHub
commit bec8540478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,9 +15,11 @@ import { CollectionSelectorIntent } from 'types/gallery';
import {
COLLECTION_SORT_ORDER,
CollectionSummaryType,
DUMMY_UNCATEGORIZED_SECTION,
} from 'constants/collection';
import { t } from 'i18next';
import { isSelectAllowedCollection } from 'utils/collection';
import { createUnCategorizedCollection } from 'services/collectionService';
export interface CollectionSelectorAttributes {
callback: (collection: Collection) => void;
@ -81,15 +83,22 @@ function CollectionSelector({
setCollectionsToShow(collectionsToShow);
};
main();
}, [collectionSummaries, attributes]);
}, [collectionSummaries, attributes, props.open]);
if (!collectionsToShow?.length) {
return <></>;
}
const handleCollectionClick = (collectionID: number) => {
const collection = collections.find((c) => c.id === collectionID);
attributes.callback(collection);
const handleCollectionClick = async (collectionID: number) => {
let selectedCollection: Collection;
if (collectionID === DUMMY_UNCATEGORIZED_SECTION) {
const uncategorizedCollection =
await createUnCategorizedCollection();
selectedCollection = uncategorizedCollection;
} else {
selectedCollection = collections.find((c) => c.id === collectionID);
}
attributes.callback(selectedCollection);
props.onClose();
};