feat(userbot,api,frontend): file links, media downloads, story hold-pause, drop scheduled dupes
This commit is contained in:
1 parent
683b9a31a3
commit
3e08698b62
38 files changed
+2889
-134
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { downloadMedia } from "$lib/api/download";
|
||||
import { getChatMedia } from "$lib/api/endpoints";
|
||||
import {
|
||||
type InlineMedia,
|
||||
@@ -19,6 +20,8 @@
|
||||
import { formatBytes, mediaKindLabel } from "$lib/format/media";
|
||||
import { poster } from "$lib/media/poster";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
import { shareUi } from "$lib/stores/shares.svelte";
|
||||
import { toasts } from "$lib/stores/toasts.svelte";
|
||||
import { ui } from "$lib/stores/ui.svelte";
|
||||
import { isMobile } from "$lib/viewport";
|
||||
|
||||
@@ -46,9 +49,26 @@
|
||||
mediaId: item.id,
|
||||
kind: item.kind,
|
||||
downloaded: item.downloaded,
|
||||
fileName: item.file_name,
|
||||
}))
|
||||
);
|
||||
|
||||
function displayName(item: MediaView): string {
|
||||
return item.file_name ?? mediaKindLabel(item.kind) ?? "Файл";
|
||||
}
|
||||
|
||||
async function save(item: MediaView) {
|
||||
try {
|
||||
await downloadMedia(item.id);
|
||||
} catch {
|
||||
toasts.error("Не удалось скачать файл");
|
||||
}
|
||||
}
|
||||
|
||||
function share(item: MediaView) {
|
||||
shareUi.share({ kind: "media", mediaId: item.id }, displayName(item));
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
if (loading || done) {
|
||||
return;
|
||||
@@ -113,6 +133,7 @@
|
||||
kind: item.kind,
|
||||
downloaded: item.downloaded,
|
||||
mime: item.mime,
|
||||
file_name: item.file_name,
|
||||
file_size: item.file_size,
|
||||
ttl_seconds: item.ttl_seconds,
|
||||
duration: null,
|
||||
@@ -197,6 +218,14 @@
|
||||
<ContextMenuItem icon="reply" onselect={() => jump(item.message_id)}
|
||||
>Перейти к сообщению</ContextMenuItem
|
||||
>
|
||||
{#if item.downloaded}
|
||||
<ContextMenuItem icon="download" onselect={() => save(item)}
|
||||
>Скачать файл</ContextMenuItem
|
||||
>
|
||||
<ContextMenuItem icon="allow-share" onselect={() => share(item)}
|
||||
>Доступ по ссылке</ContextMenuItem
|
||||
>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</ContextMenu>
|
||||
{/each}
|
||||
@@ -215,7 +244,7 @@
|
||||
>
|
||||
<span class="file-icon"><Icon name="document" /></span>
|
||||
<span class="meta">
|
||||
<span class="name">{mediaKindLabel(item.kind)}</span>
|
||||
<span class="name">{displayName(item)}</span>
|
||||
<span class="sub">
|
||||
{formatListDate(item.created_at)}
|
||||
{#if item.file_size}
|
||||
@@ -232,6 +261,14 @@
|
||||
<ContextMenuItem icon="reply" onselect={() => jump(item.message_id)}
|
||||
>Перейти к сообщению</ContextMenuItem
|
||||
>
|
||||
{#if item.downloaded}
|
||||
<ContextMenuItem icon="download" onselect={() => save(item)}
|
||||
>Скачать файл</ContextMenuItem
|
||||
>
|
||||
<ContextMenuItem icon="allow-share" onselect={() => share(item)}
|
||||
>Доступ по ссылке</ContextMenuItem
|
||||
>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</ContextMenu>
|
||||
</li>
|
||||
|
||||
Reference in new issue
Block a user