View next unread story improvements
This commit is contained in:
parent
9d3498d938
commit
84411fee38
5 changed files with 36 additions and 4 deletions
|
@ -58,6 +58,7 @@ export type PropsType = {
|
|||
recentEmojis?: Array<string>;
|
||||
renderEmojiPicker: (props: RenderEmojiPickerProps) => JSX.Element;
|
||||
replyState?: ReplyStateType;
|
||||
selectedStoryIndex: number;
|
||||
skinTone?: number;
|
||||
stories: Array<StoryViewType>;
|
||||
views?: Array<string>;
|
||||
|
@ -87,11 +88,13 @@ export const StoryViewer = ({
|
|||
recentEmojis,
|
||||
renderEmojiPicker,
|
||||
replyState,
|
||||
selectedStoryIndex,
|
||||
skinTone,
|
||||
stories,
|
||||
views,
|
||||
}: PropsType): JSX.Element => {
|
||||
const [currentStoryIndex, setCurrentStoryIndex] = useState(0);
|
||||
const [currentStoryIndex, setCurrentStoryIndex] =
|
||||
useState(selectedStoryIndex);
|
||||
const [storyDuration, setStoryDuration] = useState<number | undefined>();
|
||||
|
||||
const visibleStory = stories[currentStoryIndex];
|
||||
|
@ -140,6 +143,13 @@ export const StoryViewer = ({
|
|||
setHasExpandedCaption(false);
|
||||
}, [messageId]);
|
||||
|
||||
// In case we want to change the story we're viewing from 0 -> N
|
||||
useEffect(() => {
|
||||
if (selectedStoryIndex) {
|
||||
setCurrentStoryIndex(selectedStoryIndex);
|
||||
}
|
||||
}, [selectedStoryIndex]);
|
||||
|
||||
// Either we show the next story in the current user's stories or we ask
|
||||
// for the next user's stories.
|
||||
const showNextStory = useCallback(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue