Disables actions for Patreon apps with expired pledges instead of hiding them

This commit is contained in:
Riley Testut
2023-12-01 16:38:31 -06:00
committed by Magesh K
parent 8946ab8a65
commit 0ad9ceaa95

View File

@@ -1895,18 +1895,30 @@ extension MyAppsViewController
let error = OperationError.pledgeInactive(appName: installedApp.name) let error = OperationError.pledgeInactive(appName: installedApp.name)
title = error.localizedDescription title = error.localizedDescription
// Limit options for apps requiring pledges that we are no longer pledged to. let allowedActions: Set<UIMenuElement> = [
actions = actions.filter { openMenu,
$0 == openMenu || deactivateAction,
$0 == deactivateAction || removeAction,
$0 == removeAction || backupAction,
$0 == backupAction || exportBackupAction
$0 == exportBackupAction || ]
($0 == refreshAction && storeApp.bundleIdentifier == StoreApp.altstoreAppID) // Always show refresh option for AltStore so the menu will be shown.
}
// Disable refresh action for AltStore. for action in actions where !allowedActions.contains(action)
refreshAction.attributes = .disabled {
// Disable options for Patreon apps that we are no longer pledged to.
if let action = action as? UIAction
{
action.attributes = .disabled
}
else if let menu = action as? UIMenu
{
for case let action as UIAction in menu.children
{
action.attributes = .disabled
}
}
}
} }
let menu = UIMenu(title: title ?? "", children: actions) let menu = UIMenu(title: title ?? "", children: actions)