Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Disable session deletion when AI is busy
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Feb 12, 2024
1 parent d12cb2c commit 1206152
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
28 changes: 16 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,22 @@ const App = () => {
};

const handleDeleteSession = (id: string) => {
sendUserConfirm(t("App.handleDeleteSession.confirm_message"), {
title: t("App.handleDeleteSession.confirm_title"),
confirmText: t("App.handleDeleteSession.confirm_button"),
cancelText: t("App.handleDeleteSession.cancel_button"),
onConfirmed: () => {
navigate(routes.index.prefix);
const _sessions = { ...sessions };
delete _sessions[id];
dispatch(updateSessions(_sessions));
sendUserAlert(t("App.handleDeleteSession.on_confirmed"));
},
});
if (!ai.busy) {
sendUserConfirm(t("App.handleDeleteSession.confirm_message"), {
title: t("App.handleDeleteSession.confirm_title"),
confirmText: t("App.handleDeleteSession.confirm_button"),
cancelText: t("App.handleDeleteSession.cancel_button"),
onConfirmed: () => {
navigate(routes.index.prefix);
const _sessions = { ...sessions };
delete _sessions[id];
dispatch(updateSessions(_sessions));
sendUserAlert(t("App.handleDeleteSession.on_confirmed"));
},
});
} else {
sendUserAlert(t("App.handleDeleteSession.not_available"), true);
}
};

const handlePurgeSessions = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"export_failed": "Failed to export the conversation transcript"
},
"handleDeleteSession": {
"not_available": "AI is currently busy, please try deleting later",
"confirm_message": "Are you sure you want to delete this conversation history?",
"confirm_title": "Confirm action",
"confirm_button": "OK",
Expand Down Expand Up @@ -112,4 +113,4 @@
"no_history_chat": "No history chat"
}
}
}
}
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"export_failed": "无法导出对话记录"
},
"handleDeleteSession": {
"not_available": "AI 正忙,请稍后再尝试删除",
"confirm_message": "确定要删除这则对话记录吗?",
"confirm_title": "确认操作",
"confirm_button": "确认",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"export_failed": "無法匯出對話紀錄"
},
"handleDeleteSession": {
"confirm_message": "確定要刪除這條對話紀錄嗎?",
"not_available": "AI 正忙,請稍後再刪除",
"confirm_message": "確定要刪除這則對話紀錄嗎?",
"confirm_title": "確認操作",
"confirm_button": "確定",
"cancel_button": "取消",
Expand Down

0 comments on commit 1206152

Please sign in to comment.