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