Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Wire
// Copyright (C) 2025 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

@preconcurrency import Combine
import Foundation
import Network

public final class NetworkReachability: Sendable {

private let monitor = NWPathMonitor()
private let isReachableSubject = CurrentValueSubject<Bool, Never>(true)
private let queue = DispatchQueue(label: "NetworkReachabilityQueue")

public var isReachablePublisher: AnyPublisher<Bool, Never> {
isReachableSubject.eraseToAnyPublisher()
}

public init() {
monitor.pathUpdateHandler = { [weak self] path in
self?.isReachableSubject.send(path.status == .satisfied)
}
monitor.start(queue: queue)
}

deinit {
monitor.cancel()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ public final class ZMUserSession: NSObject {
private let userSessionComponent: UserSessionComponent
public private(set) var clientSessionComponent: ClientSessionComponent?

private let networkReachability = NetworkReachability()
private var isNetworkReachableCancellable: AnyCancellable?

// MARK: - Initialize

init(
Expand Down Expand Up @@ -489,6 +492,12 @@ public final class ZMUserSession: NSObject {

super.init()

if DeveloperFlag.multibackend.isOn {
self.isNetworkReachableCancellable = networkReachability.isReachablePublisher
.sink { [weak self] isReachable in
isReachable ? self?.didReceiveData() : self?.didGoOffline()
}
Comment on lines +496 to +499
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we need to shutdown ReachabilityWrapper if multibackend is on?

}
}

func trackAppOpenAnalyticEventWhenAppBecomesActive() {
Expand Down Expand Up @@ -698,7 +707,10 @@ public final class ZMUserSession: NSObject {

private func configureTransportSession() {
transportSession.pushChannel.clientID = selfUserClient?.remoteIdentifier
transportSession.setNetworkStateDelegate(self)
// When multibackend is on. we use another reachability.
if !DeveloperFlag.multibackend.isOn {
transportSession.setNetworkStateDelegate(self)
}
transportSession.setAccessTokenRenewalFailureHandler { [weak self] response in
self?.transportSessionAccessTokenDidFail(response: response)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ internal enum L10n {
internal enum UpdateRequired {
/// Your Wire server needs to be updated. Please notify your system administrator.
internal static let obsoleteBackend = L10n.tr("Localizable", "share_extension.error.update_required.obsolete_backend", fallback: "Your Wire server needs to be updated. Please notify your system administrator.")
/// You are missing out on new features. Get the latest version of Wire to continue using the app with this account.
internal static let obsoleteClient = L10n.tr("Localizable", "share_extension.error.update_required.obsolete_client", fallback: "You are missing out on new features. Get the latest version of Wire to continue using the app with this account.")
/// You are missing out on new features. Get the latest version of Wire to continue using the app with this account.
internal static let obsoleteClient = L10n.tr("Localizable", "share_extension.error.update_required.obsolete_client", fallback: "You are missing out on new features. Get the latest version of Wire to continue using the app with this account.")
/// Update required
internal static let title = L10n.tr("Localizable", "share_extension.error.update_required.title", fallback: "Update required")
}
Expand Down
Loading