diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index 7b7324d18..6508ce4e1 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -73,7 +73,8 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel() val noteText = when { noteFile.exists() -> noteFile.readText() else -> { - val note = svc.fetchUpdate(APP_VERSION_CODE).note + val note = svc.fetchUpdate(APP_VERSION_CODE)?.note.orEmpty() + if (note.isEmpty()) return@launch noteFile.writeText(note) note } diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt index 54f9809a5..f74899c99 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/repository/NetworkService.kt @@ -41,7 +41,9 @@ class NetworkService( info } - suspend fun fetchUpdate(version: Int) = findRelease { it.versionCode == version }.asInfo() + suspend fun fetchUpdate(version: Int) = safe { + findRelease { it.versionCode == version }.asInfo() + } // Keep going through all release pages until we find a match private suspend inline fun findRelease(predicate: (Release) -> Boolean): Release? {