Skip to content

Commit

Permalink
fix empty list crash
Browse files Browse the repository at this point in the history
  • Loading branch information
MysteryMS committed Jan 5, 2024
1 parent 68ec7f0 commit cae36db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 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
@@ -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 cae36db

Please sign in to comment.