Ensure that we resolve attachments before displaying them
This commit is contained in:
parent
72f979ea1d
commit
d8708e4e73
9 changed files with 319 additions and 31 deletions
|
@ -2,7 +2,12 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
import { isGIF, isVideo } from '../types/Attachment';
|
||||
import {
|
||||
hasNotResolved,
|
||||
isDownloaded,
|
||||
isGIF,
|
||||
isVideo,
|
||||
} from '../types/Attachment';
|
||||
import { count } from './grapheme';
|
||||
import { SECOND } from './durations';
|
||||
|
||||
|
@ -12,7 +17,11 @@ const MIN_TEXT_DURATION = 3 * SECOND;
|
|||
|
||||
export async function getStoryDuration(
|
||||
attachment: AttachmentType
|
||||
): Promise<number> {
|
||||
): Promise<number | undefined> {
|
||||
if (!isDownloaded(attachment) || hasNotResolved(attachment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGIF([attachment]) || isVideo([attachment])) {
|
||||
const videoEl = document.createElement('video');
|
||||
if (!attachment.url) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue