Browse Source

add try catch for release dialog

ruiyi.jiang 2 years ago
parent
commit
efad670fbc
1 changed files with 13 additions and 8 deletions
  1. 13 8
      client/src/components/dialogs/ReleaseCollectionDialog.tsx

+ 13 - 8
client/src/components/dialogs/ReleaseCollectionDialog.tsx

@@ -25,14 +25,19 @@ const ReleaseCollectionDialog = (props: any) => {
   const handleConfirm = async () => {
     // disable confirm button
     setDisabled(true);
-    // release collection
-    await CollectionHttp.releaseCollection(collection);
-    // enable confirm button
-    setDisabled(false);
-    // close dialog
-    handleCloseDialog();
-    // execute callback
-    onRelease && onRelease();
+    try {
+      // release collection
+      await CollectionHttp.releaseCollection(collection);
+      // execute callback
+      onRelease && onRelease();
+      // enable confirm button
+      setDisabled(false);
+      // close dialog
+      handleCloseDialog();
+    } finally {
+      // enable confirm button
+      setDisabled(false);
+    }
   };
 
   return (