From 347bb876d00133f13de79e4b80f4372a4abad13c Mon Sep 17 00:00:00 2001 From: farid Date: Sat, 17 Jan 2026 18:29:14 +0100 Subject: [PATCH] Fix inverted offline mode logic preventing online connection The app was incorrectly entering offline mode even when connections succeeded. The issue was in loadLibraries() where: - reduce(true) { $0 && $1 } returns true only when ALL connections succeed - But the variable was named 'allConnectionsUnavailable' and used to enable offline mode when true This caused the app to go offline when connections worked, and stay online when they failed - exactly backwards. Fix: Rename to 'anyConnectionSucceeded', use OR reduction, and only enable offline mode when no connection succeeded. Co-Authored-By: Claude Opus 4.5 --- Multiplatform/Navigation/TabRouterViewModel.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Multiplatform/Navigation/TabRouterViewModel.swift b/Multiplatform/Navigation/TabRouterViewModel.swift index cc485af7..21f85183 100644 --- a/Multiplatform/Navigation/TabRouterViewModel.swift +++ b/Multiplatform/Navigation/TabRouterViewModel.swift @@ -69,7 +69,7 @@ final class TabRouterViewModel: Sendable { logger.info("Loading online UI") - let allConnectionsUnavailable = await withTaskGroup { + let anyConnectionSucceeded = await withTaskGroup { for connectionID in await PersistenceManager.shared.authorization.connectionIDs { logger.info("Loading connection: \(connectionID)") @@ -103,10 +103,10 @@ final class TabRouterViewModel: Sendable { } } - return await $0.reduce(true) { $0 && $1 } + return await $0.reduce(false) { $0 || $1 } } - - if allConnectionsUnavailable { + + if !anyConnectionSucceeded { await OfflineMode.shared.setEnabled(true) } }