use suggested if available during first upload

This commit is contained in:
Abhinav 2022-01-12 14:42:46 +05:30
parent 980f6439df
commit bed6a086a6
2 changed files with 9 additions and 6 deletions

View file

@ -50,7 +50,7 @@ function CollectionSelector({
CollectionAndItsLatestFile[]
>([]);
useEffect(() => {
if (!attributes) {
if (!attributes || !props.show) {
return;
}
const user: User = getData(LS_KEYS.USER);

View file

@ -141,7 +141,7 @@ export default function Upload(props: Props) {
}
}
return {
suggestedCollectionName: commonPathPrefix,
suggestedCollectionName: commonPathPrefix || null,
multipleFolders: firstFileFolder !== lastFileFolder,
};
}
@ -279,14 +279,14 @@ export default function Upload(props: Props) {
collectionName
);
} else {
showCollectionCreateModal(analysisResult);
showCollectionCreateModal();
}
};
const showCollectionCreateModal = (analysisResult: AnalysisResult) => {
const showCollectionCreateModal = () => {
props.setCollectionNamerAttributes({
title: constants.CREATE_COLLECTION,
buttonText: constants.CREATE,
autoFilledName: analysisResult?.suggestedCollectionName,
autoFilledName: null,
callback: uploadToSingleNewCollection,
});
};
@ -296,7 +296,10 @@ export default function Upload(props: Props) {
isFirstUpload: boolean
) => {
if (isFirstUpload) {
uploadToSingleNewCollection(FIRST_ALBUM_NAME);
const collectionName =
analysisResult.suggestedCollectionName ?? FIRST_ALBUM_NAME;
uploadToSingleNewCollection(collectionName);
} else {
let showNextModal = () => {};
if (analysisResult.multipleFolders) {