Ver Fonte

Merge pull request #595 from yorunning/fix

fix: hide toast when confirmation box is cancelled
Yifei Zhang há 1 ano atrás
pai
commit
9afed21efd
1 ficheiros alterados com 12 adições e 11 exclusões
  1. 12 11
      app/store/app.ts

+ 12 - 11
app/store/app.ts

@@ -332,18 +332,19 @@ export const useChatStore = create<ChatStore>()(
         const isLastSession = get().sessions.length === 1;
         if (!isMobileScreen() || confirm(Locale.Home.DeleteChat)) {
           get().removeSession(index);
+          
+          showToast(Locale.Home.DeleteToast, {
+            text: Locale.Home.Revert,
+            onClick() {
+              set((state) => ({
+                sessions: state.sessions
+                  .slice(0, index)
+                  .concat([deletedSession])
+                  .concat(state.sessions.slice(index + Number(isLastSession))),
+              }));
+            },
+          });
         }
-        showToast(Locale.Home.DeleteToast, {
-          text: Locale.Home.Revert,
-          onClick() {
-            set((state) => ({
-              sessions: state.sessions
-                .slice(0, index)
-                .concat([deletedSession])
-                .concat(state.sessions.slice(index + Number(isLastSession))),
-            }));
-          },
-        });
       },
 
       currentSession() {