mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fix a bug where rooms couldn't be opened when returning to the foreground whilst offline. (#5867)
The stores weren't being resumed.
This commit is contained in:
@@ -421,12 +421,9 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard networkMonitor.reachabilityPublisher.value == .reachable else {
|
let offline = networkMonitor.reachabilityPublisher.value != .reachable
|
||||||
MXLog.warning("Ignoring request, network unreachable.")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await transitionServices(to: .running).value
|
await transitionServices(to: .running(offline: offline)).value
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A stored task for restarting the sync after a failure. This is stored so that we can cancel
|
/// A stored task for restarting the sync after a failure. This is stored so that we can cancel
|
||||||
@@ -1052,7 +1049,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
// Don't restart the send queue unless the client is meant to be running; doing so while
|
// Don't restart the send queue unless the client is meant to be running; doing so while
|
||||||
// suspended would generate network activity in the window we paused to keep quiet.
|
// suspended would generate network activity in the window we paused to keep quiet.
|
||||||
if enabled == false, reachability == .reachable, self?.desiredServiceState == .running {
|
if enabled == false, reachability == .reachable, case .running = self?.desiredServiceState {
|
||||||
MXLog.info("Enabling all send queues")
|
MXLog.info("Enabling all send queues")
|
||||||
Task {
|
Task {
|
||||||
await client.enableAllSendQueues(enable: true)
|
await client.enableAllSendQueues(enable: true)
|
||||||
@@ -1072,7 +1069,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
// MARK: - Pausing and resuming
|
// MARK: - Pausing and resuming
|
||||||
|
|
||||||
private enum ServiceState { case running, suspended }
|
private enum ServiceState { case running(offline: Bool), suspended }
|
||||||
|
|
||||||
/// The state the sync service and client *should* be in, updated by ``resumeServices()`` and ``pauseServices()``.
|
/// The state the sync service and client *should* be in, updated by ``resumeServices()`` and ``pauseServices()``.
|
||||||
private var desiredServiceState: ServiceState = .suspended
|
private var desiredServiceState: ServiceState = .suspended
|
||||||
@@ -1097,7 +1094,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
private func reconcileServiceState() async {
|
private func reconcileServiceState() async {
|
||||||
switch desiredServiceState {
|
switch desiredServiceState {
|
||||||
case .running:
|
case .running(let offline):
|
||||||
if appSettings.clientPausingAndResumingEnabled {
|
if appSettings.clientPausingAndResumingEnabled {
|
||||||
do {
|
do {
|
||||||
MXLog.info("Resuming client")
|
MXLog.info("Resuming client")
|
||||||
@@ -1107,6 +1104,11 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if offline {
|
||||||
|
MXLog.warning("Ignoring sync services, network unreachable.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
MXLog.info("Starting sync")
|
MXLog.info("Starting sync")
|
||||||
await syncService.start()
|
await syncService.start()
|
||||||
|
|
||||||
@@ -1213,7 +1215,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updateHomeserverReachability() {
|
private func updateHomeserverReachability() {
|
||||||
let reachability: HomeserverReachability = if desiredServiceState != .running {
|
let reachability: HomeserverReachability = if case .suspended = desiredServiceState {
|
||||||
.suspended
|
.suspended
|
||||||
} else if syncServiceState == .offline {
|
} else if syncServiceState == .offline {
|
||||||
.unreachable
|
.unreachable
|
||||||
|
|||||||
Reference in New Issue
Block a user