mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
address review: share the test helpers, guard AppModuleTest cleanup
Use cancelAndJoinBlocking in the repo tests and AppModuleTest instead of hand-rolled runBlocking joins, put AppModuleTest's cleanup in a finally so a failed join cannot leave Main overridden and Koin started, and collapse the five polling await copies into one awaitUntil. upcomingItem now reads the queue snapshot under the lock but does the Room read outside it.
This commit is contained in:
@@ -868,12 +868,17 @@ class PlaybackController(
|
||||
thumbnail: Boolean = false,
|
||||
): CoverArtRef? = sourceRepository.coverArt(item?.coverArtId, thumbnail)
|
||||
|
||||
suspend fun upcomingItem(): QueueItem? =
|
||||
suspend fun upcomingItem(): QueueItem? {
|
||||
var current: QueueSnapshot? = null
|
||||
var position: Long? = null
|
||||
startLock.withLock {
|
||||
val snap = snapshot ?: return@withLock null
|
||||
val position = currentPosition() ?: return@withLock null
|
||||
queueRepository.itemAt(snap, position + 1)?.toQueueItem()
|
||||
current = snapshot
|
||||
position = currentPosition()
|
||||
}
|
||||
val snapshot = current ?: return null
|
||||
val at = position ?: return null
|
||||
return queueRepository.itemAt(snapshot, at + 1)?.toQueueItem()
|
||||
}
|
||||
|
||||
private fun play(
|
||||
entries: List<QueueEntry>,
|
||||
|
||||
Reference in New Issue
Block a user