Skip to content

Commit

Permalink
fix: use better player context default values
Browse files Browse the repository at this point in the history
  • Loading branch information
bamdadfr committed Oct 10, 2024
1 parent 1ae7324 commit 01465ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/audio/hooks/use-audio-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {usePlayerContext} from 'src/contexts/player-context';

export function useAudioLoad() {
const {ref, setDuration, setReady, url} = usePlayerContext();
const [savedUrl, setSavedUrl] = useState<string>();
const [savedUrl, setSavedUrl] = useState<string | null>(null);

const handleCanPlay = useCallback(() => {
setReady(true);
Expand Down
12 changes: 6 additions & 6 deletions src/contexts/player-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type Progress = number; // amount in time
type Repeating = boolean;
type Seek = number; // amount in time (requested by the user)
type Ready = boolean;
type Title = string;
type Artwork = string; // url
type Url = string;
type Title = string | null;
type Artwork = string | null; // url
type Url = string | null;

type Context = {
ref: MutableRefObject<Ref>;
Expand Down Expand Up @@ -67,9 +67,9 @@ export function PlayerContextProvider({children}) {
const [isRepeating, setRepeating] = useState<Repeating>(true);
const [seek, setSeek] = useState<Seek>(0);
const [isReady, setReady] = useState<Ready>(false);
const [title, setTitle] = useState<Title>('');
const [artwork, setArtwork] = useState<Artwork>('');
const [url, setUrl] = useState<Url>('');
const [title, setTitle] = useState<Title>(null);
const [artwork, setArtwork] = useState<Artwork>(null);
const [url, setUrl] = useState<Url>(null);

const setSpeedSanitized = useCallback((newSpeed: string) => {
let newSpeedFloat = parseFloat(newSpeed);
Expand Down

0 comments on commit 01465ef

Please sign in to comment.