fix: no auto download if updated disabled

This commit is contained in:
2026-09-07 00:31:34 +03:00
parent f19d65abb5
commit bafebfd253
2 changed files with 15 additions and 4 deletions
@@ -50,12 +50,12 @@ fun SettingsScreen(viewModel: UpdateViewModel) {
item {
SettingsItem(
title = "Проверить наличие обновлений",
subtitle = updateStatusText(updateState),
subtitle = updateStatusText(updateState, autoEnabled),
onClick = { viewModel.checkNow() }
)
SettingsDivider()
}
if (updateState is UpdateState.Available || updateState is UpdateState.ReadyToInstall) {
if (autoEnabled && (updateState is UpdateState.Available || updateState is UpdateState.ReadyToInstall)) {
item {
SettingsItem(
title = "Установить обновление",
@@ -89,11 +89,13 @@ fun SettingsScreen(viewModel: UpdateViewModel) {
}
}
private fun updateStatusText(state: UpdateState): String = when (state) {
private fun updateStatusText(state: UpdateState, autoEnabled: Boolean): String = when (state) {
is UpdateState.Idle -> "Проверить сейчас"
is UpdateState.Checking -> "Проверка…"
is UpdateState.UpToDate -> "Установлена последняя версия"
is UpdateState.Available -> "Доступна версия ${state.version}"
is UpdateState.Available ->
if (autoEnabled) "Доступна версия ${state.version}"
else "Доступна версия ${state.version} — включите автообновления для установки"
is UpdateState.Downloading -> "Скачивание: ${state.progress?.let { "$it%" } ?: "…"}"
is UpdateState.ReadyToInstall -> "Обновление скачано, нажмите для установки"
is UpdateState.Failed -> "Ошибка: ${state.message}"