From 860c06c1b11371b3e777baa20e0b99a8bf56b857 Mon Sep 17 00:00:00 2001 From: jack <212554440+jackjackbits@users.noreply.github.com> Date: Thu, 11 Sep 2025 16:42:21 +0200 Subject: [PATCH] Update BitchatApp.swift Co-authored-by: asmo --- bitchat/BitchatApp.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bitchat/BitchatApp.swift b/bitchat/BitchatApp.swift index 2a43ff9a..da4f07e7 100644 --- a/bitchat/BitchatApp.swift +++ b/bitchat/BitchatApp.swift @@ -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 {