Merge pull request #291 from ente-io/first-upload-name

use suggested name if available during first upload
This commit is contained in:
Abhinav Kumar 2022-01-13 11:14:45 +05:30 committed by GitHub
commit 8aa55eb411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) {