[Settings]: Fix: DisableAppLimit switch reverting back to off state even if on iOS where sparseRestore is not patched yet

This commit is contained in:
Magesh K
2025-01-19 18:47:25 +05:30
parent 29ed2afb3d
commit 28de1953c4
4 changed files with 23 additions and 18 deletions

View File

@@ -44,7 +44,10 @@ extension SettingsViewController
var c: [AppRefreshRow] = [.backgroundRefresh, .noIdleTimeout, .addToSiri]
// conditional entries go at the last to preserve ordering
if !ProcessInfo().sparseRestorePatched { c.append(.disableAppLimit) }
if UserDefaults.standard.isCowExploitSupported || !ProcessInfo().sparseRestorePatched
{
c.append(.disableAppLimit)
}
return c
}
}
@@ -477,13 +480,16 @@ private extension SettingsViewController
}
@IBAction func toggleDisableAppLimit(_ sender: UISwitch) {
UserDefaults.standard.isAppLimitDisabled = sender.isOn
// TODO: Here we force reload the activeAppsLimit after detecting change in isAppLimitDisabled
// Why do we need to do this, once identified if this is intentional and working as expected, remove this todo
if UserDefaults.standard.activeAppsLimit != nil
{
UserDefaults.standard.activeAppsLimit = InstalledApp.freeAccountActiveAppsLimit
if UserDefaults.standard.isCowExploitSupported || !ProcessInfo().sparseRestorePatched {
// accept state change only when valid
UserDefaults.standard.isAppLimitDisabled = sender.isOn
// TODO: Here we force reload the activeAppsLimit after detecting change in isAppLimitDisabled
// Why do we need to do this, once identified if this is intentional and working as expected, remove this todo
if UserDefaults.standard.activeAppsLimit != nil
{
UserDefaults.standard.activeAppsLimit = InstalledApp.freeAccountActiveAppsLimit
}
}
}