Add purge chat usage option
This commit is contained in:
parent
b122dfa3f3
commit
6f91286982
|
@ -17,8 +17,8 @@
|
||||||
faEye,
|
faEye,
|
||||||
faEyeSlash
|
faEyeSlash
|
||||||
} from '@fortawesome/free-solid-svg-icons/index'
|
} from '@fortawesome/free-solid-svg-icons/index'
|
||||||
import { faSquarePlus as faSquarePlusOutline } from '@fortawesome/free-regular-svg-icons/index'
|
import { faSquareMinus, faSquarePlus as faSquarePlusOutline } from '@fortawesome/free-regular-svg-icons/index'
|
||||||
import { apiKeyStorage, addChatFromJSON, chatsStorage, checkStateChange, clearChats, clearMessages, copyChat, globalStorage, setGlobalSettingValueByKey, showSetChatSettings, pinMainMenu, getChat, deleteChat } from './Storage.svelte'
|
import { apiKeyStorage, addChatFromJSON, chatsStorage, checkStateChange, clearChats, clearMessages, copyChat, globalStorage, setGlobalSettingValueByKey, showSetChatSettings, pinMainMenu, getChat, deleteChat, saveChatStore } from './Storage.svelte'
|
||||||
import { exportAsMarkdown, exportChatAsJSON } from './Export.svelte'
|
import { exportAsMarkdown, exportChatAsJSON } from './Export.svelte'
|
||||||
import { restartProfile } from './Profiles.svelte'
|
import { restartProfile } from './Profiles.svelte'
|
||||||
import { replace } from 'svelte-spa-router'
|
import { replace } from 'svelte-spa-router'
|
||||||
|
@ -106,6 +106,21 @@
|
||||||
setGlobalSettingValueByKey('hideSummarized', !$globalStorage.hideSummarized)
|
setGlobalSettingValueByKey('hideSummarized', !$globalStorage.hideSummarized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clearUsage = () => {
|
||||||
|
openModal(PromptConfirm, {
|
||||||
|
title: 'Clear Chat Usage',
|
||||||
|
message: 'Are you sure you want to clear your token usage stats for the current chat?',
|
||||||
|
class: 'is-warning',
|
||||||
|
confirmButtonClass: 'is-warning',
|
||||||
|
confirmButton: 'Clear Usage',
|
||||||
|
onConfirm: () => {
|
||||||
|
const chat = getChat(chatId)
|
||||||
|
chat.usage = {}
|
||||||
|
saveChatStore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="dropdown {style}" class:is-active={showChatMenu} use:clickOutside={() => { showChatMenu = false }}>
|
<div class="dropdown {style}" class:is-active={showChatMenu} use:clickOutside={() => { showChatMenu = false }}>
|
||||||
|
@ -139,6 +154,9 @@
|
||||||
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); clearMessages(chatId) }}>
|
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); clearMessages(chatId) }}>
|
||||||
<span class="menu-icon"><Fa icon={faEraser}/></span> Clear Chat Messages
|
<span class="menu-icon"><Fa icon={faEraser}/></span> Clear Chat Messages
|
||||||
</a>
|
</a>
|
||||||
|
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); clearUsage() }}>
|
||||||
|
<span class="menu-icon"><Fa icon={faSquareMinus}/></span> Clear Chat Usage
|
||||||
|
</a>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { close(); exportChatAsJSON(chatId) }}>
|
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { close(); exportChatAsJSON(chatId) }}>
|
||||||
<span class="menu-icon"><Fa icon={faDownload}/></span> Backup Chat JSON
|
<span class="menu-icon"><Fa icon={faDownload}/></span> Backup Chat JSON
|
||||||
|
|
Loading…
Reference in New Issue