Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions components/Cast/Cast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { TrackMetadata } from '@/types/Track';
import Like from './Like';
import Share from './Share';
import { Separator } from '@/components/ui/separator';
import { timeFromNow } from '@/lib/utils';
import UpvoteDownvote from '../UpvoteDownvote';
import { isNil } from 'lodash';
import CollectButton from './CollectButton';
Expand Down Expand Up @@ -44,11 +43,11 @@ const Cast = ({ cast = {} as SupabasePost }: { cast: SupabasePost }) => {
return (
<div className="w-full space-y-4 ">
<div className="flex gap-2">
<UserDetails user={author} hasHypersub={!isNil(cast.hypersub_subscribed_since)} />
<span className="text-sm leading-none text-muted-foreground">
{'• '}
{timeFromNow(cast.created_at)}
</span>
<UserDetails
user={author}
hasHypersub={!isNil(cast.hypersub_subscribed_since)}
createdAt={cast.created_at}
/>
</div>

<MediaPlayer metadata={metadata} />
Expand Down
15 changes: 12 additions & 3 deletions components/GlobalPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { usePlayer } from '@/providers/audio/PlayerProvider';
import Image from 'next/image';
import Scrubber from '@/components/Scrubber';
import PlayerButtons from './PlayerButtons';
import { Button } from './ui/button';
import { Cross1Icon } from '@radix-ui/react-icons';

export default function GlobalPlayer() {
const [player] = usePlayer();
const [player, dispatch] = usePlayer();
const { metadata } = player;

if (!metadata) return <></>;
Expand All @@ -16,6 +18,13 @@ export default function GlobalPlayer() {
className="sticky bottom-0 left-0 mt-auto w-screen space-y-6 overflow-hidden bg-white py-3 shadow-2xl shadow-black"
>
<div className="container relative flex items-center gap-3">
<Button
variant="ghost"
className="h-auto rounded-full p-2"
onClick={() => dispatch({ type: 'STOP' })}
>
<Cross1Icon />
</Button>
<div className="relative my-auto size-16 overflow-hidden rounded-lg shadow-md">
<Image
src={metadata.artworkUrl}
Expand All @@ -26,15 +35,15 @@ export default function GlobalPlayer() {
/>
</div>

<div className=" max-w-[33%] space-y-0.5 self-center">
<div className="max-w-[33%] space-y-0.5 self-center">
<div className="line-clamp-2 text-sm font-bold">{metadata.trackName}</div>
<div className="line-clamp-2 text-xs font-extralight text-muted-foreground">
{metadata.artistName}
</div>
</div>
<div className="absolute left-1/4 w-full">
<div className="ml-6 flex max-w-2xl grow flex-col items-center gap-1">
{metadata && <PlayerButtons metadata={metadata} />}
<PlayerButtons metadata={metadata} />
<Scrubber className="w-full max-md:hidden" />
</div>
</div>
Expand Down
13 changes: 11 additions & 2 deletions components/UserDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { User } from '@neynar/nodejs-sdk/build/neynar-api/v2';
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar';
import { cn } from '@/lib/utils';
import { cn, timeFromNow } from '@/lib/utils';
import Image from 'next/image';
import Link from 'next/link';
import { SupabasePost } from '@/types/SupabasePost';

export default function UserDetails({
user,
hasHypersub,
className,
createdAt,
}: {
user: User;
hasHypersub?: boolean;
className?: string;
createdAt?: SupabasePost['created_at'];
}) {
return (
<div className={cn('flex space-x-3', className)}>
Expand All @@ -22,7 +25,7 @@ export default function UserDetails({
</Avatar>
</Link>
<div className="flex flex-col gap-1">
<div className="flex flex-row items-center align-middle">
<div className="flex flex-row items-center gap-1 align-middle">
<a
href={`/${user.username}`}
target="_blank"
Expand All @@ -31,6 +34,12 @@ export default function UserDetails({
{user.display_name}
</a>
{hasHypersub && <Image src="/images/hypersub.png" width={20} height={20} alt="" />}
{createdAt && (
<span className="text-sm leading-none text-muted-foreground">
{'• '}
{timeFromNow(createdAt)}
</span>
)}
</div>
<a
href={`/${user.username}`}
Expand Down
9 changes: 8 additions & 1 deletion providers/audio/PlayerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export type PlayerAction =
id: string;
};
}
| {
type: 'STOP';
}
| {
type: 'SEEK';
payload: {
Expand Down Expand Up @@ -76,6 +79,7 @@ const initialState: Player = {
loading: false,
seekTo: null,
feedId: -1,
metadata: undefined,
};

const PlayerContext = createContext<[Player, Dispatch<PlayerAction>]>([initialState, () => {}]);
Expand Down Expand Up @@ -103,6 +107,9 @@ const playerReducer = (state: Player, action: PlayerAction) => {
if (state.metadata?.id !== id) return state;
return { ...state, playing: false };
}
case 'STOP': {
return initialState;
}
case 'SEEK':
return { ...state, seekTo: action.payload.position };
case 'SEEKED':
Expand Down Expand Up @@ -142,7 +149,7 @@ export default function PlayerProvider({ children }: { children: ReactNode }) {
soundController,
spotifyController,
youtubeController,
zoraController
zoraController,
]);

useEffect(() => {
Expand Down