about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOllie H <renahlee@outlook.com>2023-05-11 08:38:10 -0700
committerGitHub <noreply@github.com>2023-05-11 10:38:10 -0500
commit0192923ef3a13468d6a3cb86793c31af5e693335 (patch)
tree7be2aabc2c36893d6e6f85062f8078bb401aeaa4 /src
parentc2fb4d4b4b584bb109fa83be750b11e6190f61d6 (diff)
downloadvoidsky-0192923ef3a13468d6a3cb86793c31af5e693335.tar.zst
Only allow one close draft confirmation at a time (#611)
* Only allow one close draft confirmation at a time

* lint
Diffstat (limited to 'src')
-rw-r--r--src/view/com/composer/Composer.tsx10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index 5c7594d61..3891fa268 100644
--- a/src/view/com/composer/Composer.tsx
+++ b/src/view/com/composer/Composer.tsx
@@ -91,7 +91,13 @@ export const ComposePost = observer(function ComposePost({
   const onEscape = useCallback(
     (e: KeyboardEvent) => {
       if (e.key === 'Escape') {
-        store.shell.openModal({
+        const {shell} = store
+
+        if (shell.activeModals.some(modal => modal.name === 'confirm')) {
+          store.shell.closeModal()
+        }
+
+        shell.openModal({
           name: 'confirm',
           title: 'Cancel draft',
           onPressConfirm: onClose,
@@ -102,7 +108,7 @@ export const ComposePost = observer(function ComposePost({
         })
       }
     },
-    [store.shell, onClose],
+    [store, onClose],
   )
 
   useEffect(() => {