Skip to content

Commit

Permalink
Merge pull request #40 from musicorum-app/dev
Browse files Browse the repository at this point in the history
fix empty list crashes
  • Loading branch information
MysteryMS authored Jan 5, 2024
2 parents f66055d + cae36db commit 5cc055e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
applicationId "io.musicorum.mobile"
minSdk 28
targetSdk 34
versionCode 71
versionName "2.0.1"
versionCode 72
versionName "2.0.2"
//compileSdkPreview = "UpsideDownCake"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -67,6 +69,7 @@ fun FriendActivity(
val analytics = LocalAnalytics.current!!
val nav = LocalNavigation.current
val showSheet = remember { mutableStateOf(false) }
val haptic = LocalHapticFeedback.current

if (showSheet.value) {
val colors = ListItemDefaults.colors(
Expand Down Expand Up @@ -130,7 +133,10 @@ fun FriendActivity(
param(FirebaseAnalytics.Param.ITEM_NAME, "friend_activity_track")
}
},
onLongClick = { showSheet.value = true }
onLongClick = {
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
showSheet.value = true
}
)
)
AsyncImage(
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/io/musicorum/mobile/components/TrackCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -58,8 +60,10 @@ fun TrackCard(track: Track, labelType: LabelType) {
val navTrack = NavigationTrack(track.name.encodeURLPathPart(), track.artist.name)
val dest = Json.encodeToString(navTrack)
val showTrackSheet = remember { mutableStateOf(false) }
val haptic = LocalHapticFeedback.current

if (showTrackSheet.value) {
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
TrackSheet(track = track, show = showTrackSheet)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.musicorum.mobile.views.friendlist

import android.app.Application
import android.content.Intent
import android.net.Uri
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import io.musicorum.mobile.ktor.endpoints.UserEndpoint
Expand All @@ -23,7 +21,13 @@ class FriendActivityViewModel(application: Application) : AndroidViewModel(appli
}
val res = UserEndpoint.getRecentTracks(username, null, 1)
res?.let {
val track = res.recentTracks.tracks.first()
val track = res.recentTracks.tracks.firstOrNull()
if (track == null) {
state.update {
it.copy(loading = false)
}
return@launch
}
state.update {
it.copy(
track = track,
Expand Down

0 comments on commit 5cc055e

Please sign in to comment.