Skip to content

Commit

Permalink
Add delete all chat history button
Browse files Browse the repository at this point in the history
  • Loading branch information
tanchekwei authored and sunner committed Jul 6, 2023
1 parent 88e3e01 commit 464a120
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
31 changes: 31 additions & 0 deletions src/components/ChatSetting.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<v-list-item>
<v-btn
color="primary"
variant="outlined"
:text="$t('chat.deleteAllChatHistory')"
@click="deleteChats"
></v-btn>
</v-list-item>
<ConfirmModal ref="confirmModal" />
</template>

<script setup>
import { ref } from "vue";
import { useStore } from "vuex";
import i18n from "@/i18n";
import ConfirmModal from "@/components/ConfirmModal.vue";
const emit = defineEmits(["close-dialog"]);
const confirmModal = ref();
const store = useStore();
async function deleteChats() {
const confirm = await confirmModal.value.showModal(
"",
i18n.global.t("chat.confirmDeleteAllChatHistory"),
);
if (confirm) {
store.commit("deleteChats");
emit("close-dialog");
}
}
</script>
8 changes: 7 additions & 1 deletion src/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<v-tabs v-model="tab" direction="vertical" color="primary">
<v-tab value="general">{{ $t("settings.general") }}</v-tab>
<v-tab value="proxy">{{ $t("proxy.name") }}</v-tab>
<v-tab value="chat">{{ $t("chat.name") }}</v-tab>
<v-tab
v-for="(setting, index) in botSettings"
:key="index"
Expand Down Expand Up @@ -63,6 +64,10 @@
<component :is="proxy"></component>
</div>

<div v-if="tab == 'chat'">
<component :is="chat" @close-dialog="closeDialog"></component>
</div>

<template v-for="(setting, index) in botSettings" :key="index">
<component
v-if="tab == index"
Expand All @@ -83,6 +88,7 @@ import { useI18n } from "vue-i18n";
import { useTheme } from "vuetify";
import ProxySettings from "@/components/ProxySetting.vue";
import ChatSettings from "@/components/ChatSetting.vue";
import ChatGPTBotSettings from "@/components/BotSettings/ChatGPTBotSettings.vue";
import OpenAIAPIBotSettings from "@/components/BotSettings/OpenAIAPIBotSettings.vue";
Expand Down Expand Up @@ -129,7 +135,7 @@ const botSettings = [
];
const proxy = ProxySettings;
const chat = ChatSettings;
const languages = computed(() => [
{ name: $t("settings.system"), code: "auto" },
{ name: "Deutsch", code: "de" },
Expand Down
5 changes: 4 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"done": "Done"
},
"chat": {
"newChat": "New Chat"
"name": "Chat",
"newChat": "New Chat",
"deleteAllChatHistory": "Delete All Chat History",
"confirmDeleteAllChatHistory": "Are you sure you want to delete all chat history? This action cannot be undone."
},
"bot": {
"creatingConversation": "Creating conversation...",
Expand Down
5 changes: 4 additions & 1 deletion src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"done": "完成"
},
"chat": {
"newChat": "新对话"
"name": "对话",
"newChat": "新对话",
"deleteAllChatHistory": "删除所有对话记录",
"confirmDeleteAllChatHistory": "你确定要删除所有对话记录吗?此操作无法撤消。"
},
"bot": {
"creatingConversation": "创建新对话...",
Expand Down
16 changes: 16 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ export default createStore({
setIsChatDrawerOpen(state, isChatDrawerOpen) {
state.isChatDrawerOpen = isChatDrawerOpen;
},
deleteChats(state) {
const { favBots } = state.chats[state.currentChatIndex];
const newChats = [
{
favBots,
contexts: {},
messages: [],
threads: [],
index: 0,
title: i18n.global.t("chat.newChat"),
createdTime: new Date().getTime(),
},
];
state.chats = newChats;
state.currentChatIndex = 0;
},
},
actions: {
sendPrompt({ commit, state, dispatch }, { prompt, bots, promptIndex }) {
Expand Down

1 comment on commit 464a120

@vercel
Copy link

@vercel vercel bot commented on 464a120 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chatall – ./

chatall-llm.vercel.app
chatall-git-main-sunner.vercel.app
chatall-sunner.vercel.app

Please sign in to comment.