Skip to content

Commit

Permalink
fixup: ui: Details dialog refactor [2/2]
Browse files Browse the repository at this point in the history
* We were passing in the player song's play count instead of the selected song's
  • Loading branch information
mikooomich committed Jan 5, 2025
1 parent 7acaa4d commit f4e9332
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class PlayerConnection(
val currentFormat = mediaMetadata.flatMapLatest { mediaMetadata ->
database.format(mediaMetadata?.id)
}
val currentPlayCount = mediaMetadata.flatMapLatest { mediaMetadata ->
database.getLifetimePlayCount(mediaMetadata?.id)
}

private val currentMediaItemIndex = MutableStateFlow(-1)

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/dd3boh/outertune/ui/menu/PlayerMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastSumBy
import androidx.compose.ui.window.DialogProperties
import androidx.media3.common.PlaybackParameters
import androidx.media3.exoplayer.offline.DownloadService
Expand Down Expand Up @@ -107,7 +108,6 @@ fun PlayerMenu(
val playerConnection = LocalPlayerConnection.current ?: return
val playerVolume = playerConnection.service.playerVolume.collectAsState()
val currentFormat by playerConnection.currentFormat.collectAsState(initial = null)
val currentPlayCount by playerConnection.currentPlayCount.collectAsState(initial = null)
val librarySong by database.song(mediaMetadata.id).collectAsState(initial = null)
val coroutineScope = rememberCoroutineScope()

Expand Down Expand Up @@ -292,7 +292,7 @@ fun PlayerMenu(
DetailsDialog(
mediaMetadata = mediaMetadata,
currentFormat = currentFormat,
currentPlayCount = currentPlayCount,
currentPlayCount = librarySong?.playCount?.fastSumBy { it.count }?: 0,
volume = playerConnection.player.volume,
clipboardManager = clipboardManager,
setVisibility = {showDetailsDialog = it }
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/dd3boh/outertune/ui/menu/SongMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastSumBy
import androidx.media3.exoplayer.offline.DownloadService
import androidx.navigation.NavController
import coil.compose.AsyncImage
Expand Down Expand Up @@ -102,7 +103,6 @@ fun SongMenu(
val coroutineScope = rememberCoroutineScope()

val currentFormat by playerConnection.currentFormat.collectAsState(initial = null)
val currentPlayCount by playerConnection.currentPlayCount.collectAsState(initial = null)

var showEditDialog by rememberSaveable {
mutableStateOf(false)
Expand Down Expand Up @@ -220,7 +220,7 @@ fun SongMenu(
DetailsDialog(
mediaMetadata = song.toMediaMetadata(),
currentFormat = currentFormat,
currentPlayCount = currentPlayCount,
currentPlayCount = song.playCount?.fastSumBy { it.count }?: 0,
volume = playerConnection.player.volume,
clipboardManager = clipboardManager,
setVisibility = {showDetailsDialog = it }
Expand Down

0 comments on commit f4e9332

Please sign in to comment.