Skip to content

Commit 7334c00

Browse files
Merge remote-tracking branch 'origin/connection-recovery-handler' into connection-recovery-handler
2 parents ac231f8 + 41cbf28 commit 7334c00

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

stream-android-core/src/main/java/io/getstream/android/core/api/utils/Result.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ public inline fun <T, R> Result<T>.flatMap(transform: (T) -> Result<R>): Result<
4949
@StreamInternalApi
5050
public suspend fun <T> Result<T>.onTokenError(
5151
function: suspend (exception: StreamEndpointException, code: Int) -> Result<T>
52-
): Result<T> = onFailure {
53-
if (it is StreamEndpointException && it.apiError?.code?.div(10) == 4) {
54-
function(it, it.apiError.code)
55-
} else {
56-
this
52+
): Result<T> = fold(
53+
onSuccess = { this },
54+
onFailure = { throwable ->
55+
if (throwable is StreamEndpointException && throwable.apiError?.code?.div(10) == 4) {
56+
function(throwable, throwable.apiError.code)
57+
} else {
58+
this
59+
}
5760
}
58-
}
61+
)

stream-android-core/src/main/java/io/getstream/android/core/internal/observers/StreamNetworkAndLifeCycleMonitor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import kotlinx.coroutines.flow.MutableStateFlow
3131
* Coordinates lifecycle and network signals to make connection recovery decisions.
3232
*
3333
* ### Responsibilities
34-
* - Bridges callbacks from [StreamNetworkMonitor] and [StreamLifecycleMonitor] into hot state flows
35-
* exposed as [networkState] and [lifecycleState].
36-
* - Notifies registered [StreamConnectionRecoveryListener]s when reconnect/teardown actions should
34+
* - Bridges callbacks from [StreamNetworkMonitor] and [StreamLifecycleMonitor] into internal state flows
35+
* for network and lifecycle state.
36+
* - Notifies registered [StreamNetworkAndLifecycleMonitorListener]s when reconnect/teardown actions should
3737
* occur.
3838
* - Implements [StreamStartableComponent] so callers can hook into their own lifecycle.
3939
*

stream-android-core/src/main/java/io/getstream/android/core/internal/recovery/StreamConnectionRecoveryEvaluatorImpl.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ internal class StreamConnectionRecoveryEvaluatorImpl(
9494
lastConnectionState = connectionState
9595
lastLifecycleState = lifecycleState
9696
lastNetworkState = networkState
97-
if (networkState is StreamNetworkState.Available) {
98-
lastNetworkSnapshot = networkState.snapshot
99-
}
97+
lastNetworkSnapshot = connectSnapshot
10098
result
10199
}
102100
}

0 commit comments

Comments
 (0)