mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 02:25:20 +00:00
fix(iOS App): resolve merge artifacts in scenePhase handler\n- Remove duplicate didEnterBackground state\n- Fix switch/if braces and logic for foreground restart gating
This commit is contained in:
@@ -18,7 +18,6 @@ struct BitchatApp: App {
|
|||||||
// Skip the very first .active-triggered Tor restart on cold launch
|
// Skip the very first .active-triggered Tor restart on cold launch
|
||||||
@State private var didHandleInitialActive: Bool = false
|
@State private var didHandleInitialActive: Bool = false
|
||||||
@State private var didEnterBackground: Bool = false
|
@State private var didEnterBackground: Bool = false
|
||||||
@State private var didEnterBackground: Bool = false
|
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
@NSApplicationDelegateAdaptor(MacAppDelegate.self) var appDelegate
|
@NSApplicationDelegateAdaptor(MacAppDelegate.self) var appDelegate
|
||||||
#endif
|
#endif
|
||||||
@@ -70,8 +69,6 @@ struct BitchatApp: App {
|
|||||||
// Proactively disconnect Nostr to avoid spurious socket errors while Tor is down
|
// Proactively disconnect Nostr to avoid spurious socket errors while Tor is down
|
||||||
NostrRelayManager.shared.disconnect()
|
NostrRelayManager.shared.disconnect()
|
||||||
didEnterBackground = true
|
didEnterBackground = true
|
||||||
didEnterBackground = true
|
|
||||||
break
|
|
||||||
case .active:
|
case .active:
|
||||||
// Restart services when becoming active
|
// Restart services when becoming active
|
||||||
chatViewModel.meshService.startServices()
|
chatViewModel.meshService.startServices()
|
||||||
@@ -79,15 +76,11 @@ struct BitchatApp: App {
|
|||||||
// On initial cold launch, Tor was just started in onAppear.
|
// On initial cold launch, Tor was just started in onAppear.
|
||||||
// Skip the deterministic restart the first time we become active.
|
// Skip the deterministic restart the first time we become active.
|
||||||
if didHandleInitialActive && didEnterBackground {
|
if didHandleInitialActive && didEnterBackground {
|
||||||
// Ensure Tor is healthy; restart deterministically, then wait until ready
|
|
||||||
TorManager.shared.ensureRunningOnForeground()
|
TorManager.shared.ensureRunningOnForeground()
|
||||||
} else {
|
} else {
|
||||||
didHandleInitialActive = true
|
didHandleInitialActive = true
|
||||||
}
|
}
|
||||||
didEnterBackground = false
|
didEnterBackground = false
|
||||||
} else {
|
|
||||||
didHandleInitialActive = true
|
|
||||||
}
|
|
||||||
Task.detached {
|
Task.detached {
|
||||||
let _ = await TorManager.shared.awaitReady(timeout: 60)
|
let _ = await TorManager.shared.awaitReady(timeout: 60)
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
|
|||||||
Reference in New Issue
Block a user