impl VBoxUpdateFetcher

This commit is contained in:
2026-07-25 21:09:26 +03:00
parent aa6c62d283
commit c49a5ed087
7 changed files with 47 additions and 18 deletions
@@ -0,0 +1,27 @@
package ru.shadowsparky.vbox.shared.data
import io.ktor.client.HttpClient
import org.koin.core.annotation.Factory
import ru.shadowsparky.domain.AppConfig
import ru.shadowsparky.updater.domain.UpdateFetcher
import ru.shadowsparky.updater.domain.UpdateInfo
import ru.shadowsparky.vbox.shared.domain.DYNAMIC_PREFIX
import ru.shadowsparky.vbox.shared.domain.ServerConfigurationRepository
import ru.shadowsparky.vbox.shared.domain.getServerConfiguration
@Factory
class VBoxUpdateFetcher(
private val httpClient: HttpClient,
private val serverConfigurationProvider: ServerConfigurationRepository,
private val appConfig: AppConfig
) : UpdateFetcher {
override suspend fun fetch(): UpdateInfo {
return httpClient.get<UpdateInfo>(
"$DYNAMIC_PREFIX/checkUpdates",
mapOf(
"versionCode" to appConfig.versionCode.toString()
),
serverConfigurationProvider.getServerConfiguration()
)
}
}
@@ -39,7 +39,7 @@ class SettingsComponent(
val showOffline: () -> Unit,
val showTags: () -> Unit
) : ComponentContext by context {
private val updateComponent = updateComponentFactory.create(childContext("UpdateComponent"))
val updateComponent = updateComponentFactory.create(childContext("UpdateComponent"))
val hasUpdateSupport = updateComponent.hasSupport
@@ -27,6 +27,7 @@ import ru.shadowsparky.ui.applyBlurSource
import ru.shadowsparky.ui.components.ExpressiveLazyColumn
import ru.shadowsparky.ui.components.SwitchPreference
import ru.shadowsparky.ui.components.TextPreference
import ru.shadowsparky.updater.presentation.UpdateBottomSheet
@Composable
fun SettingsContent(comp: SettingsComponent, paddingValues: PaddingValues) {
@@ -73,7 +74,7 @@ fun SettingsContent(comp: SettingsComponent, paddingValues: PaddingValues) {
modifier = Modifier.clickable { comp.showTags() }
)
}
if (comp.hasUpdateSupport) {
if (comp.updateComponent.hasSupport) {
item {
TextPreference(
text = stringResource(Res.string.check_for_updates),
@@ -115,6 +116,7 @@ fun SettingsContent(comp: SettingsComponent, paddingValues: PaddingValues) {
}
}
)
UpdateBottomSheet(comp.updateComponent)
LaunchedEffect(null) {
withFrameNanos {}
requester.requestFocus()