Merge pull request #817 from ente-io/fix-upload-cancel-upload

Fix upload cancel on collection-selector screen lead to bad state , and no new uploads were accepted
This commit is contained in:
Abhinav Kumar 2022-12-13 13:44:34 +05:30 committed by GitHub
commit f12ad15d96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View file

@ -14,6 +14,7 @@ export interface CollectionSelectorAttributes {
showNextModal: () => void;
title: string;
fromCollection?: number;
onCancel?: () => void;
}
interface Props {
@ -61,7 +62,10 @@ function CollectionSelector({
props.onClose();
};
const onCloseButtonClick = () => props.onClose(true);
const onCloseButtonClick = () => {
attributes?.onCancel();
props.onClose(true);
};
return (
<AllCollectionDialog

View file

@ -118,6 +118,14 @@ export default function Uploader(props: Props) {
const uploadRunning = useRef(false);
const handleChoiceModalClose = () => {
setChoiceModalView(false);
uploadRunning.current = false;
};
const handleCollectionSelectorCancel = () => {
uploadRunning.current = false;
};
useEffect(() => {
UploadManager.init(
{
@ -530,6 +538,7 @@ export default function Uploader(props: Props) {
}
props.setCollectionSelectorAttributes({
callback: uploadFilesToExistingCollection,
onCancel: handleCollectionSelectorCancel,
showNextModal,
title: constants.UPLOAD_TO_COLLECTION,
});
@ -583,7 +592,7 @@ export default function Uploader(props: Props) {
<>
<UploadStrategyChoiceModal
open={choiceModalView}
onClose={() => setChoiceModalView(false)}
onClose={handleChoiceModalClose}
uploadToSingleCollection={() =>
uploadToSingleNewCollection(importSuggestion.rootFolderName)
}

View file

@ -298,7 +298,7 @@ class watchFolderService {
file: EnteFile
) {
addLocalLog(() => `onFileUpload called`);
if (!this.isUploadRunning) {
if (!this.isUploadRunning()) {
return;
}
if (