Add lastChatId, but disable use for now
This commit is contained in:
parent
69f514a69f
commit
86092afcb0
|
@ -1,9 +1,24 @@
|
|||
<script lang="ts">
|
||||
import { apiKeyStorage } from './Storage.svelte'
|
||||
import { apiKeyStorage, lastChatId, getChat, started } from './Storage.svelte'
|
||||
import Footer from './Footer.svelte'
|
||||
// import { replace } from 'svelte-spa-router'
|
||||
import { onMount } from 'svelte'
|
||||
|
||||
$: apiKey = $apiKeyStorage
|
||||
|
||||
onMount(() => {
|
||||
if (!$started) {
|
||||
$started = true
|
||||
console.log('started', apiKey, $lastChatId, getChat($lastChatId))
|
||||
if (apiKey && getChat($lastChatId)) {
|
||||
// const chatId = $lastChatId
|
||||
$lastChatId = 0
|
||||
// replace(`/chat/${chatId}`)
|
||||
}
|
||||
}
|
||||
$lastChatId = 0
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<section class="section">
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
export let pinMainMenu = writable(false) // Show menu (for mobile use)
|
||||
export let continueMessage = writable('') //
|
||||
export let currentChatMessages = writable([] as Message[])
|
||||
export let started = writable(false)
|
||||
export let currentChatId = writable(0)
|
||||
export let lastChatId = persisted('currentChatId', 0)
|
||||
|
||||
const chatDefaults = getChatDefaults()
|
||||
|
||||
|
@ -227,10 +229,12 @@
|
|||
clearTimeout(setChatTimer)
|
||||
if (!chatId) {
|
||||
currentChatId.set(0)
|
||||
lastChatId.set(0)
|
||||
currentChatMessages.set([])
|
||||
}
|
||||
setChatTimer = setTimeout(() => {
|
||||
currentChatId.set(chatId)
|
||||
lastChatId.set(chatId)
|
||||
currentChatMessages.set(getChat(chatId).messages)
|
||||
}, 10)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue