Adds error states to story images

This commit is contained in:
Josh Perez 2022-08-03 20:38:41 -04:00 committed by GitHub
parent 782838c591
commit fcf7406dd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 158 additions and 21 deletions

View file

@ -3,6 +3,7 @@
import type { AttachmentType } from '../types/Attachment';
import {
hasFailed,
hasNotResolved,
isDownloaded,
isGIF,
@ -18,6 +19,10 @@ const MIN_TEXT_DURATION = 3 * SECOND;
export async function getStoryDuration(
attachment: AttachmentType
): Promise<number | undefined> {
if (hasFailed(attachment)) {
return DEFAULT_DURATION;
}
if (!isDownloaded(attachment) || hasNotResolved(attachment)) {
return;
}