mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-10-07 02:51:21 -04:00
Fix: Handle null or empty release list in getLatestRelease (#1967)
This commit is contained in:
1 parent
1f2254f98b
commit
091607da08
1 file changed
+7
-3
+7
-3
@@ -52,8 +52,12 @@ class FirmwareReleaseLocalDataSource @Inject constructor(
|
||||
suspend fun getLatestRelease(releaseType: FirmwareReleaseType): FirmwareReleaseEntity? =
|
||||
withContext(Dispatchers.IO) {
|
||||
val releases = firmwareReleaseDao.getReleasesByType(releaseType)
|
||||
val latestRelease =
|
||||
releases?.maxBy { it.asDeviceVersion() }
|
||||
return@withContext latestRelease
|
||||
if (releases.isNullOrEmpty()) {
|
||||
return@withContext null
|
||||
} else {
|
||||
val latestRelease =
|
||||
releases.maxBy { it.asDeviceVersion() }
|
||||
return@withContext latestRelease
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user