Merge pull request #180 from Webifi/main

Fix delete all chats option and code highlighting while streaming #178
This commit is contained in:
Niek van der Maas 2023-06-14 21:59:05 +02:00 committed by GitHub
commit de64e59b6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -74,6 +74,7 @@
} }
const confirmClearChats = () => { const confirmClearChats = () => {
if (!sortedChats.length) return
close() close()
openModal(PromptConfirm, { openModal(PromptConfirm, {
title: 'Delete ALL Chat', title: 'Delete ALL Chat',
@ -148,7 +149,7 @@
<a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); delChat() }}> <a href={'#'} class="dropdown-item" class:is-disabled={!chatId} on:click|preventDefault={() => { if (chatId) close(); delChat() }}>
<span class="menu-icon"><Fa icon={faTrash}/></span> Delete Chat <span class="menu-icon"><Fa icon={faTrash}/></span> Delete Chat
</a> </a>
<a href={'#'} class="dropdown-item" on:click|preventDefault={() => { if (chatId) confirmClearChats() }}> <a href={'#'} class="dropdown-item" class:is-disabled={$chatsStorage && !$chatsStorage[0]} on:click|preventDefault={() => { confirmClearChats() }}>
<span class="menu-icon"><Fa icon={faTrashCan}/></span> Delete ALL Chats <span class="menu-icon"><Fa icon={faTrashCan}/></span> Delete ALL Chats
</a> </a>
<hr class="dropdown-divider"> <hr class="dropdown-divider">

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import Code from './Code.svelte' import Code from './Code.svelte'
import { createEventDispatcher, onMount } from 'svelte' import { afterUpdate, createEventDispatcher, onMount } from 'svelte'
import { deleteMessage, chatsStorage, deleteSummaryMessage, truncateFromMessage, submitExitingPromptsNow, saveChatStore, continueMessage } from './Storage.svelte' import { deleteMessage, chatsStorage, deleteSummaryMessage, truncateFromMessage, submitExitingPromptsNow, saveChatStore, continueMessage } from './Storage.svelte'
import { getPrice } from './Stats.svelte' import { getPrice } from './Stats.svelte'
import SvelteMarkdown from 'svelte-markdown' import SvelteMarkdown from 'svelte-markdown'
@ -37,6 +37,7 @@
let original:string let original:string
let defaultModel:Model let defaultModel:Model
let imageUrl:string let imageUrl:string
let refreshCounter = 0
onMount(() => { onMount(() => {
defaultModel = chatSettings.model defaultModel = chatSettings.model
@ -47,6 +48,10 @@
} }
}) })
afterUpdate(() => {
if (message.content.slice(-5).match(/```/)) refreshCounter++
})
const edit = () => { const edit = () => {
if (message.summarized || message.streaming || editing) return if (message.summarized || message.streaming || editing) return
editing = true editing = true
@ -224,11 +229,13 @@
{#if message.summary && !message.summary.length} {#if message.summary && !message.summary.length}
<p><b>Summarizing...</b></p> <p><b>Summarizing...</b></p>
{/if} {/if}
{#key refreshCounter}
<SvelteMarkdown <SvelteMarkdown
source={message.content} source={message.content}
options={markdownOptions} options={markdownOptions}
renderers={{ code: Code, html: Code }} renderers={{ code: Code, html: Code }}
/> />
{/key}
{#if imageUrl} {#if imageUrl}
<img src={imageUrl} alt=""> <img src={imageUrl} alt="">
{/if} {/if}

View File

@ -47,7 +47,7 @@
></div> ></div>
{:else} {:else}
<div class="level-item"> <div class="level-item">
<button on:click={() => { startNewChatWithWarning(activeChatId) }} class="panel-block button" title="Start new chat with default profile" class:is-disabled={!$apiKeyStorage} <button on:click={() => { $pinMainMenu = false; startNewChatWithWarning(activeChatId) }} class="panel-block button" title="Start new chat with default profile" class:is-disabled={!$apiKeyStorage}
><span class="greyscale mr-2"><Fa icon={faSquarePlus} /></span> New chat</button> ><span class="greyscale mr-2"><Fa icon={faSquarePlus} /></span> New chat</button>
</div> </div>
{/if} {/if}