Grab new story duration whenever messageId changes

This commit is contained in:
Josh Perez 2022-08-04 21:08:15 -04:00 committed by GitHub
parent 726e67ce95
commit 808118d1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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<boolean>(false);
useEffect(() => {