Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

added link to artist page #1182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ import androidx.media3.common.Player
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.models.Info
import it.vfsfitvnm.vimusic.models.Song
import it.vfsfitvnm.vimusic.query
import it.vfsfitvnm.vimusic.ui.components.SeekBar
import it.vfsfitvnm.vimusic.ui.components.themed.IconButton
import it.vfsfitvnm.vimusic.ui.screens.artistRoute
import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.ui.styling.favoritesIcon
import it.vfsfitvnm.vimusic.utils.bold
Expand All @@ -52,7 +54,9 @@ import it.vfsfitvnm.vimusic.utils.rememberPreference
import it.vfsfitvnm.vimusic.utils.secondary
import it.vfsfitvnm.vimusic.utils.semiBold
import it.vfsfitvnm.vimusic.utils.trackLoopEnabledKey
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.withContext

@Composable
fun Controls(
Expand All @@ -79,8 +83,14 @@ fun Controls(
mutableStateOf<Long?>(null)
}

LaunchedEffect(mediaId) {
Database.likedAt(mediaId).distinctUntilChanged().collect { likedAt = it }
var artistsInfo: List<Info>? by remember { mutableStateOf(null) }

LaunchedEffect(Unit) {
withContext(Dispatchers.IO) {
if (artistsInfo == null) artistsInfo = Database.songArtistInfo(mediaId)

Database.likedAt(mediaId).distinctUntilChanged().collect { likedAt = it }
}
}

val shouldBePlayingTransition = updateTransition(shouldBePlaying, label = "shouldBePlaying")
Expand Down Expand Up @@ -113,7 +123,11 @@ fun Controls(
text = artist ?: "",
style = typography.s.semiBold.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
modifier = Modifier.clickable {
val goTo = artistRoute::global
goTo(artistsInfo?.get(0)?.id)
}
)

Spacer(
Expand Down