mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 07:25:19 +00:00
UI: scope Tor restart messages to geohash channels; skip initial foreground restart on cold launch to avoid confusing system message in #mesh
This commit is contained in:
@@ -15,6 +15,8 @@ struct BitchatApp: App {
|
||||
#if os(iOS)
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
// Skip the very first .active-triggered Tor restart on cold launch
|
||||
@State private var didHandleInitialActive: Bool = false
|
||||
#elseif os(macOS)
|
||||
@NSApplicationDelegateAdaptor(MacAppDelegate.self) var appDelegate
|
||||
#endif
|
||||
@@ -66,8 +68,14 @@ struct BitchatApp: App {
|
||||
// Restart services when becoming active
|
||||
chatViewModel.meshService.startServices()
|
||||
TorManager.shared.setAppForeground(true)
|
||||
// Ensure Tor is healthy; restart deterministically, then wait until ready
|
||||
TorManager.shared.ensureRunningOnForeground()
|
||||
// On initial cold launch, Tor was just started in onAppear.
|
||||
// Skip the deterministic restart the first time we become active.
|
||||
if didHandleInitialActive {
|
||||
// Ensure Tor is healthy; restart deterministically, then wait until ready
|
||||
TorManager.shared.ensureRunningOnForeground()
|
||||
} else {
|
||||
didHandleInitialActive = true
|
||||
}
|
||||
Task.detached {
|
||||
let _ = await TorManager.shared.awaitReady(timeout: 60)
|
||||
await MainActor.run {
|
||||
|
||||
@@ -836,7 +836,8 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
||||
@objc private func handleTorWillRestart() {
|
||||
Task { @MainActor in
|
||||
self.torRestartPending = true
|
||||
self.addPublicSystemMessage("tor restarting to recover connectivity…")
|
||||
// Post only in geohash channels (queue if not active)
|
||||
self.addGeohashOnlySystemMessage("tor restarting to recover connectivity…")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,7 +845,8 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
||||
Task { @MainActor in
|
||||
// Only announce "restarted" if we actually restarted this session
|
||||
if self.torRestartPending {
|
||||
self.addPublicSystemMessage("tor restarted. network routing restored.")
|
||||
// Post only in geohash channels (queue if not active)
|
||||
self.addGeohashOnlySystemMessage("tor restarted. network routing restored.")
|
||||
self.torRestartPending = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user