From 808118d1e4623e6fad6ab8503437981eeca64636 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 4 Aug 2022 21:08:15 -0400 Subject: [PATCH] Grab new story duration whenever messageId changes --- ts/components/StoryViewer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/components/StoryViewer.tsx b/ts/components/StoryViewer.tsx index 85fd1a969c..92bed54e1f 100644 --- a/ts/components/StoryViewer.tsx +++ b/ts/components/StoryViewer.tsx @@ -196,6 +196,9 @@ export const StoryViewer = ({ setHasExpandedCaption(false); }, [messageId]); + // messageId is set as a dependency so that we can reset the story duration + // when a new story is selected in case the same story (and same attachment) + // are sequentially posted. useEffect(() => { let shouldCancel = false; (async function hydrateStoryDuration() { @@ -218,7 +221,7 @@ export const StoryViewer = ({ return () => { shouldCancel = true; }; - }, [attachment]); + }, [attachment, messageId]); const unmountRef = useRef(false); useEffect(() => {