Skip to content

Commit 3224995

Browse files
committed
Try increasing the cache index when re-creating the Flow<RootNavState>, otherwise sometimes we get a blank screen
1 parent dedc539 commit 3224995

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

appnav/src/main/kotlin/io/element/android/appnav/root/RootNavStateFlowFactory.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class RootNavStateFlowFactory(
5757
* @return a flow of integer, where each time a clear cache is done, we have a new incremented value.
5858
*/
5959
private fun cacheIndexFlow(savedStateMap: SavedStateMap?): Flow<Int> {
60-
val initialCacheIndex = savedStateMap.getCacheIndexOrDefault()
60+
val initialCacheIndex = savedStateMap.getUpdatedCacheIndexOrDefault()
6161
return cacheService.clearedCacheEventFlow
6262
.onEach { sessionId ->
6363
matrixSessionCache.remove(sessionId)
@@ -83,7 +83,7 @@ class RootNavStateFlowFactory(
8383
}
8484
}
8585

86-
private fun SavedStateMap?.getCacheIndexOrDefault(): Int {
87-
return this?.get(SAVE_INSTANCE_KEY) as? Int ?: 0
86+
private fun SavedStateMap?.getUpdatedCacheIndexOrDefault(): Int {
87+
return (this?.get(SAVE_INSTANCE_KEY) as? Int)?.let { it + 1 } ?: 0
8888
}
8989
}

0 commit comments

Comments
 (0)