fix: address code review issues — pinned on fresh install, reorder selection, stale rename, detached scopes, duplicate click

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-11 16:32:33 -04:00
parent 5c87f821e0
commit 5f7cb050e5
5 changed files with 22 additions and 11 deletions

View File

@@ -69,7 +69,7 @@ object SomaFmSeedData : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {
super.onCreate(db)
seedStations(db)
seedStations(db, includePinned = true)
}
/**

View File

@@ -472,20 +472,22 @@ class RadioPlaybackService : LifecycleService() {
}
private fun endConnectionSpan() {
if (connectionSpanId != 0L) {
CoroutineScope(Dispatchers.IO).launch {
connectionSpanDao.updateEndedAt(connectionSpanId, System.currentTimeMillis())
}
val spanId = connectionSpanId
if (spanId != 0L) {
connectionSpanId = 0L
serviceScope.launch(Dispatchers.IO) {
connectionSpanDao.updateEndedAt(spanId, System.currentTimeMillis())
}
}
}
private fun endListeningSession() {
if (listeningSessionId != 0L) {
CoroutineScope(Dispatchers.IO).launch {
listeningSessionDao.updateEndedAt(listeningSessionId, System.currentTimeMillis())
}
val sessionId = listeningSessionId
if (sessionId != 0L) {
listeningSessionId = 0L
serviceScope.launch(Dispatchers.IO) {
listeningSessionDao.updateEndedAt(sessionId, System.currentTimeMillis())
}
}
}
}

View File

@@ -16,7 +16,7 @@ fun RenamePlaylistDialog(
onDismiss: () -> Unit,
onConfirm: (String) -> Unit
) {
var name by remember { mutableStateOf(currentName) }
var name by remember(currentName) { mutableStateOf(currentName) }
AlertDialog(
onDismissRequest = onDismiss,

View File

@@ -471,7 +471,7 @@ private fun DragReorderTabRow(
Box {
Tab(
selected = selectedTabIndex == index,
onClick = { onSelectTab(index) },
onClick = {},
text = {
Text(
text = tab.label,

View File

@@ -17,6 +17,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
@@ -355,10 +356,18 @@ class StationListViewModel(application: Application) : AndroidViewModel(applicat
}
fun reorderTabs(reorderedPlaylists: List<Playlist>) {
val currentTab = viewState.value.tabs.getOrNull(viewState.value.selectedTabIndex)
val selectedPlaylistId = currentTab?.playlist?.id
viewModelScope.launch {
for ((index, playlist) in reorderedPlaylists.withIndex()) {
playlistDao.updateSortOrder(playlist.id, index)
}
if (selectedPlaylistId != null) {
val playlists = playlistDao.getAllPlaylists().first()
val tabs = buildTabs(playlists)
val newIndex = tabs.indexOfFirst { it.playlist?.id == selectedPlaylistId }
if (newIndex >= 0) _selectedTabIndex.value = newIndex
}
}
}
}