Skip to content

Commit 1474489

Browse files
author
Garrett Downs
committed
Add option to resume episode
1 parent 66997a9 commit 1474489

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/routes/episode/index.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import OptionMenu from '../../components/option-menu';
66
import AppContext from '../../contexts/appContext';
77
import { useNavKeys } from '../../hooks/useNavKeys';
88
import { usePlayerActions } from '../../hooks/usePlayer';
9+
import formatTime from '../../utils/formatTime';
910

1011
const episodeService = new EpisodeService();
1112

@@ -32,17 +33,28 @@ export default function EpisodeDetail({ episodeId }: EpisodeDetailProps) {
3233
Enter: () => console.log('episode enter pressed')
3334
});
3435

35-
const options = [
36-
{ id: 'stream', label: 'Stream' },
37-
{ id: 'markPlayed', label: 'Mark as Played' },
38-
{ id: 'markUnplayed', label: 'Mark as Unplayed' }
39-
];
36+
const getMenuOptions = () => {
37+
const options = [
38+
{ id: 'stream', label: 'Stream' }
39+
// { id: 'markPlayed', label: 'Mark as Played' },
40+
// { id: 'markUnplayed', label: 'Mark as Unplayed' }
41+
];
42+
43+
if (episode && episode.progress > 0) {
44+
options.push({ id: 'resume', label: `Resume at ${formatTime(episode.progress)}` });
45+
}
46+
47+
return options;
48+
};
4049

4150
const handleOptionSelect = (id: string) => {
4251
switch (id) {
4352
case 'stream':
4453
player.setEpisode(episode!, false);
4554
break;
55+
case 'resume':
56+
player.setEpisode(episode!, true, true);
57+
break;
4658
}
4759

4860
toggleMenu(false);
@@ -77,7 +89,7 @@ export default function EpisodeDetail({ episodeId }: EpisodeDetailProps) {
7789
{menuOpen && (
7890
<OptionMenu
7991
title="Episode Actions"
80-
options={options}
92+
options={getMenuOptions()}
8193
onSelect={handleOptionSelect}
8294
onCancel={handleOptionCancel}
8395
/>

0 commit comments

Comments
 (0)