From e756c415997a5b9ac3b2a3a265b201d436e86d1c Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 26 Dec 2023 17:09:24 -0800 Subject: [PATCH] feat: chat storage migration overlay --- src/routes/(app)/+layout.svelte | 75 +++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 3b09a246..9fa117cc 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -20,6 +20,9 @@ let ollamaVersion = ''; let loaded = false; + let DB = null; + let localDBChats = []; + const getModels = async () => { let models = []; models.push( @@ -69,16 +72,13 @@ if ($user === undefined) { await goto('/auth'); } else if (['user', 'admin'].includes($user.role)) { - const DB = await openDB('Chats', 1); + DB = await openDB('Chats', 1); if (DB) { - let chats = await DB.getAllFromIndex('chats', 'timestamp'); - chats = chats.map((item, idx) => chats[chats.length - 1 - idx]); + const chats = await DB.getAllFromIndex('chats', 'timestamp'); + localDBChats = chats.map((item, idx) => chats[chats.length - 1 - idx]); - if (chats.length > 0) { - let blob = new Blob([JSON.stringify(chats)], { type: 'application/json' }); - saveAs(blob, `chat-export-${Date.now()}.json`); - } + console.log('localdb', localDBChats); } console.log(DB); @@ -103,9 +103,9 @@ {#if loaded}
{#if !['user', 'admin'].includes($user.role)} -
+
@@ -121,7 +121,7 @@
{:else if checkVersion(REQUIRED_OLLAMA_VERSION, ollamaVersion ?? '0')} -
+
@@ -164,7 +164,7 @@
+ {:else if localDBChats.length > 0} +
+
+
+
+
+ Important Update
Action Required for Chat Log Storage +
+ +
+ Saving chat logs directly to your browser's storage is no longer supported. Please + take a moment to download and delete your chat logs by clicking the button below. + Don't worry, you can easily re-import your chat logs to the backend through Settings > Chats > Import Chats. This ensures that your valuable conversations are securely saved to your backend + database. Thank you! +
+ +
+ + + +
+
+
+
+
{/if}