From adff4a9fb05f193cb03c3a76117a6cd47667748f Mon Sep 17 00:00:00 2001 From: Jake Coble Date: Thu, 19 Dec 2024 10:54:23 -0500 Subject: [PATCH] Autoplay the chapter and close the hat on navigation --- src/components/molecules/player.tsx | 5 +++++ src/components/organisms/passageNavigation/index.tsx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/components/molecules/player.tsx b/src/components/molecules/player.tsx index a4682d40e..32c149450 100644 --- a/src/components/molecules/player.tsx +++ b/src/components/molecules/player.tsx @@ -23,6 +23,7 @@ import IconPlay from '~public/img/icons/icon-play-large.svg'; import useGlobalSpaceDown from '~src/lib/hooks/useGlobalSpaceDown'; import useIsAuthenticated from '~src/lib/hooks/useIsAuthenticated'; import usePlaybackSession from '~src/lib/hooks/usePlaybackSession'; +import isServerSide from '~src/lib/isServerSide'; import { PlaybackContext } from '../templates/andPlaybackContext'; import { PlayerFragment } from './__generated__/player'; @@ -79,6 +80,10 @@ const Player = ({ } }, []); + useEffect(() => { + if (!isServerSide()) session.play(); + }, [session]); + const iconColor = isBackgroundColorDark(backgroundColor) ? BaseColors.WHITE : BaseColors.DARK; diff --git a/src/components/organisms/passageNavigation/index.tsx b/src/components/organisms/passageNavigation/index.tsx index 53d40d8f6..0521b800c 100644 --- a/src/components/organisms/passageNavigation/index.tsx +++ b/src/components/organisms/passageNavigation/index.tsx @@ -132,6 +132,10 @@ export default function PassageNavigation({ } }, [selectedChapterId, chapterId, setSelectedChapterId, versions]); + useEffect(() => { + setOpen(false); + }, [selectedChapterId]); + const [selectedView, setSelectedView] = useLocalStorage<'grid' | 'list'>( 'passageNavLayout', 'grid',