Skip to content

Commit

Permalink
app: HistoryViewModel: Avoid history crashes while offline
Browse files Browse the repository at this point in the history
  • Loading branch information
DD3Boh committed May 17, 2024
1 parent 877ffe9 commit 51c0ba9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.dd3boh.outertune.db.MusicDatabase
import com.dd3boh.outertune.utils.reportException
import com.zionhuang.innertube.YouTube
import com.zionhuang.innertube.pages.HistoryPage
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -52,7 +53,11 @@ class HistoryViewModel @Inject constructor(

init {
viewModelScope.launch(Dispatchers.IO) {
historyPage.value = YouTube.musicHistory().getOrNull()
YouTube.musicHistory().onSuccess {
historyPage.value = it
}.onFailure {
reportException(it)
}
}
}
}
Expand Down

0 comments on commit 51c0ba9

Please sign in to comment.