Add new chat from current to chat option menu
This commit is contained in:
parent
3314252c3c
commit
2098bc7a0b
|
@ -24,7 +24,7 @@
|
||||||
import { clickOutside } from 'svelte-use-click-outside'
|
import { clickOutside } from 'svelte-use-click-outside'
|
||||||
import { openModal } from 'svelte-modals'
|
import { openModal } from 'svelte-modals'
|
||||||
import PromptConfirm from './PromptConfirm.svelte'
|
import PromptConfirm from './PromptConfirm.svelte'
|
||||||
import { startNewChatWithWarning } from './Util.svelte'
|
import { startNewChatWithWarning, startNewChatFromChatId } from './Util.svelte'
|
||||||
|
|
||||||
export let chatId
|
export let chatId
|
||||||
export const show = (showHide:boolean = true) => {
|
export const show = (showHide:boolean = true) => {
|
||||||
|
@ -123,7 +123,10 @@
|
||||||
</a>
|
</a>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
<a href={'#'} class:is-disabled={!$apiKeyStorage} on:click|preventDefault={() => { $apiKeyStorage && close(); $apiKeyStorage && startNewChatWithWarning(chatId) }} class="dropdown-item">
|
<a href={'#'} class:is-disabled={!$apiKeyStorage} on:click|preventDefault={() => { $apiKeyStorage && close(); $apiKeyStorage && startNewChatWithWarning(chatId) }} class="dropdown-item">
|
||||||
<span class="menu-icon"><Fa icon={faSquarePlus}/></span> New Chat
|
<span class="menu-icon"><Fa icon={faSquarePlus}/></span> New Chat from Default
|
||||||
|
</a>
|
||||||
|
<a href={'#'} class:is-disabled={!chatId} on:click|preventDefault={() => { chatId && close(); chatId && startNewChatFromChatId(chatId) }} class="dropdown-item">
|
||||||
|
<span class="menu-icon"><Fa icon={faSquarePlus}/></span> New Chat from Current
|
||||||
</a>
|
</a>
|
||||||
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); copyChat(chatId) }}>
|
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); copyChat(chatId) }}>
|
||||||
<span class="menu-icon"><Fa icon={faClone}/></span> Clone Chat
|
<span class="menu-icon"><Fa icon={faClone}/></span> Clone Chat
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { compare } from 'stacking-order'
|
import { compare } from 'stacking-order'
|
||||||
import { openModal } from 'svelte-modals'
|
import { openModal } from 'svelte-modals'
|
||||||
import PromptNotice from './PromptNotice.svelte'
|
import PromptNotice from './PromptNotice.svelte'
|
||||||
import { getChat } from './Storage.svelte'
|
import { addChat, getChat } from './Storage.svelte'
|
||||||
import { replace } from 'svelte-spa-router'
|
import { replace } from 'svelte-spa-router'
|
||||||
import PromptConfirm from './PromptConfirm.svelte'
|
import PromptConfirm from './PromptConfirm.svelte'
|
||||||
export const sizeTextElements = () => {
|
export const sizeTextElements = () => {
|
||||||
|
@ -115,6 +115,12 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const startNewChatFromChatId = (chatId: number) => {
|
||||||
|
const newChatId = addChat(getChat(chatId).settings)
|
||||||
|
// go to new chat
|
||||||
|
replace(`/chat/${newChatId}`)
|
||||||
|
}
|
||||||
|
|
||||||
export const startNewChatWithWarning = (activeChatId: number|undefined) => {
|
export const startNewChatWithWarning = (activeChatId: number|undefined) => {
|
||||||
if (activeChatId && getChat(activeChatId).settings.isDirty) {
|
if (activeChatId && getChat(activeChatId).settings.isDirty) {
|
||||||
openModal(PromptConfirm, {
|
openModal(PromptConfirm, {
|
||||||
|
|
Loading…
Reference in New Issue