feat(frontend): a finished action answers on the button that was pressed instead of a toast

This commit is contained in:
hh committed 2026-10-19 06:07:54 +00:00
1 parent e228d999dd
commit bca0b34636
15 files changed
+179 -73

No files matched your search

+11 -3
View File
@@ -17,6 +17,7 @@
import { formatBytes, mediaKindLabel } from "#lib/format/media.js";
import { t } from "#lib/i18n/locale.svelte.js";
import { poster } from "#lib/media/poster.js";
import { createFlash } from "#lib/stores/flash.svelte.js";
import { shareUi } from "#lib/stores/shares.svelte.js";
import { toasts } from "#lib/stores/toasts.svelte.js";
@@ -49,6 +50,7 @@
let loading = $state(false);
let saving = $state(false);
let token = 0;
const queued = createFlash<number>();
const mime = $derived(result?.state === "ready" ? (result.mime ?? "") : "");
const isImage = $derived(mime.startsWith("image/") || kind === "photo");
@@ -140,9 +142,10 @@
if (messageId === null) {
return;
}
const target = messageId;
try {
await fetchMedia(chatId, messageId);
toasts.success(t("media.queued"));
await fetchMedia(chatId, target);
queued.show(target);
} catch {
toasts.error(t("media.queueFailed"));
}
@@ -312,7 +315,12 @@
<div class="media-message">
<p>{t("media.notDownloaded")}</p>
<Button fluid onclick={queueFetch} variant="primary">
{t("media.downloadToArchive")}
{#if queued.current === messageId}
<Icon name="check" />
{t("chat.media.queued")}
{:else}
{t("media.downloadToArchive")}
{/if}
</Button>
</div>
{:else if result?.state === "missing"}