fix(api,frontend): render files by name without fetching, previewable share links
This commit is contained in:
1 parent
ef739838a5
commit
e833de245a
13 files changed
+348
-45
No files matched your search
@@ -21,9 +21,11 @@ export type InlineMedia =
|
||||
export interface ViewerItem {
|
||||
downloaded: boolean;
|
||||
fileName: string | null;
|
||||
fileSize: number | null;
|
||||
kind: string;
|
||||
mediaId: number | null;
|
||||
messageId: number;
|
||||
mime: string | null;
|
||||
}
|
||||
|
||||
export function viewerItemsFrom(
|
||||
@@ -32,7 +34,15 @@ export function viewerItemsFrom(
|
||||
): ViewerItem[] {
|
||||
if (media.length === 0) {
|
||||
return [
|
||||
{ messageId, mediaId: null, kind: "", downloaded: false, fileName: null },
|
||||
{
|
||||
messageId,
|
||||
mediaId: null,
|
||||
kind: "",
|
||||
downloaded: false,
|
||||
fileName: null,
|
||||
fileSize: null,
|
||||
mime: null,
|
||||
},
|
||||
];
|
||||
}
|
||||
return media.map((item) => ({
|
||||
@@ -41,9 +51,31 @@ export function viewerItemsFrom(
|
||||
kind: item.kind,
|
||||
downloaded: item.downloaded,
|
||||
fileName: item.file_name,
|
||||
fileSize: item.file_size,
|
||||
mime: item.mime,
|
||||
}));
|
||||
}
|
||||
|
||||
const PREVIEW_KINDS = new Set([
|
||||
"photo",
|
||||
"video",
|
||||
"video_note",
|
||||
"animation",
|
||||
"gif",
|
||||
"sticker",
|
||||
"voice",
|
||||
"audio",
|
||||
]);
|
||||
|
||||
const PREVIEW_MIME_PREFIXES = ["image/", "video/", "audio/"];
|
||||
|
||||
export function isPreviewable(kind: string, mime: string | null): boolean {
|
||||
if (PREVIEW_KINDS.has(kind)) {
|
||||
return true;
|
||||
}
|
||||
return PREVIEW_MIME_PREFIXES.some((prefix) => mime?.startsWith(prefix));
|
||||
}
|
||||
|
||||
export type VisualKind = "image" | "video" | "other";
|
||||
|
||||
const VIDEO_KINDS = new Set(["video", "video_note", "animation", "gif"]);
|
||||
|
||||
Reference in new issue
Block a user