Merge pull request #595 from yorunning/fix

fix: hide toast when confirmation box is cancelled
This commit is contained in:
Yifei Zhang 2023-04-08 00:59:09 +08:00 committed by GitHub
commit 9afed21efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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() {