Skip to content

Commit 72d1892

Browse files
authored
feat(canvas): add artwork selection store
Implement an in-memory store for canvas artwork selections per track.
1 parent b43416d commit 72d1892

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.metrolist.music.features.canvas
2+
3+
import kotlinx.coroutines.flow.MutableStateFlow
4+
import kotlinx.coroutines.flow.StateFlow
5+
import kotlinx.coroutines.flow.asStateFlow
6+
import kotlinx.coroutines.flow.update
7+
import java.util.concurrent.ConcurrentHashMap
8+
9+
/** In-memory per-track selections made from the Player's Canvas picker. */
10+
object CanvasArtworkSelectionStore {
11+
private val selected = ConcurrentHashMap<String, CanvasArtwork>()
12+
private val _changes = MutableStateFlow(0L)
13+
val changes: StateFlow<Long> = _changes.asStateFlow()
14+
15+
fun get(mediaId: String): CanvasArtwork? = selected[mediaId]
16+
17+
fun put(mediaId: String, artwork: CanvasArtwork) {
18+
if (mediaId.isBlank()) return
19+
selected[mediaId] = artwork
20+
_changes.update { it + 1L }
21+
}
22+
}

0 commit comments

Comments
 (0)