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
@@ -18,6 +18,7 @@
|
||||
import { peerName } from "#lib/format/peer.js";
|
||||
import { t } from "#lib/i18n/locale.svelte.js";
|
||||
import { accounts } from "#lib/stores/accounts.svelte.js";
|
||||
import { createFlash } from "#lib/stores/flash.svelte.js";
|
||||
import { toasts } from "#lib/stores/toasts.svelte.js";
|
||||
|
||||
interface Group {
|
||||
@@ -45,6 +46,7 @@
|
||||
let viewerItems = $state<StoryView[]>([]);
|
||||
let viewerPeerId = $state(0);
|
||||
let backfilling = $state<number | null>(null);
|
||||
const started = createFlash<number>();
|
||||
|
||||
async function load() {
|
||||
const current = token;
|
||||
@@ -150,7 +152,7 @@
|
||||
backfilling = peerId;
|
||||
try {
|
||||
await enqueueStoriesBackfill(peerId);
|
||||
toasts.success(t("stories.backfillStarted"));
|
||||
started.show(peerId);
|
||||
} catch {
|
||||
toasts.error(t("stories.backfillFailed"));
|
||||
} finally {
|
||||
@@ -178,6 +180,10 @@
|
||||
{/if}
|
||||
{:else}
|
||||
{#each groups as group (group.peerId)}
|
||||
{@const fresh = started.current === group.peerId}
|
||||
{@const backfillLabel = fresh
|
||||
? t("stories.backfillStarted")
|
||||
: t("stories.loadOlderStories")}
|
||||
<section class="group">
|
||||
<header class="group-head">
|
||||
<button
|
||||
@@ -200,14 +206,15 @@
|
||||
</span>
|
||||
</button>
|
||||
<Button
|
||||
aria-label={t("stories.loadOlderStories")}
|
||||
aria-label={backfillLabel}
|
||||
loading={backfilling === group.peerId}
|
||||
onclick={() => backfill(group.peerId)}
|
||||
round
|
||||
smaller
|
||||
title={backfillLabel}
|
||||
variant="translucent"
|
||||
>
|
||||
<Icon name="cloud-download" />
|
||||
<Icon name={fresh ? "check" : "cloud-download"} />
|
||||
</Button>
|
||||
</header>
|
||||
{#if expanded[group.peerId]}
|
||||
|
||||
Reference in new issue
Block a user