-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix app auto-reconnect on background #1170
Conversation
e5eeeeb
to
5aa1f5e
Compare
Sources/StreamChat/ChatClient.swift
Outdated
cancelBackgroundTaskIfNeeded() | ||
|
||
guard config.shouldConnectAutomatically else { return } | ||
guard connectionStatus != .connected && connectionStatus != .connected else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we should maybe add one more && connectionStatus != .connected
to be 300% sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let confidenceChecks = (1...10).random()
for _ in confidenceChecks {
guard connectionStatus != .connected else { return }
}
dbc11f8
to
45cc880
Compare
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great refactoring 👍 Please add CHANGELOG
/// If set to `true`, the `ChatClient` will try to stay connected while app is backgrounded. | ||
/// If set to `false`, websocket disconnects immediately when app is backgrounded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would be fine to mention that the client starts starts a background task for this
Also moves the handling logic from WSClient to ChatClient. Basically, when we disconnected, we automatically set a timer for reconnection, and reconnected while in background.
Codecov Report
@@ Coverage Diff @@
## main #1170 +/- ##
==========================================
- Coverage 91.31% 91.24% -0.08%
==========================================
Files 217 217
Lines 9248 9261 +13
==========================================
+ Hits 8445 8450 +5
- Misses 803 811 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Also moves the handling logic from WSClient to ChatClient.
Basically, when we disconnected, we automatically set a timer for reconnection, and reconnected while in background.