feat(frontend): a finished action answers on the button that was pressed instead of a toast
This commit is contained in:
1 parent
e228d999dd
commit
bca0b34636
15 files changed
+179
-73
No files matched your search
@@ -11,6 +11,7 @@
|
||||
import Spinner from "#lib/components/ui/Spinner.svelte";
|
||||
import { t } from "#lib/i18n/locale.svelte.js";
|
||||
import { poster } from "#lib/media/poster.js";
|
||||
import { createFlash } from "#lib/stores/flash.svelte.js";
|
||||
import { toasts } from "#lib/stores/toasts.svelte.js";
|
||||
|
||||
interface Props {
|
||||
@@ -24,7 +25,17 @@
|
||||
let loaded = $state(false);
|
||||
let inline = $state<InlineMedia | null>(null);
|
||||
let queuing = $state(false);
|
||||
const queued = createFlash<true>();
|
||||
|
||||
const queueIcon = $derived.by(() => {
|
||||
if (queuing) {
|
||||
return "timer";
|
||||
}
|
||||
return queued.current ? "check" : "download";
|
||||
});
|
||||
const queueLabel = $derived(
|
||||
queued.current ? t("chat.media.queued") : t("media.downloadToArchive")
|
||||
);
|
||||
const ready = $derived(inline?.state === "ready" ? inline : null);
|
||||
const isVideo = $derived(ready ? visualKind(ready.kind) === "video" : false);
|
||||
|
||||
@@ -40,7 +51,7 @@
|
||||
queuing = true;
|
||||
try {
|
||||
await fetchMedia(chatId, media.message_id);
|
||||
toasts.success(t("media.queued"));
|
||||
queued.show(true);
|
||||
} catch {
|
||||
toasts.error(t("media.queueFailed"));
|
||||
} finally {
|
||||
@@ -66,8 +77,14 @@
|
||||
<img alt={t("media.attachment")} src={ready.url}>
|
||||
</button>
|
||||
{:else if inline?.state === "not-downloaded"}
|
||||
<button class="tile placeholder" onclick={queue} type="button">
|
||||
<Icon name={queuing ? "timer" : "download"} size="1.5rem" />
|
||||
<button
|
||||
aria-label={queueLabel}
|
||||
class="tile placeholder"
|
||||
onclick={queue}
|
||||
title={queueLabel}
|
||||
type="button"
|
||||
>
|
||||
<Icon name={queueIcon} size="1.5rem" />
|
||||
</button>
|
||||
{:else if loaded}
|
||||
<div class="tile placeholder"><Icon name="photo" size="1.5rem" /></div>
|
||||
|
||||
Reference in new issue
Block a user