From 5eb9b00f8d92aabb215281b3389ac942872c3849 Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Tue, 21 May 2024 18:30:31 +0100 Subject: [PATCH] refac: consolidate chat logic into single component --- src/lib/components/chat/Chat.svelte | 1052 ++++++++++++++++++++++++++ src/routes/(app)/+page.svelte | 987 +----------------------- src/routes/(app)/c/[id]/+page.svelte | 1001 +----------------------- 3 files changed, 1058 insertions(+), 1982 deletions(-) create mode 100644 src/lib/components/chat/Chat.svelte diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte new file mode 100644 index 0000000000..1701d97e65 --- /dev/null +++ b/src/lib/components/chat/Chat.svelte @@ -0,0 +1,1052 @@ + + + + + {title + ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` + : `${$WEBUI_NAME}`} + + + +{#if !chatIdProp || (loaded && chatIdProp)} +
+ 0} + {chat} + {initNewChat} + /> +
+ +
+
+ + +{/if} diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index ddb5fd35ef..3af455a94f 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -1,986 +1,5 @@ - - - - {title - ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` - : `${$WEBUI_NAME}`} - - - -
- 0} - {chat} - {initNewChat} - /> -
- -
-
- - + diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 34aa88b991..6e468b729a 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -1,1001 +1,6 @@ - - - - {title - ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` - : `${$WEBUI_NAME}`} - - - -{#if loaded} -
- 0} - initNewChat={async () => { - if (currentRequestId !== null) { - await cancelOllamaRequest(localStorage.token, currentRequestId); - currentRequestId = null; - } - - goto('/'); - }} - /> -
- -
-
- - -{/if} +