feat(userbot,api,frontend): backfill stories and unbreak all-stories list

This commit is contained in:
hh committed 2026-08-06 14:08:10 +02:00
1 parent 1e143c7573
commit 12cc7d57e3
11 files changed
+326 -102

No files matched your search

@@ -1,16 +1,23 @@
<script lang="ts">
import { untrack } from "svelte";
import { getChat, getPeers, getStories } from "$lib/api/endpoints";
import {
enqueueStoriesBackfill,
getChat,
getPeers,
getStories,
} from "$lib/api/endpoints";
import { loadStoryMedia } from "$lib/api/stories";
import type { StoryView } from "$lib/api/types";
import StoryViewer from "$lib/components/stories/StoryViewer.svelte";
import Avatar from "$lib/components/ui/Avatar.svelte";
import Button from "$lib/components/ui/Button.svelte";
import EmptyState from "$lib/components/ui/EmptyState.svelte";
import Icon from "$lib/components/ui/Icon.svelte";
import Spinner from "$lib/components/ui/Spinner.svelte";
import { peerName } from "$lib/format/peer";
import { poster } from "$lib/media/poster";
import { accounts } from "$lib/stores/accounts.svelte";
import { toasts } from "$lib/stores/toasts.svelte";
interface Group {
hasAvatar: boolean;
@@ -31,12 +38,13 @@
let viewerIndex = $state(0);
let viewerItems = $state<StoryView[]>([]);
let viewerPeerId = $state(0);
let backfilling = $state<number | null>(null);
async function load() {
const current = token;
loading = true;
try {
const stories = await getStories(0, { limit: FETCH_LIMIT });
const stories = await getStories(null, { limit: FETCH_LIMIT });
if (current !== token) {
return;
}
@@ -127,6 +135,21 @@
};
});
async function backfill(peerId: number) {
if (backfilling !== null) {
return;
}
backfilling = peerId;
try {
await enqueueStoriesBackfill(peerId);
toasts.success("Загружаем старые сторис");
} catch {
toasts.error("Не удалось запустить загрузку сторис");
} finally {
backfilling = null;
}
}
function openViewer(group: Group, index: number) {
viewerItems = group.stories;
viewerPeerId = group.peerId;
@@ -154,6 +177,16 @@
/>
<span class="group-name">{group.name}</span>
<span class="group-count">{group.stories.length}</span>
<Button
variant="translucent"
round
smaller
loading={backfilling === group.peerId}
onclick={() => backfill(group.peerId)}
aria-label="Загрузить старые сторис"
>
<Icon name="cloud-download" />
</Button>
</header>
<div class="grid">
{#each group.stories as item, index (item.story_id)}