forked from open-webui/open-webui
		
	refac: replace timestamp field
This commit is contained in:
		
							parent
							
								
									50e8979c00
								
							
						
					
					
						commit
						b12edb4a7a
					
				
					 7 changed files with 240 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -27,6 +27,7 @@
 | 
			
		|||
	import ChatMenu from './Sidebar/ChatMenu.svelte';
 | 
			
		||||
	import ShareChatModal from '../chat/ShareChatModal.svelte';
 | 
			
		||||
	import ArchiveBox from '../icons/ArchiveBox.svelte';
 | 
			
		||||
	import ArchivedChatsModal from './Sidebar/ArchivedChatsModal.svelte';
 | 
			
		||||
 | 
			
		||||
	let show = false;
 | 
			
		||||
	let navElement;
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +43,7 @@
 | 
			
		|||
	let chatTitleEditId = null;
 | 
			
		||||
	let chatTitle = '';
 | 
			
		||||
 | 
			
		||||
	let showArchivedChatsModal = false;
 | 
			
		||||
	let showShareChatModal = false;
 | 
			
		||||
	let showDropdown = false;
 | 
			
		||||
	let isEditing = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -148,6 +150,7 @@
 | 
			
		|||
</script>
 | 
			
		||||
 | 
			
		||||
<ShareChatModal bind:show={showShareChatModal} chatId={shareChatId} />
 | 
			
		||||
<ArchivedChatsModal bind:show={showArchivedChatsModal} />
 | 
			
		||||
 | 
			
		||||
<div
 | 
			
		||||
	bind:this={navElement}
 | 
			
		||||
