Update BitchatApp.swift

Co-authored-by: asmo <asmogo@protonmail.com>
This commit is contained in:
jack 2025-09-11 16:42:21 +02:00 committed by GitHub
parent 789bbf6862
commit 860c06c1b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,12 +76,16 @@ struct BitchatApp: App {
TorManager.shared.setAppForeground(true)
// On initial cold launch, Tor was just started in onAppear.
// Skip the deterministic restart the first time we become active.
if didHandleInitialActive {
if didHandleInitialActive && didEnterBackground {
// Ensure Tor is healthy; restart deterministically, then wait until ready
TorManager.shared.ensureRunningOnForeground()
} else {
didHandleInitialActive = true
}
didEnterBackground = false
} else {
didHandleInitialActive = true
}
Task.detached {
let _ = await TorManager.shared.awaitReady(timeout: 60)
await MainActor.run {