feat(ui): add 'Unshare All Shared Chats' button to Shared Chats modal (#25848)

This commit is contained in:
G30 authored and GitHub committed 2026-06-17 03:06:41 +02:00
1 parent dfdb76cc46
commit 4584adf900
5 files changed
+114 -3

No files matched your search

@@ -2,15 +2,18 @@
import type { Writable } from 'svelte/store';
import { toast } from 'svelte-sonner';
import { getContext } from 'svelte';
import { deleteSharedChatById, getSharedChatList } from '$lib/apis/chats';
import { unshareAllChats, deleteSharedChatById, getSharedChatList } from '$lib/apis/chats';
import ChatsModal from './ChatsModal.svelte';
import UnshareAllConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
import Spinner from '../common/Spinner.svelte';
const i18n: Writable<any> = getContext('i18n');
export let show = false;
export let onUpdate = () => {};
let loading = false;
let chatList: any[] | null = null;
let page = 1;
@@ -22,6 +25,8 @@
let chatListLoading = false;
let searchDebounceTimeout: any;
let showUnshareAllConfirmDialog = false;
let filter: any = {};
$: filter = {
...(query ? { query } : {}),
@@ -97,6 +102,20 @@
}
};
const unshareAllHandler = async () => {
loading = true;
try {
await unshareAllChats(localStorage.token);
toast.success($i18n.t('All shared chats have been unshared.'));
onUpdate();
await init();
} catch (error) {
toast.error(`${error}`);
} finally {
loading = false;
}
};
const init = async () => {
chatList = await getSharedChatList(localStorage.token);
};
@@ -106,6 +125,17 @@
}
</script>
<UnshareAllConfirmDialog
bind:show={showUnshareAllConfirmDialog}
message={$i18n.t(
'Are you sure you want to unshare all shared chats? This will remove all share links.'
)}
confirmLabel={$i18n.t('Unshare All')}
on:confirm={() => {
unshareAllHandler();
}}
/>
<ChatsModal
bind:show
bind:query
@@ -123,4 +153,22 @@
}}
loadHandler={loadMoreChats}
{unshareHandler}
/>
>
<div slot="footer">
<div class="flex flex-wrap text-sm font-medium gap-1.5 mt-2 m-1 justify-end w-full">
<button
class=" px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-100 dark:outline-gray-800 rounded-3xl"
disabled={loading}
on:click={() => {
showUnshareAllConfirmDialog = true;
}}
>
{#if loading}
<Spinner className="size-4" />
{:else}
{$i18n.t('Unshare All Shared Chats')}
{/if}
</button>
</div>
</div>
</ChatsModal>