From a20feccae214c1141d3db93900d29d6496a807c5 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 14 Jan 2020 13:20:26 -0800 Subject: [PATCH] Only updates ALTAppID features when they have changed --- AltStore/Operations/ResignAppOperation.swift | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index bb14a4c4..a7bea66d 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -264,11 +264,37 @@ private extension ResignAppOperation features[.appGroups] = true } - let appID = appID.copy() as! ALTAppID - appID.features = features + var updateFeatures = false - ALTAppleAPI.shared.update(appID, team: team, session: session) { (appID, error) in - completionHandler(Result(appID, error)) + // Determine whether the required features are already enabled for the AppID. + for (feature, value) in features + { + if let appIDValue = appID.features[feature] as AnyObject?, (value as AnyObject).isEqual(appIDValue) + { + // AppID already has this feature enabled and the values are the same. + continue + } + else + { + // AppID either doesn't have this feature enabled or the value has changed, + // so we need to update it to reflect new values. + updateFeatures = true + break + } + } + + if updateFeatures + { + let appID = appID.copy() as! ALTAppID + appID.features = features + + ALTAppleAPI.shared.update(appID, team: team, session: session) { (appID, error) in + completionHandler(Result(appID, error)) + } + } + else + { + completionHandler(.success(appID)) } }