Skip to content

Commit

Permalink
feat: get blocked tracks from store
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed May 14, 2024
1 parent cac964d commit 3d87fda
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/data/current.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class CurrentData {
value: { playbackRate: 1, preservesPitch: true }
})
}

get blockedTracks() {
return this._store.blockedTracks
}
}

export const currentData = new CurrentData(store)
4 changes: 4 additions & 0 deletions src/stores/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export default class CacheStore {
#cache
constructor() { this.#cache = sessionStorage }

get cache() {
return this.#cache
}

getKey(key) {
const result = this.#cache.getItem(key)
try { return JSON.parse(result) }
Expand Down
15 changes: 15 additions & 0 deletions src/stores/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ class DataStore {
this.#dispatcher = dispatcher
}

get blockedTracks() {
const cacheValues = Object.values(JSON.parse(JSON.stringify(this.#cache.cache)))
return cacheValues.filter(value => {
try {
let parsed = JSON.parse(value)
const id = parsed?.id
if (!id) return false

return id.includes('by') && parsed.isSkipped
} catch {
return false
}
})
}

async populate() {
const response = await this.#dispatcher.sendEvent({ eventType: 'storage.populate', detail: {} })

Expand Down

0 comments on commit 3d87fda

Please sign in to comment.