Gitnuro/src/main/kotlin/app/updates/UpdatesRepository.kt
Abdelilah El Aissaoui a43c13462a The app now remembers the window state.
The resolution won't be saved to avoid issues when adding or removing screens with different resolution.

Fixes https://github.com/JetpackDuba/Gitnuro/issues/8
2022-06-17 03:14:21 +02:00

23 lines
630 B
Kotlin

package app.updates
import app.AppConstants
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import javax.inject.Inject
private val updateJson = Json {
this.ignoreUnknownKeys = true
}
class UpdatesRepository @Inject constructor(
private val updatesWebService: UpdatesService,
) {
suspend fun latestRelease(): Update? = withContext(Dispatchers.IO) {
val latestReleaseJson = updatesWebService.release(AppConstants.VERSION_CHECK_URL)
updateJson.decodeFromString(latestReleaseJson)
}
}