|
@@ -9,7 +9,13 @@
|
|
|
import { downloadChatAsPDF } from '$lib/apis/utils';
|
|
|
import { copyToClipboard, createMessagesList } from '$lib/utils';
|
|
|
|
|
|
- import { showOverview, showControls, showArtifacts, mobile } from '$lib/stores';
|
|
|
+ import {
|
|
|
+ showOverview,
|
|
|
+ showControls,
|
|
|
+ showArtifacts,
|
|
|
+ mobile,
|
|
|
+ temporaryChatEnabled
|
|
|
+ } from '$lib/stores';
|
|
|
import { flyAndScale } from '$lib/utils/transitions';
|
|
|
|
|
|
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
|
@@ -31,9 +37,8 @@
|
|
|
export let onClose: Function = () => {};
|
|
|
|
|
|
const getChatAsText = async () => {
|
|
|
- const _chat = chat.chat;
|
|
|
-
|
|
|
- const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
|
|
+ const history = chat.chat.history;
|
|
|
+ const messages = createMessagesList(history, history.currentId);
|
|
|
const chatText = messages.reduce((a, message, i, arr) => {
|
|
|
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
|
|
}, '');
|
|
@@ -52,12 +57,9 @@
|
|
|
};
|
|
|
|
|
|
const downloadPdf = async () => {
|
|
|
- const _chat = chat.chat;
|
|
|
- const messages = createMessagesList(_chat.history, _chat.history.currentId);
|
|
|
-
|
|
|
- console.log('download', chat);
|
|
|
-
|
|
|
- const blob = await downloadChatAsPDF(_chat.title, messages);
|
|
|
+ const history = chat.chat.history;
|
|
|
+ const messages = createMessagesList(history, history.currentId);
|
|
|
+ const blob = await downloadChatAsPDF(chat.chat.title, messages);
|
|
|
|
|
|
// Create a URL for the blob
|
|
|
const url = window.URL.createObjectURL(blob);
|
|
@@ -65,7 +67,7 @@
|
|
|
// Create a link element to trigger the download
|
|
|
const a = document.createElement('a');
|
|
|
a.href = url;
|
|
|
- a.download = `chat-${_chat.title}.pdf`;
|
|
|
+ a.download = `chat-${chat.chat.title}.pdf`;
|
|
|
|
|
|
// Append the link to the body and click it programmatically
|
|
|
document.body.appendChild(a);
|
|
@@ -189,27 +191,29 @@
|
|
|
<div class="flex items-center">{$i18n.t('Copy')}</div>
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
|
- <DropdownMenu.Item
|
|
|
- class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
|
|
|
- id="chat-share-button"
|
|
|
- on:click={() => {
|
|
|
- shareHandler();
|
|
|
- }}
|
|
|
- >
|
|
|
- <svg
|
|
|
- xmlns="http://www.w3.org/2000/svg"
|
|
|
- viewBox="0 0 24 24"
|
|
|
- fill="currentColor"
|
|
|
- class="size-4"
|
|
|
+ {#if !$temporaryChatEnabled}
|
|
|
+ <DropdownMenu.Item
|
|
|
+ class="flex gap-2 items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-md"
|
|
|
+ id="chat-share-button"
|
|
|
+ on:click={() => {
|
|
|
+ shareHandler();
|
|
|
+ }}
|
|
|
>
|
|
|
- <path
|
|
|
- fill-rule="evenodd"
|
|
|
- d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"
|
|
|
- clip-rule="evenodd"
|
|
|
- />
|
|
|
- </svg>
|
|
|
- <div class="flex items-center">{$i18n.t('Share')}</div>
|
|
|
- </DropdownMenu.Item>
|
|
|
+ <svg
|
|
|
+ xmlns="http://www.w3.org/2000/svg"
|
|
|
+ viewBox="0 0 24 24"
|
|
|
+ fill="currentColor"
|
|
|
+ class="size-4"
|
|
|
+ >
|
|
|
+ <path
|
|
|
+ fill-rule="evenodd"
|
|
|
+ d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z"
|
|
|
+ clip-rule="evenodd"
|
|
|
+ />
|
|
|
+ </svg>
|
|
|
+ <div class="flex items-center">{$i18n.t('Share')}</div>
|
|
|
+ </DropdownMenu.Item>
|
|
|
+ {/if}
|
|
|
|
|
|
<DropdownMenu.Sub>
|
|
|
<DropdownMenu.SubTrigger
|
|
@@ -265,11 +269,13 @@
|
|
|
</DropdownMenu.SubContent>
|
|
|
</DropdownMenu.Sub>
|
|
|
|
|
|
- <hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
|
|
|
+ {#if !$temporaryChatEnabled}
|
|
|
+ <hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
|
|
|
|
|
|
- <div class="flex p-1">
|
|
|
- <Tags chatId={chat.id} />
|
|
|
- </div>
|
|
|
+ <div class="flex p-1">
|
|
|
+ <Tags chatId={chat.id} />
|
|
|
+ </div>
|
|
|
+ {/if}
|
|
|
</DropdownMenu.Content>
|
|
|
</div>
|
|
|
</Dropdown>
|