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
@@ -6,6 +6,7 @@
|
||||
import { accounts } from "#lib/stores/accounts.svelte.js";
|
||||
import { chats } from "#lib/stores/chats.svelte.js";
|
||||
import { discover } from "#lib/stores/discover.svelte.js";
|
||||
import { createFlash } from "#lib/stores/flash.svelte.js";
|
||||
import { toasts } from "#lib/stores/toasts.svelte.js";
|
||||
|
||||
interface Props {
|
||||
@@ -15,6 +16,7 @@
|
||||
let { chatId }: Props = $props();
|
||||
|
||||
let busy = $state(false);
|
||||
const started = createFlash<true>();
|
||||
|
||||
const item = $derived(discover.get(chatId));
|
||||
const tracked = $derived(item?.tracked ?? false);
|
||||
@@ -34,7 +36,7 @@
|
||||
busy = true;
|
||||
try {
|
||||
discover.set(await trackChat(chatId, true));
|
||||
toasts.success(t("track.started"));
|
||||
started.show(true);
|
||||
chats.refresh();
|
||||
} catch {
|
||||
toasts.error(t("track.failed"));
|
||||
@@ -50,7 +52,7 @@
|
||||
busy = true;
|
||||
try {
|
||||
await enqueueBackfill(chatId, true, true);
|
||||
toasts.success(t("jobs.backfillStarted"));
|
||||
started.show(true);
|
||||
} catch {
|
||||
toasts.error(t("jobs.backfillFailed"));
|
||||
} finally {
|
||||
@@ -67,8 +69,10 @@
|
||||
<div class="actions">
|
||||
{#if tracked}
|
||||
<Button loading={busy} onclick={backfill} pill variant="secondary">
|
||||
<Icon name="cloud-download" />
|
||||
<span>{t("track.loadHistory")}</span>
|
||||
<Icon name={started.current ? "check" : "cloud-download"} />
|
||||
<span
|
||||
>{started.current ? t("track.loading") : t("track.loadHistory")}</span
|
||||
>
|
||||
</Button>
|
||||
{:else}
|
||||
<Button loading={busy} onclick={track} pill variant="primary">
|
||||
|
||||
Reference in new issue
Block a user