Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyadev committed Jan 16, 2025
1 parent 6c307d0 commit 3d7bc52
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
13 changes: 9 additions & 4 deletions src/components/app/providers/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ function ContextRichAudio({
// nextTrack()
}}
>
<source id="source" ref={playerRef.sourceRef} type="audio/mpeg" src="/api/library/track_data?id=fe6cee76-1975-4cc3-a4a8-b234625c0e91" />
<source
id="source"
ref={playerRef.sourceRef}
type="audio/mpeg"
src="/api/library/track_data?id=fe6cee76-1975-4cc3-a4a8-b234625c0e91"
/>
</audio>

)
}

Expand Down Expand Up @@ -122,9 +126,10 @@ export default function PlayerContextProvider({
> | null
currentTrackPosition: number
}) {
// biome-ignore lint/style/noNonNullAssertion : the moment it loads, its not null.
const playerRef = {
const playerRef = {
// biome-ignore lint/style/noNonNullAssertion : the moment it loads, its not null.
audioRef: useRef<HTMLAudioElement>(null!),
// biome-ignore lint/style/noNonNullAssertion : the moment it loads, its not null.
sourceRef: useRef<HTMLSourceElement>(null!),
}
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/providers/playing.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type React from 'react'
import { useState, useContext, createContext, useEffect } from 'react'
import { MultiRef } from './player'
import type { MultiRef } from './player'

const PlayingContext = createContext<{
playing: boolean
Expand Down
7 changes: 4 additions & 3 deletions src/components/app/providers/position.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { useState, useContext, createContext } from 'react'
import { setCurrentTrackPosition } from '~/lib/actions/user'
import { MultiRef } from './player'
import type { MultiRef } from './player'

const PositionContext = createContext<{
position: number[]
Expand All @@ -14,7 +14,7 @@ const PositionContext = createContext<{
const usePosition = () => useContext(PositionContext)

const PositionProvider: React.FC<{
playerRef: MultiRef,
playerRef: MultiRef
children: React.ReactNode
}> = ({ playerRef, children }) => {
const [position, setPosition] = useState([0])
Expand All @@ -28,7 +28,8 @@ const PositionProvider: React.FC<{
if (playerRef.audioRef.current.currentTime === undefined) return
if (position[0] === undefined) return
if (
Math.floor(playerRef.audioRef.current.currentTime) !== Math.floor(position[0] ?? 0)
Math.floor(playerRef.audioRef.current.currentTime) !==
Math.floor(position[0] ?? 0)
) {
setCurrentTrackPosition(playerRef.audioRef.current.currentTime)
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/app/providers/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,19 @@ const QueueProvider: React.FC<{
return
} // no need to add this to queue


if (track !== null) {
setQueuePlayed([...queuePlayed, track!])
setQueuePlayed([...queuePlayed, track])
}
if (queue.length === 0) {
if (autoplay === true) {
// queue is empty, autoplay is on, get a random track from the library
getRandomTrack().then((res) => {
if (res.content !== undefined) {
console.log("calling changeTrack")
console.log('calling changeTrack')
changeTrack(res.content, true)
}
})
return
} else {
}
setPlayingFalse()
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/providers/track.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usePosition } from './position'
import { usePlaying } from './playing'
import type { getTrack } from '~/lib/actions/library'
import { getCurrentTrack, setCurrentTrack } from '~/lib/actions/user'
import { MultiRef } from './player'
import type { MultiRef } from './player'

type TrackQuery = NonNullable<
Awaited<ReturnType<typeof getTrack>>['content']
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/providers/volume.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MySqlTimeBuilderInitial } from 'drizzle-orm/mysql-core'
import type React from 'react'
import { useContext, createContext, useState } from 'react'
import { MultiRef } from './player'
import type { MultiRef } from './player'

const VolumeContext = createContext<{
volume: number
Expand All @@ -10,7 +10,7 @@ const VolumeContext = createContext<{

const useVolume = () => useContext(VolumeContext)
const VolumeProvider: React.FC<{
playerRef: MultiRef,
playerRef: MultiRef
children: React.ReactNode
}> = ({ playerRef, children }) => {
const [volume, setVolume] = useState(50)
Expand Down

0 comments on commit 3d7bc52

Please sign in to comment.