Fix: Handle null or empty release list in getLatestRelease (#1967)

This commit is contained in:
James Rich 2025-05-28 12:32:42 -05:00 committed by GitHub
parent 1f2254f98b
commit 091607da08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}
}
}