v3: code quality pass, various bug fixes

This commit is contained in:
khannurien
2026-03-23 07:47:49 +00:00
parent d94a319d96
commit fbbbb43258
44 changed files with 1060 additions and 698 deletions

View File

@@ -1,13 +1,15 @@
import { useState } from "react";
import { useCallback, useMemo, useState } from "react";
import { PlayerContext, type PlayerItem } from "./PlayerContext.ts";
export function PlayerProvider({ children }: { children: React.ReactNode }) {
const [current, setCurrent] = useState<PlayerItem | null>(null);
const play = setCurrent;
const stop = useCallback(() => setCurrent(null), []);
const value = useMemo(() => ({ current, play, stop }), [current, play, stop]);
return (
<PlayerContext.Provider
value={{ current, play: setCurrent, stop: () => setCurrent(null) }}
>
<PlayerContext.Provider value={value}>
{children}
</PlayerContext.Provider>
);