From 86caf33504695047641556b10df5a659b9b90d2b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 1 Oct 2026 18:37:40 +0200 Subject: [PATCH] Use withPreviousValue() to detect removed sessions Replace the hand-written runningFold in RootFlowNode.observeRemovedSessions() with the existing withPreviousValue() helper, as done in IncomingVerificationRequestObserver. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../main/kotlin/io/element/android/appnav/RootFlowNode.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt index c451a65d63..d8103c18c0 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt @@ -55,6 +55,7 @@ import io.element.android.libraries.architecture.BaseFlowNode import io.element.android.libraries.architecture.appyx.rememberDelegateTransitionHandler import io.element.android.libraries.architecture.createNode import io.element.android.libraries.architecture.waitForChildAttached +import io.element.android.libraries.core.coroutine.withPreviousValue import io.element.android.libraries.deeplink.api.DeeplinkData import io.element.android.libraries.di.annotations.AppCoroutineScope import io.element.android.libraries.featureflag.api.FeatureFlagService @@ -84,7 +85,6 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.flow.runningFold import kotlinx.coroutines.launch import kotlinx.coroutines.withTimeoutOrNull import kotlinx.parcelize.Parcelize @@ -238,9 +238,9 @@ class RootFlowNode( private fun observeRemovedSessions() { sessionStore.sessionsFlow() .map { sessions -> sessions.map { SessionId(it.userId) }.toSet() } - .runningFold(emptySet() to emptySet()) { (_, previous), current -> previous to current } + .withPreviousValue() .onEach { (previous, current) -> - (previous - current).forEach { sessionId -> + (previous.orEmpty() - current).forEach { sessionId -> Timber.d("Session $sessionId removed, remove it from the cache") matrixSessionCache.remove(sessionId) }