Add more checks to avoid unnecessary websocket connects.

This commit is contained in:
Greyson Parrelli
2026-06-17 13:08:35 -04:00
parent e877f43dde
commit 4c1555bc7b
3 changed files with 4 additions and 2 deletions
@@ -399,7 +399,7 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
};
SignalWebSocket.AuthenticatedWebSocket webSocket = new SignalWebSocket.AuthenticatedWebSocket(authFactory,
() -> !SignalStore.misc().isClientDeprecated() && !DeviceTransferBlockingInterceptor.getInstance().isBlockingNetwork() && !Environment.IS_INSTRUMENTATION,
() -> !SignalStore.misc().isClientDeprecated() && SignalStore.account().isRegistered() && !TextSecurePreferences.isUnauthorizedReceived(context) && !DeviceTransferBlockingInterceptor.getInstance().isBlockingNetwork() && !Environment.IS_INSTRUMENTATION,
sleepTimer,
TimeUnit.SECONDS.toMillis(30));
if (AppForegroundObserver.isForegrounded()) {
@@ -271,7 +271,7 @@ class IncomingMessageObserver(
}
private fun isConnectionAvailable(): Boolean {
return SignalStore.account.isRegistered && (authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED || (authWebSocket.shouldSendKeepAlives() && NetworkConstraint.isMet(context)))
return !TextSecurePreferences.isUnauthorizedReceived(context) && SignalStore.account.isRegistered && (authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED || (authWebSocket.shouldSendKeepAlives() && NetworkConstraint.isMet(context)))
}
private fun waitForConnectionNecessary() {