Start story duration when it is a text story
This commit is contained in:
parent
11deabe959
commit
5e9744d62a
1 changed files with 14 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue