Skip to content

Commit

Permalink
Cue position
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvarado91 committed Mar 18, 2024
1 parent aa6dc1a commit 5463a58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/client/EpisodesScreen/EpisodeModalSheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import {
usePlayerEpisodeDuration,
usePlayerLoadingStatus,
usePlayerActions,
usePlayerCuePosition,
} from "../PlayerStore";
import { useGetEpisode } from "../useEpisodeHooks";
import Sheet from "react-modal-sheet";
import create from "zustand";
import { trpc } from "@/utils/trpc";
import { cn } from "@/lib/utils";
import { EpisodeTrackProjection } from "@/server/router";

interface EpisodeModalSheetStore {
isOpen: boolean;
Expand Down Expand Up @@ -114,6 +116,7 @@ function EpisodeSheetContent({ episodeId }: { episodeId: string }) {

function EpisodeTracksList({ episodeId }: { episodeId: string }) {
const progress = usePlayerProgress();
const playerActions = usePlayerActions();
const progressSecs = progress / 1000;

const { data, status } = trpc["episode.getTracks"].useQuery({
Expand All @@ -129,6 +132,12 @@ function EpisodeTracksList({ episodeId }: { episodeId: string }) {

const currentTrack = possibleTracks.at(-1);

function onTrckClick(t: EpisodeTrackProjection) {
if (t.timestamp) {
playerActions.setCuePosition(t.timestamp * 1000);
}
}

return loaded && loadedData.length > 0 ? (
<>
<div className="py-1" />
Expand All @@ -141,8 +150,11 @@ function EpisodeTracksList({ episodeId }: { episodeId: string }) {
{loadedData.map((t, i) => {
const isCurrent = currentTrack?.order === t.order;
return (
<div className="flex justify-between items-center px-4 py-2 space-x-4">
<div className="flex items-center space-x-3">
<button
onClick={() => onTrckClick(t)}
className="flex w-full justify-between items-center px-4 py-2 space-x-4"
>
<div className="flex text-left items-center space-x-3">
<div
className={cn(
"text-xs h-5 w-5 inline-flex p-1 items-center justify-center relative",
Expand Down Expand Up @@ -178,7 +190,7 @@ function EpisodeTracksList({ episodeId }: { episodeId: string }) {
) : (
<></>
)}
</div>
</button>
);
})}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function episodeTrackProjection(t: EpisodeTrack) {
order: t.order,
name: t.name,
artist: t.artist,
timestamp: t.timestamp,
...(t.timestamp ? { timestamp: t.timestamp } : null),
} as const;
}

Expand Down

0 comments on commit 5463a58

Please sign in to comment.