mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
[DisableIdleTimeout]: Fix: account for concurrency
This commit is contained in:
@@ -1231,8 +1231,11 @@ private extension AppManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DispatchQueue.main.schedule {
|
// Disable the idleTimeout
|
||||||
UIApplication.shared.isIdleTimerDisabled = UserDefaults.standard.isIdleTimeoutDisableEnabled
|
if !UIApplication.shared.isIdleTimerDisabled { // accept only once if concurrent
|
||||||
|
DispatchQueue.main.schedule {
|
||||||
|
UIApplication.shared.isIdleTimerDisabled = UserDefaults.standard.isIdleTimeoutDisableEnabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
performAppOperations()
|
performAppOperations()
|
||||||
// Moved to self.finish()
|
// Moved to self.finish()
|
||||||
@@ -2099,9 +2102,14 @@ private extension AppManager
|
|||||||
|
|
||||||
func finish(_ operation: AppOperation, result: Result<InstalledApp, Error>, group: RefreshGroup, progress: Progress?)
|
func finish(_ operation: AppOperation, result: Result<InstalledApp, Error>, group: RefreshGroup, progress: Progress?)
|
||||||
{
|
{
|
||||||
// remove disableIdleTimeout
|
// Remove disableIdleTimeout
|
||||||
DispatchQueue.main.schedule {
|
// TODO: This should disable for the last finish() request not the first though for batches
|
||||||
UIApplication.shared.isIdleTimerDisabled = false
|
// probably if we are in batch mode, we can count expected no of finishes() to arrive
|
||||||
|
// and schedule disabling only on last request by matching it with count.
|
||||||
|
if UIApplication.shared.isIdleTimerDisabled { // accept only once if concurrent
|
||||||
|
DispatchQueue.main.schedule {
|
||||||
|
UIApplication.shared.isIdleTimerDisabled = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must remove before saving installedApp.
|
// Must remove before saving installedApp.
|
||||||
|
|||||||
Reference in New Issue
Block a user