mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
668 lines
19 KiB
Svelte
668 lines
19 KiB
Svelte
<script lang="ts">
|
|
import { DropdownMenu } from 'bits-ui';
|
|
import { marked } from 'marked';
|
|
import Fuse from 'fuse.js';
|
|
|
|
import dayjs from '$lib/dayjs';
|
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
dayjs.extend(relativeTime);
|
|
|
|
import { flyAndScale } from '$lib/utils/transitions';
|
|
import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
|
|
import { goto } from '$app/navigation';
|
|
|
|
import { deleteModel, getOllamaVersion, pullModel, unloadModel } from '$lib/apis/ollama';
|
|
|
|
import {
|
|
user,
|
|
MODEL_DOWNLOAD_POOL,
|
|
models,
|
|
mobile,
|
|
temporaryChatEnabled,
|
|
settings,
|
|
config
|
|
} from '$lib/stores';
|
|
import { toast } from 'svelte-sonner';
|
|
import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils';
|
|
import { getModels } from '$lib/apis';
|
|
|
|
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
|
import Check from '$lib/components/icons/Check.svelte';
|
|
import Search from '$lib/components/icons/Search.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import ChatBubbleOval from '$lib/components/icons/ChatBubbleOval.svelte';
|
|
|
|
import ModelItem from './ModelItem.svelte';
|
|
|
|
const i18n = getContext('i18n');
|
|
const dispatch = createEventDispatcher();
|
|
|
|
export let id = '';
|
|
export let value = '';
|
|
export let placeholder = 'Select a model';
|
|
export let searchEnabled = true;
|
|
export let searchPlaceholder = $i18n.t('Search a model');
|
|
|
|
export let showTemporaryChatControl = false;
|
|
|
|
export let items: {
|
|
label: string;
|
|
value: string;
|
|
model: Model;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
[key: string]: any;
|
|
}[] = [];
|
|
|
|
export let className = 'w-[32rem]';
|
|
export let triggerClassName = 'text-lg';
|
|
|
|
export let pinModelHandler: (modelId: string) => void = () => {};
|
|
|
|
let tagsContainerElement;
|
|
|
|
let show = false;
|
|
let tags = [];
|
|
|
|
let selectedModel = '';
|
|
$: selectedModel = items.find((item) => item.value === value) ?? '';
|
|
|
|
let searchValue = '';
|
|
|
|
let selectedTag = '';
|
|
let selectedConnectionType = '';
|
|
|
|
let ollamaVersion = null;
|
|
let selectedModelIdx = 0;
|
|
|
|
const fuse = new Fuse(
|
|
items.map((item) => {
|
|
const _item = {
|
|
...item,
|
|
modelName: item.model?.name,
|
|
tags: (item.model?.tags ?? []).map((tag) => tag.name).join(' '),
|
|
desc: item.model?.info?.meta?.description
|
|
};
|
|
return _item;
|
|
}),
|
|
{
|
|
keys: ['value', 'tags', 'modelName'],
|
|
threshold: 0.4
|
|
}
|
|
);
|
|
|
|
$: filteredItems = (
|
|
searchValue
|
|
? fuse
|
|
.search(searchValue)
|
|
.map((e) => {
|
|
return e.item;
|
|
})
|
|
.filter((item) => {
|
|
if (selectedTag === '') {
|
|
return true;
|
|
}
|
|
return (item.model?.tags ?? []).map((tag) => tag.name).includes(selectedTag);
|
|
})
|
|
.filter((item) => {
|
|
if (selectedConnectionType === '') {
|
|
return true;
|
|
} else if (selectedConnectionType === 'local') {
|
|
return item.model?.connection_type === 'local';
|
|
} else if (selectedConnectionType === 'external') {
|
|
return item.model?.connection_type === 'external';
|
|
} else if (selectedConnectionType === 'direct') {
|
|
return item.model?.direct;
|
|
}
|
|
})
|
|
: items
|
|
.filter((item) => {
|
|
if (selectedTag === '') {
|
|
return true;
|
|
}
|
|
return (item.model?.tags ?? []).map((tag) => tag.name).includes(selectedTag);
|
|
})
|
|
.filter((item) => {
|
|
if (selectedConnectionType === '') {
|
|
return true;
|
|
} else if (selectedConnectionType === 'local') {
|
|
return item.model?.connection_type === 'local';
|
|
} else if (selectedConnectionType === 'external') {
|
|
return item.model?.connection_type === 'external';
|
|
} else if (selectedConnectionType === 'direct') {
|
|
return item.model?.direct;
|
|
}
|
|
})
|
|
).filter((item) => !(item.model?.info?.meta?.hidden ?? false));
|
|
|
|
$: if (selectedTag || selectedConnectionType) {
|
|
resetView();
|
|
} else {
|
|
resetView();
|
|
}
|
|
|
|
const resetView = async () => {
|
|
await tick();
|
|
|
|
const selectedInFiltered = filteredItems.findIndex((item) => item.value === value);
|
|
|
|
if (selectedInFiltered >= 0) {
|
|
// The selected model is visible in the current filter
|
|
selectedModelIdx = selectedInFiltered;
|
|
} else {
|
|
// The selected model is not visible, default to first item in filtered list
|
|
selectedModelIdx = 0;
|
|
}
|
|
|
|
await tick();
|
|
const item = document.querySelector(`[data-arrow-selected="true"]`);
|
|
item?.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
|
};
|
|
|
|
const pullModelHandler = async () => {
|
|
const sanitizedModelTag = searchValue.trim().replace(/^ollama\s+(run|pull)\s+/, '');
|
|
|
|
console.log($MODEL_DOWNLOAD_POOL);
|
|
if ($MODEL_DOWNLOAD_POOL[sanitizedModelTag]) {
|
|
toast.error(
|
|
$i18n.t(`Model '{{modelTag}}' is already in queue for downloading.`, {
|
|
modelTag: sanitizedModelTag
|
|
})
|
|
);
|
|
return;
|
|
}
|
|
if (Object.keys($MODEL_DOWNLOAD_POOL).length === 3) {
|
|
toast.error(
|
|
$i18n.t('Maximum of 3 models can be downloaded simultaneously. Please try again later.')
|
|
);
|
|
return;
|
|
}
|
|
|
|
const [res, controller] = await pullModel(localStorage.token, sanitizedModelTag, '0').catch(
|
|
(error) => {
|
|
toast.error(`${error}`);
|
|
return null;
|
|
}
|
|
);
|
|
|
|
if (res) {
|
|
const reader = res.body
|
|
.pipeThrough(new TextDecoderStream())
|
|
.pipeThrough(splitStream('\n'))
|
|
.getReader();
|
|
|
|
MODEL_DOWNLOAD_POOL.set({
|
|
...$MODEL_DOWNLOAD_POOL,
|
|
[sanitizedModelTag]: {
|
|
...$MODEL_DOWNLOAD_POOL[sanitizedModelTag],
|
|
abortController: controller,
|
|
reader,
|
|
done: false
|
|
}
|
|
});
|
|
|
|
while (true) {
|
|
try {
|
|
const { value, done } = await reader.read();
|
|
if (done) break;
|
|
|
|
let lines = value.split('\n');
|
|
|
|
for (const line of lines) {
|
|
if (line !== '') {
|
|
let data = JSON.parse(line);
|
|
console.log(data);
|
|
if (data.error) {
|
|
throw data.error;
|
|
}
|
|
if (data.detail) {
|
|
throw data.detail;
|
|
}
|
|
|
|
if (data.status) {
|
|
if (data.digest) {
|
|
let downloadProgress = 0;
|
|
if (data.completed) {
|
|
downloadProgress = Math.round((data.completed / data.total) * 1000) / 10;
|
|
} else {
|
|
downloadProgress = 100;
|
|
}
|
|
|
|
MODEL_DOWNLOAD_POOL.set({
|
|
...$MODEL_DOWNLOAD_POOL,
|
|
[sanitizedModelTag]: {
|
|
...$MODEL_DOWNLOAD_POOL[sanitizedModelTag],
|
|
pullProgress: downloadProgress,
|
|
digest: data.digest
|
|
}
|
|
});
|
|
} else {
|
|
toast.success(data.status);
|
|
|
|
MODEL_DOWNLOAD_POOL.set({
|
|
...$MODEL_DOWNLOAD_POOL,
|
|
[sanitizedModelTag]: {
|
|
...$MODEL_DOWNLOAD_POOL[sanitizedModelTag],
|
|
done: data.status === 'success'
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.log(error);
|
|
if (typeof error !== 'string') {
|
|
error = error.message;
|
|
}
|
|
|
|
toast.error(`${error}`);
|
|
// opts.callback({ success: false, error, modelName: opts.modelName });
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($MODEL_DOWNLOAD_POOL[sanitizedModelTag].done) {
|
|
toast.success(
|
|
$i18n.t(`Model '{{modelName}}' has been successfully downloaded.`, {
|
|
modelName: sanitizedModelTag
|
|
})
|
|
);
|
|
|
|
models.set(
|
|
await getModels(
|
|
localStorage.token,
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
|
)
|
|
);
|
|
} else {
|
|
toast.error($i18n.t('Download canceled'));
|
|
}
|
|
|
|
delete $MODEL_DOWNLOAD_POOL[sanitizedModelTag];
|
|
|
|
MODEL_DOWNLOAD_POOL.set({
|
|
...$MODEL_DOWNLOAD_POOL
|
|
});
|
|
}
|
|
};
|
|
|
|
onMount(async () => {
|
|
ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false);
|
|
|
|
if (items) {
|
|
tags = items
|
|
.filter((item) => !(item.model?.info?.meta?.hidden ?? false))
|
|
.flatMap((item) => item.model?.tags ?? [])
|
|
.map((tag) => tag.name);
|
|
|
|
// Remove duplicates and sort
|
|
tags = Array.from(new Set(tags)).sort((a, b) => a.localeCompare(b));
|
|
}
|
|
});
|
|
|
|
const cancelModelPullHandler = async (model: string) => {
|
|
const { reader, abortController } = $MODEL_DOWNLOAD_POOL[model];
|
|
if (abortController) {
|
|
abortController.abort();
|
|
}
|
|
if (reader) {
|
|
await reader.cancel();
|
|
delete $MODEL_DOWNLOAD_POOL[model];
|
|
MODEL_DOWNLOAD_POOL.set({
|
|
...$MODEL_DOWNLOAD_POOL
|
|
});
|
|
await deleteModel(localStorage.token, model);
|
|
toast.success(`${model} download has been canceled`);
|
|
}
|
|
};
|
|
|
|
const unloadModelHandler = async (model: string) => {
|
|
const res = await unloadModel(localStorage.token, model).catch((error) => {
|
|
toast.error($i18n.t('Error unloading model: {{error}}', { error }));
|
|
});
|
|
|
|
if (res) {
|
|
toast.success($i18n.t('Model unloaded successfully'));
|
|
models.set(
|
|
await getModels(
|
|
localStorage.token,
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
|
)
|
|
);
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<DropdownMenu.Root
|
|
bind:open={show}
|
|
onOpenChange={async () => {
|
|
searchValue = '';
|
|
window.setTimeout(() => document.getElementById('model-search-input')?.focus(), 0);
|
|
|
|
resetView();
|
|
}}
|
|
closeFocus={false}
|
|
>
|
|
<DropdownMenu.Trigger
|
|
class="relative w-full font-primary"
|
|
aria-label={placeholder}
|
|
id="model-selector-{id}-button"
|
|
>
|
|
<button
|
|
class="flex w-full text-left px-0.5 outline-hidden bg-transparent truncate {triggerClassName} justify-between font-medium placeholder-gray-400 focus:outline-hidden"
|
|
on:mouseenter={async () => {
|
|
models.set(
|
|
await getModels(
|
|
localStorage.token,
|
|
$config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
|
)
|
|
);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if selectedModel}
|
|
{selectedModel.label}
|
|
{:else}
|
|
{placeholder}
|
|
{/if}
|
|
<ChevronDown className=" self-center ml-2 size-3" strokeWidth="2.5" />
|
|
</button>
|
|
</DropdownMenu.Trigger>
|
|
|
|
<DropdownMenu.Content
|
|
class=" z-40 {$mobile
|
|
? `w-full`
|
|
: `${className}`} max-w-[calc(100vw-1rem)] justify-start rounded-xl bg-white dark:bg-gray-850 dark:text-white shadow-lg outline-hidden"
|
|
transition={flyAndScale}
|
|
side={$mobile ? 'bottom' : 'bottom-start'}
|
|
sideOffset={3}
|
|
>
|
|
<slot>
|
|
{#if searchEnabled}
|
|
<div class="flex items-center gap-2.5 px-5 mt-3.5 mb-1.5">
|
|
<Search className="size-4" strokeWidth="2.5" />
|
|
|
|
<input
|
|
id="model-search-input"
|
|
bind:value={searchValue}
|
|
class="w-full text-sm bg-transparent outline-hidden"
|
|
placeholder={searchPlaceholder}
|
|
autocomplete="off"
|
|
on:keydown={(e) => {
|
|
if (e.code === 'Enter' && filteredItems.length > 0) {
|
|
value = filteredItems[selectedModelIdx].value;
|
|
show = false;
|
|
return; // dont need to scroll on selection
|
|
} else if (e.code === 'ArrowDown') {
|
|
selectedModelIdx = Math.min(selectedModelIdx + 1, filteredItems.length - 1);
|
|
} else if (e.code === 'ArrowUp') {
|
|
selectedModelIdx = Math.max(selectedModelIdx - 1, 0);
|
|
} else {
|
|
// if the user types something, reset to the top selection.
|
|
selectedModelIdx = 0;
|
|
}
|
|
|
|
const item = document.querySelector(`[data-arrow-selected="true"]`);
|
|
item?.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
|
}}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="px-3 max-h-64 overflow-y-auto group relative">
|
|
{#if tags && items.filter((item) => !(item.model?.info?.meta?.hidden ?? false)).length > 0}
|
|
<div
|
|
class=" flex w-full sticky top-0 z-10 bg-white dark:bg-gray-850 overflow-x-auto scrollbar-none"
|
|
on:wheel={(e) => {
|
|
if (e.deltaY !== 0) {
|
|
e.preventDefault();
|
|
e.currentTarget.scrollLeft += e.deltaY;
|
|
}
|
|
}}
|
|
>
|
|
<div
|
|
class="flex gap-1 w-fit text-center text-sm font-medium rounded-full bg-transparent px-1.5 pb-0.5"
|
|
bind:this={tagsContainerElement}
|
|
>
|
|
{#if (items.find((item) => item.model?.connection_type === 'local') && items.find((item) => item.model?.connection_type === 'external')) || items.find((item) => item.model?.direct) || tags.length > 0}
|
|
<button
|
|
class="min-w-fit outline-none p-1.5 {selectedTag === '' &&
|
|
selectedConnectionType === ''
|
|
? ''
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
|
on:click={() => {
|
|
selectedConnectionType = '';
|
|
selectedTag = '';
|
|
}}
|
|
>
|
|
{$i18n.t('All')}
|
|
</button>
|
|
{/if}
|
|
|
|
{#if items.find((item) => item.model?.connection_type === 'local') && items.find((item) => item.model?.connection_type === 'external')}
|
|
<button
|
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'local'
|
|
? ''
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
|
on:click={() => {
|
|
selectedTag = '';
|
|
selectedConnectionType = 'local';
|
|
}}
|
|
>
|
|
{$i18n.t('Local')}
|
|
</button>
|
|
<button
|
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'external'
|
|
? ''
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
|
on:click={() => {
|
|
selectedTag = '';
|
|
selectedConnectionType = 'external';
|
|
}}
|
|
>
|
|
{$i18n.t('External')}
|
|
</button>
|
|
{/if}
|
|
|
|
{#if items.find((item) => item.model?.direct)}
|
|
<button
|
|
class="min-w-fit outline-none p-1.5 {selectedConnectionType === 'direct'
|
|
? ''
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
|
on:click={() => {
|
|
selectedTag = '';
|
|
selectedConnectionType = 'direct';
|
|
}}
|
|
>
|
|
{$i18n.t('Direct')}
|
|
</button>
|
|
{/if}
|
|
|
|
{#each tags as tag}
|
|
<button
|
|
class="min-w-fit outline-none p-1.5 {selectedTag === tag
|
|
? ''
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition capitalize"
|
|
on:click={() => {
|
|
selectedConnectionType = '';
|
|
selectedTag = tag;
|
|
}}
|
|
>
|
|
{tag}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
{#each filteredItems as item, index}
|
|
<ModelItem
|
|
{selectedModelIdx}
|
|
{item}
|
|
{index}
|
|
{value}
|
|
{pinModelHandler}
|
|
{unloadModelHandler}
|
|
onClick={() => {
|
|
value = item.value;
|
|
selectedModelIdx = index;
|
|
|
|
show = false;
|
|
}}
|
|
/>
|
|
{:else}
|
|
<div class="">
|
|
<div class="block px-3 py-2 text-sm text-gray-700 dark:text-gray-100">
|
|
{$i18n.t('No results found')}
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
|
|
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'}
|
|
<Tooltip
|
|
content={$i18n.t(`Pull "{{searchValue}}" from Ollama.com`, {
|
|
searchValue: searchValue
|
|
})}
|
|
placement="top-start"
|
|
>
|
|
<button
|
|
class="flex w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer data-highlighted:bg-muted"
|
|
on:click={() => {
|
|
pullModelHandler();
|
|
}}
|
|
>
|
|
<div class=" truncate">
|
|
{$i18n.t(`Pull "{{searchValue}}" from Ollama.com`, { searchValue: searchValue })}
|
|
</div>
|
|
</button>
|
|
</Tooltip>
|
|
{/if}
|
|
|
|
{#each Object.keys($MODEL_DOWNLOAD_POOL) as model}
|
|
<div
|
|
class="flex w-full justify-between font-medium select-none rounded-button py-2 pl-3 pr-1.5 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 rounded-lg cursor-pointer data-highlighted:bg-muted"
|
|
>
|
|
<div class="flex">
|
|
<div class="-ml-2 mr-2.5 translate-y-0.5">
|
|
<svg
|
|
class="size-4"
|
|
viewBox="0 0 24 24"
|
|
fill="currentColor"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
><style>
|
|
.spinner_ajPY {
|
|
transform-origin: center;
|
|
animation: spinner_AtaB 0.75s infinite linear;
|
|
}
|
|
@keyframes spinner_AtaB {
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style><path
|
|
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
|
|
opacity=".25"
|
|
/><path
|
|
d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
|
|
class="spinner_ajPY"
|
|
/></svg
|
|
>
|
|
</div>
|
|
|
|
<div class="flex flex-col self-start">
|
|
<div class="flex gap-1">
|
|
<div class="line-clamp-1">
|
|
Downloading "{model}"
|
|
</div>
|
|
|
|
<div class="shrink-0">
|
|
{'pullProgress' in $MODEL_DOWNLOAD_POOL[model]
|
|
? `(${$MODEL_DOWNLOAD_POOL[model].pullProgress}%)`
|
|
: ''}
|
|
</div>
|
|
</div>
|
|
|
|
{#if 'digest' in $MODEL_DOWNLOAD_POOL[model] && $MODEL_DOWNLOAD_POOL[model].digest}
|
|
<div class="-mt-1 h-fit text-[0.7rem] dark:text-gray-500 line-clamp-1">
|
|
{$MODEL_DOWNLOAD_POOL[model].digest}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mr-2 ml-1 translate-y-0.5">
|
|
<Tooltip content={$i18n.t('Cancel')}>
|
|
<button
|
|
class="text-gray-800 dark:text-gray-100"
|
|
on:click={() => {
|
|
cancelModelPullHandler(model);
|
|
}}
|
|
>
|
|
<svg
|
|
class="w-4 h-4 text-gray-800 dark:text-white"
|
|
aria-hidden="true"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
width="24"
|
|
height="24"
|
|
fill="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path
|
|
stroke="currentColor"
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M6 18 17.94 6M18 18 6.06 6"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
</Tooltip>
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
|
|
{#if showTemporaryChatControl}
|
|
<div class="flex items-center mx-2 mt-1 mb-2">
|
|
<button
|
|
class="flex justify-between w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 px-3 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer data-highlighted:bg-muted"
|
|
on:click={async () => {
|
|
temporaryChatEnabled.set(!$temporaryChatEnabled);
|
|
await goto('/');
|
|
const newChatButton = document.getElementById('new-chat-button');
|
|
setTimeout(() => {
|
|
newChatButton?.click();
|
|
}, 0);
|
|
|
|
// add 'temporary-chat=true' to the URL
|
|
if ($temporaryChatEnabled) {
|
|
history.replaceState(null, '', '?temporary-chat=true');
|
|
} else {
|
|
history.replaceState(null, '', location.pathname);
|
|
}
|
|
|
|
show = false;
|
|
}}
|
|
>
|
|
<div class="flex gap-2.5 items-center">
|
|
<ChatBubbleOval className="size-4" strokeWidth="2.5" />
|
|
|
|
{$i18n.t(`Temporary Chat`)}
|
|
</div>
|
|
|
|
<div>
|
|
<Switch state={$temporaryChatEnabled} />
|
|
</div>
|
|
</button>
|
|
</div>
|
|
{:else}
|
|
<div class="mb-3"></div>
|
|
{/if}
|
|
|
|
<div class="hidden w-[42rem]" />
|
|
<div class="hidden w-[32rem]" />
|
|
</slot>
|
|
</DropdownMenu.Content>
|
|
</DropdownMenu.Root>
|