| 
						 | 
				
			
			@ -638,13 +641,13 @@
 | 
			
		|||
					{#if showDropdown}
 | 
			
		||||
						<div
 | 
			
		||||
							id="dropdownDots"
 | 
			
		||||
							class="absolute z-40 bottom-[70px] 4.5rem rounded-xl shadow w-[240px] bg-white dark:bg-gray-900"
 | 
			
		||||
							class="absolute z-40 bottom-[70px] rounded-lg shadow w-[240px] bg-white dark:bg-gray-900"
 | 
			
		||||
							transition:fade|slide={{ duration: 100 }}
 | 
			
		||||
						>
 | 
			
		||||
							<div class="py-2 w-full">
 | 
			
		||||
							<div class="p-1 py-2 w-full">
 | 
			
		||||
								{#if $user.role === 'admin'}
 | 
			
		||||
									<button
 | 
			
		||||
										class="flex py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
										class="flex rounded-md py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
										on:click={() => {
 | 
			
		||||
											goto('/admin');
 | 
			
		||||
											showDropdown = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -670,7 +673,7 @@
 | 
			
		|||
									</button>
 | 
			
		||||
 | 
			
		||||
									<button
 | 
			
		||||
										class="flex py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
										class="flex rounded-md py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
										on:click={() => {
 | 
			
		||||
											goto('/playground');
 | 
			
		||||
											showDropdown = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -697,7 +700,20 @@
 | 
			
		|||
								{/if}
 | 
			
		||||
 | 
			
		||||
								<button
 | 
			
		||||
									class="flex py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
									class="flex rounded-md py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
									on:click={() => {
 | 
			
		||||
										showArchivedChatsModal = true;
 | 
			
		||||
										showDropdown = false;
 | 
			
		||||
									}}
 | 
			
		||||
								>
 | 
			
		||||
									<div class=" self-center mr-3">
 | 
			
		||||
										<ArchiveBox className="size-5" strokeWidth="1.5" />
 | 
			
		||||
									</div>
 | 
			
		||||
									<div class=" self-center font-medium">{$i18n.t('Archived Chats')}</div>
 | 
			
		||||
								</button>
 | 
			
		||||
 | 
			
		||||
								<button
 | 
			
		||||
									class="flex rounded-md py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
									on:click={async () => {
 | 
			
		||||
										await showSettings.set(true);
 | 
			
		||||
										showDropdown = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -728,11 +744,11 @@
 | 
			
		|||
								</button>
 | 
			
		||||
							</div>
 | 
			
		||||
 | 
			
		||||
							<hr class=" dark:border-gray-700 m-0 p-0" />
 | 
			
		||||
							<hr class=" dark:border-gray-800 m-0 p-0" />
 | 
			
		||||
 | 
			
		||||
							<div class="py-2 w-full">
 | 
			
		||||
							<div class="p-1 py-2 w-full">
 | 
			
		||||
								<button
 | 
			
		||||
									class="flex py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
									class="flex rounded-md py-2.5 px-3.5 w-full hover:bg-gray-100 dark:hover:bg-gray-800 transition"
 | 
			
		||||
									on:click={() => {
 | 
			
		||||
										localStorage.removeItem('token');
 | 
			
		||||
										location.href = '/auth';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										60
									
								
								src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								src/lib/components/layout/Sidebar/ArchivedChatsModal.svelte
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,60 @@
 | 
			
		|||
<script lang="ts">
 | 
			
		||||
	import { toast } from 'svelte-sonner';
 | 
			
		||||
	import dayjs from 'dayjs';
 | 
			
		||||
	import { onMount, getContext } from 'svelte';
 | 
			
		||||
 | 
			
		||||
	import Modal from '$lib/components/common/Modal.svelte';
 | 
			
		||||
	import { getArchivedChatList } from '$lib/apis/chats';
 | 
			
		||||
 | 
			
		||||
	const i18n = getContext('i18n');
 | 
			
		||||
 | 
			
		||||
	export let show = false;
 | 
			
		||||
 | 
			
		||||
	let chats = [];
 | 
			
		||||
 | 
			
		||||
	onMount(async () => {
 | 
			
		||||
		chats = await getArchivedChatList(localStorage.token);
 | 
			
		||||
	});
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<Modal size="lg" bind:show>
 | 
			
		||||
	<div>
 | 
			
		||||
		<div class=" flex justify-between dark:text-gray-300 px-5 py-4">
 | 
			
		||||
			<div class=" text-lg font-medium self-center">{$i18n.t('Archived Chats')}</div>
 | 
			
		||||
			<button
 | 
			
		||||
				class="self-center"
 | 
			
		||||
				on:click={() => {
 | 
			
		||||
					show = false;
 | 
			
		||||
				}}
 | 
			
		||||
			>
 | 
			
		||||
				<svg
 | 
			
		||||
					xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
					viewBox="0 0 20 20"
 | 
			
		||||
					fill="currentColor"
 | 
			
		||||
					class="w-5 h-5"
 | 
			
		||||
				>
 | 
			
		||||
					<path
 | 
			
		||||
						d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
 | 
			
		||||
					/>
 | 
			
		||||
				</svg>
 | 
			
		||||
			</button>
 | 
			
		||||
		</div>
 | 
			
		||||
		<hr class=" dark:border-gray-850" />
 | 
			
		||||
 | 
			
		||||
		<div class="flex flex-col md:flex-row w-full px-5 py-4 md:space-x-4 dark:text-gray-200">
 | 
			
		||||
			<div class=" flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6">
 | 
			
		||||
				{#if chats.length > 0}
 | 
			
		||||
					<div class="text-left text-sm w-full mb-8">
 | 
			
		||||
						{#each chats as chat}
 | 
			
		||||
							<div>
 | 
			
		||||
								{JSON.stringify(chat)}
 | 
			
		||||
							</div>
 | 
			
		||||
						{/each}
 | 
			
		||||
					</div>
 | 
			
		||||
				{:else}
 | 
			
		||||
					<div class="text-left text-sm w-full mb-8">You have no archived conversations.</div>
 | 
			
		||||
				{/if}
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</Modal>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue