Skip to content

Commit

Permalink
chore: components/Listen/Listen.react.tsx :: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
12ya committed Oct 19, 2023
1 parent 9c0e624 commit df99231
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions js/components/Listen/Listen.react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,29 @@ import {genProgressForLesson} from '../../persistence';
import {log} from '../../metrics';
import {useSetStatusBarStyle} from '../../hooks/useStatusBarStyle';

const Listen = (props: any) => {
interface Props {
route: {
params: {
course: Course;
lesson: number;
};
};
navigation: {
pop: () => void;
};
}

const Listen = (props: Props) => {
const {course, lesson} = props.route.params;

const [bottomSheetOpen, setBottomSheetOpen] = useState(false);

const playbackState = usePlaybackState();
const playing = playbackState === State.Playing;

// go back to the previous screen when the user stops
// the music from outside the app
useTrackPlayerEvents([Event.RemoteStop], () =>
props.navigation.pop(),
);
useTrackPlayerEvents([Event.RemoteStop], () => props.navigation.pop());

// adjust the status bar style according to the course colors,
// and the bottom sheet visibility
Expand All @@ -39,11 +50,7 @@ const Listen = (props: any) => {
((navBarLight ? 'dark' : 'light') + '-content') as StatusBarStyle,
navBarLight,
);
}, [
setStatusBarStyle,
bottomSheetOpen,
course,
]);
}, [setStatusBarStyle, bottomSheetOpen, course]);

// load & queue audio file, find the last heard offset, and start
// the lesson
Expand Down Expand Up @@ -114,7 +121,7 @@ const Listen = (props: any) => {
position: await TrackPlayer.getPosition(),
});

TrackPlayer.seekTo(Math.max(0, await TrackPlayer.getPosition() - 10));
TrackPlayer.seekTo(Math.max(0, (await TrackPlayer.getPosition()) - 10));
};

return (
Expand Down

0 comments on commit df99231

Please sign in to comment.