Start story duration when it is a text story

This commit is contained in:
Josh Perez 2022-11-28 20:35:15 -05:00 committed by GitHub
parent 11deabe959
commit 5e9744d62a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,6 +22,20 @@ export async function getStoryDuration(
return DEFAULT_DURATION;
}
if (attachment.textAttachment) {
// Minimum 5 seconds. +1 second for every 15 characters past the first
// 15 characters (round up).
// For text stories that include a link, +2 seconds to the playback time.
const length = attachment.textAttachment.text
? count(attachment.textAttachment.text)
: 0;
const additionalSeconds = (Math.ceil(length / 15) - 1) * SECOND;
const linkPreviewSeconds = attachment.textAttachment.preview
? 2 * SECOND
: 0;
return DEFAULT_DURATION + additionalSeconds + linkPreviewSeconds;
}
if (!isDownloaded(attachment) || hasNotResolved(attachment)) {
return;
}
@ -56,18 +70,6 @@ export async function getStoryDuration(
return Math.min(duration, MAX_VIDEO_DURATION);
}
if (attachment.textAttachment && attachment.textAttachment.text) {
// Minimum 5 seconds. +1 second for every 15 characters past the first
// 15 characters (round up).
// For text stories that include a link, +2 seconds to the playback time.
const length = count(attachment.textAttachment.text);
const additionalSeconds = (Math.ceil(length / 15) - 1) * SECOND;
const linkPreviewSeconds = attachment.textAttachment.preview
? 2 * SECOND
: 0;
return DEFAULT_DURATION + additionalSeconds + linkPreviewSeconds;
}
if (attachment.caption) {
const length = count(attachment.caption);
const additionalSeconds = (Math.ceil(length / 15) - 1) * SECOND;