Skip to content

Commit

Permalink
fix navigating back to zero index
Browse files Browse the repository at this point in the history
  • Loading branch information
codyzu committed Jun 6, 2023
1 parent daa04f1 commit d330969
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/slides/use-slide-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ export function useSlideIndex({
);

const updateSlideIndex = useCallback((index?: number) => {
if (index) {
setSlideIndex(index);
// Heartbeat messages can include an index (if sent from the presentation view)
// Sometimes this gets called and there is no index (heartbeats from other views)
// Update the index if one is included.
// Use isInteger because the 0 index is a falsy value (can't just check for a truthy value)
if (Number.isInteger(index)) {
setSlideIndex(index!);
}
}, []);

Expand Down

0 comments on commit d330969

Please sign in to comment.