refactor(frontend): storage panel answers in place instead of toasts, empty groups hidden, weight bar animates by transform

This commit is contained in:
hh committed 2026-10-14 03:14:51 +02:00
1 parent 55634984fd
commit 06ae3e928f
4 files changed
+110 -62

No files matched your search

@@ -21,7 +21,6 @@
import { plural } from "#lib/format/shares.js";
import { filesLabel, purgeLabel } from "#lib/format/storage.js";
import { chats } from "#lib/stores/chats.svelte.js";
import { toasts } from "#lib/stores/toasts.svelte.js";
import { ui } from "#lib/stores/ui.svelte.js";
import { isMobile } from "#lib/viewport.js";
import { goto } from "$app/navigation";
@@ -31,6 +30,7 @@
let failed = $state(false);
let busy = $state(false);
let doomed = $state<TrashItem[] | null>(null);
let problem = $state<string | null>(null);
let viewerOpen = $state(false);
let viewerIndex = $state(0);
const selected = new SvelteSet<string>();
@@ -83,6 +83,7 @@
}
function toggle(key: string) {
problem = null;
if (!selected.delete(key)) {
selected.add(key);
}
@@ -99,12 +100,13 @@
return;
}
busy = true;
problem = null;
const keys = list.map((item) => item.storage_key);
try {
await restoreFromTrash(keys);
drop(keys);
} catch {
toasts.error("Не удалось вернуть файлы");
problem = "Не удалось вернуть файлы";
} finally {
busy = false;
}
@@ -115,13 +117,14 @@
return;
}
busy = true;
problem = null;
const keys = doomed.map((item) => item.storage_key);
try {
await purgeTrash(keys);
drop(keys);
doomed = null;
} catch {
toasts.error("Не удалось удалить файлы");
problem = "Не удалось удалить файлы";
} finally {
busy = false;
}
@@ -215,7 +218,8 @@
{#if chosen.length > 0}
<SelectionBar
note={chosenGone > 0 ? `${chosenGone} не скачать заново` : undefined}
note={problem ??
(chosenGone > 0 ? `${chosenGone} не скачать заново` : undefined)}
title="{filesLabel(chosen.length)} · {formatBytes(bytesOf(chosen))}"
warn
>
@@ -240,6 +244,18 @@
<span>Вернуть</span>
</Button>
</SelectionBar>
{:else if problem && doomed === null}
<SelectionBar title={problem}>
<Button
onclick={() => {
problem = null;
}}
smaller
variant="text"
>
Понятно
</Button>
</SelectionBar>
{/if}
</div>
@@ -247,6 +263,7 @@
onOpenChange={(next) => {
if (!next) {
doomed = null;
problem = null;
}
}}
open={doomed !== null}
@@ -280,6 +297,12 @@
можно скачать из Telegram заново.
{/if}
</p>
{#if problem}
<p class="confirm warn">
<Icon name="warning" size="1.25rem" />
<span>{problem}.</span>
</p>
{/if}
{#if doomedGone > 0}
<p class="confirm warn">
<Icon name="warning" size="1.25rem" />