mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 07:35:19 +00:00
fix: let UploadSuccess actually render in upload modals
The auto-success useEffect in UploadModalSplat / UploadModalImage / UploadModal3D was firing on UploaderStates.success and immediately calling onClose(), which short-circuited the UploaderModalContent switch before the UploaderStates.success branch (UploadSuccess) could render. The OK button on UploadSuccess was effectively dead code. Move the success-side actions (open the gallery, fire onSuccess, close the modal) into the UploadSuccess onOk handler. The user now sees the "upload successful" dialog and can dismiss it intentionally; the gallery opens at dismissal so they can drag the freshly uploaded asset onto the canvas.
This commit is contained in:
1 parent
088edd270f
commit
35aae54d49
3 files changed
+15
-37
No files matched your search
@@ -73,17 +73,6 @@ export function UploadModal3D(props: Props) {
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (uploaderState.status === UploaderStates.success) {
|
||||
// Automatically open the global Gallery modal after a successful upload
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [uploaderState.status]);
|
||||
|
||||
const UploaderModalContent = () => {
|
||||
switch (uploaderState.status) {
|
||||
@@ -130,8 +119,12 @@ export function UploadModal3D(props: Props) {
|
||||
<UploadSuccess
|
||||
title="3D model"
|
||||
onOk={() => {
|
||||
onClose();
|
||||
// Open the gallery so the user can drag the freshly
|
||||
// uploaded model onto the canvas.
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
+5
-12
@@ -48,17 +48,6 @@ export function UploadModalImage(props: Props) {
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (uploaderState.status === UploaderStates.success) {
|
||||
// Automatically open the global Gallery modal after a successful upload
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [uploaderState.status]);
|
||||
|
||||
const UploaderModalContent = () => {
|
||||
switch (uploaderState.status) {
|
||||
@@ -94,8 +83,12 @@ export function UploadModalImage(props: Props) {
|
||||
<UploadSuccess
|
||||
title="Image"
|
||||
onOk={() => {
|
||||
onClose();
|
||||
// Open the gallery so the user can drag the freshly
|
||||
// uploaded image onto the canvas.
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
+5
-13
@@ -52,18 +52,6 @@ export function UploadModalSplat(props: Props) {
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (uploaderState.status === UploaderStates.success) {
|
||||
// Match the image / 3D-model upload flow: open the gallery so the
|
||||
// user can drag the freshly uploaded splat onto the canvas.
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [uploaderState.status]);
|
||||
|
||||
const UploaderModalContent = () => {
|
||||
switch (uploaderState.status) {
|
||||
@@ -103,8 +91,12 @@ export function UploadModalSplat(props: Props) {
|
||||
<UploadSuccess
|
||||
title="Splat"
|
||||
onOk={() => {
|
||||
onClose();
|
||||
// Open the gallery so the user can drag the freshly
|
||||
// uploaded splat onto the canvas.
|
||||
galleryModalVisibleViewMode.value = true;
|
||||
galleryModalVisibleDuringDrag.value = true;
|
||||
onSuccess(selectedCategory);
|
||||
onClose();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user