Skip to content

Commit

Permalink
fix: early return current track if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed May 15, 2024
1 parent 58add6c commit 2b06897
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/data/current.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ class CurrentData {

async readTrack() {
const currentInfo = currentSongInfo()
const trackParams = { id: currentInfo.id, value: { ...this.#trackDefaults, ...currentInfo } }
const existingTrack = await this._store.getTrack({ id: currentInfo.id })
if (existingTrack) return existingTrack

const trackParams = {
id: currentInfo.id,
value: { ...this.#trackDefaults, ...currentInfo }
}
const track = await this._store.getTrack(trackParams)

return track?.id ? track : { ...this.#trackDefaults, ...currentSongInfo }
Expand Down

0 comments on commit 2b06897

Please sign in to comment.