From 216b8f50be255c63b7243b39262611cf8bb03ced Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 18 Dec 2025 07:05:46 +0300 Subject: [PATCH] patch --- yobble/Services/AppUpdateChecker.swift | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/yobble/Services/AppUpdateChecker.swift b/yobble/Services/AppUpdateChecker.swift index 10c1474..95e2cf3 100644 --- a/yobble/Services/AppUpdateChecker.swift +++ b/yobble/Services/AppUpdateChecker.swift @@ -1,4 +1,5 @@ import Foundation +import SwiftUI import UIKit struct AppUpdateNotice: Identifiable { @@ -15,27 +16,30 @@ struct AppUpdateNotice: Identifiable { var title: String { switch kind { case .need: - return NSLocalizedString("NeedUpdate.Title", comment: "Need update alert title") + return NSLocalizedString("Обновление обязательно", comment: "Need update alert title") case .force: - return NSLocalizedString("ForceUpdate.Title", comment: "Force update alert title") + return NSLocalizedString("Рекомендуется обновление", comment: "Force update alert title") case .soft: - return NSLocalizedString("SoftUpdate.Title", comment: "Soft update alert title") + return NSLocalizedString("Доступно обновление", comment: "Soft update alert title") } } var message: String { switch kind { case .need: - return NSLocalizedString("NeedUpdate.Message", comment: "Need update alert message") + return NSLocalizedString("Для продолжения работы необходимо обновить приложение до последней версии.", comment: "Need update alert message") case .force: - return NSLocalizedString("ForceUpdate.Message", comment: "Force update alert message") + return NSLocalizedString("Эта версия приложения устарела. Некоторые функции могут работать некорректно.", comment: "Force update alert message") case .soft: - return NSLocalizedString("SoftUpdate.Message", comment: "Soft update alert message") + return NSLocalizedString("Вышла новая версия приложения с улучшениями и исправлениями.", comment: "Soft update alert message") } } } final class AppUpdateChecker: ObservableObject { + @AppStorage("appIsBlocked") private var isAppBlocked: Bool = false + @AppStorage("lastCheckedAppBuild") private var lastCheckedAppBuild: Int = 0 + @Published private(set) var needUpdateNotice: AppUpdateNotice? @Published private(set) var softUpdateNotice: AppUpdateNotice? @Published private(set) var forceUpdateNotice: AppUpdateNotice? @@ -108,24 +112,29 @@ final class AppUpdateChecker: ObservableObject { log("Config missing App Store URL") return } - + print("buildNumber", buildNumber) print("config", config.notSupportedBuild, config.minSupportedBuild, config.recommendedBuild) let requiresNeedUpdate = buildNumber <= config.notSupportedBuild if requiresNeedUpdate { + isAppBlocked = true needUpdateNotice = AppUpdateNotice(kind: .need, appStoreURL: appStoreURL) return + } else { + isAppBlocked = false } let requiresForcedUpdate = buildNumber < config.minSupportedBuild if requiresForcedUpdate { - forceUpdateNotice = AppUpdateNotice(kind: .force, appStoreURL: appStoreURL) + softUpdateNotice = AppUpdateNotice(kind: .force, appStoreURL: appStoreURL) return } - if buildNumber < config.recommendedBuild { + if buildNumber < config.recommendedBuild && config.recommendedBuild != lastCheckedAppBuild { +// lastCheckedAppBuild = config.recommendedBuild softUpdateNotice = AppUpdateNotice(kind: .soft, appStoreURL: appStoreURL) + return } }