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
12 changed files with 158 additions and 21 deletions
+5
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;
}