mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 03:03:31 +01:00
Improves 10 App ID limit error handling
This commit is contained in:
@@ -24,6 +24,7 @@ enum OperationError: LocalizedError
|
||||
case invalidParameters
|
||||
|
||||
case iOSVersionNotSupported(ALTApplication)
|
||||
case maximumAppIDLimitReached(Date)
|
||||
|
||||
case noSources
|
||||
|
||||
@@ -49,6 +50,37 @@ enum OperationError: LocalizedError
|
||||
|
||||
let localizedDescription = String(format: NSLocalizedString("%@ requires %@.", comment: ""), name, version)
|
||||
return localizedDescription
|
||||
|
||||
case .maximumAppIDLimitReached: return NSLocalizedString("Cannot register more than 10 App IDs.", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
var recoverySuggestion: String? {
|
||||
switch self
|
||||
{
|
||||
case .maximumAppIDLimitReached(let date):
|
||||
let remainingTime: String
|
||||
|
||||
let numberOfDays = date.numberOfCalendarDays(since: Date())
|
||||
switch numberOfDays {
|
||||
case 0:
|
||||
let components = Calendar.current.dateComponents([.hour], from: Date(), to: date)
|
||||
let numberOfHours = components.hour!
|
||||
|
||||
switch numberOfHours
|
||||
{
|
||||
case 1: remainingTime = NSLocalizedString("1 hour", comment: "")
|
||||
default: remainingTime = String(format: NSLocalizedString("%@ hours", comment: ""), NSNumber(value: numberOfHours))
|
||||
}
|
||||
|
||||
case 1: remainingTime = NSLocalizedString("1 day", comment: "")
|
||||
default: remainingTime = String(format: NSLocalizedString("%@ days", comment: ""), NSNumber(value: numberOfDays))
|
||||
}
|
||||
|
||||
let message = String(format: NSLocalizedString("Delete sideloaded apps to free up App ID slots. You can register another App ID in %@.", comment: ""), remainingTime)
|
||||
return message
|
||||
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user