@@ -36,7 +36,8 @@ import io.element.android.libraries.sessionstorage.api.SessionData
36
36
import io.element.android.libraries.sessionstorage.api.SessionStore
37
37
import kotlinx.collections.immutable.persistentListOf
38
38
import kotlinx.collections.immutable.toPersistentList
39
- import kotlinx.coroutines.flow.map
39
+ import kotlinx.coroutines.flow.combine
40
+ import kotlinx.coroutines.flow.onEach
40
41
import kotlinx.coroutines.launch
41
42
42
43
@Inject
@@ -56,8 +57,19 @@ class HomePresenter(
56
57
val coroutineState = rememberCoroutineScope()
57
58
val matrixUser by client.userProfile.collectAsState()
58
59
val matrixUserAndNeighbors by remember {
59
- sessionStore.sessionsFlow().map { list ->
60
- list.takeCurrentUserWithNeighbors(matrixUser).toPersistentList()
60
+ combine(
61
+ client.userProfile.onEach { user ->
62
+ // Ensure that the profile is always up to date in our
63
+ // session storage when it changes
64
+ sessionStore.updateUserProfile(
65
+ sessionId = user.userId.value,
66
+ displayName = user.displayName,
67
+ avatarUrl = user.avatarUrl,
68
+ )
69
+ },
70
+ sessionStore.sessionsFlow()
71
+ ) { user, sessions ->
72
+ sessions.takeCurrentUserWithNeighbors(user).toPersistentList()
61
73
}
62
74
}.collectAsState(initial = persistentListOf(matrixUser))
63
75
val isOnline by syncService.isOnline.collectAsState()
@@ -76,15 +88,6 @@ class HomePresenter(
76
88
// Force a refresh of the profile
77
89
client.getUserProfile()
78
90
}
79
- LaunchedEffect (matrixUser) {
80
- // Ensure that the profile is always up to date in our
81
- // session storage when it changes
82
- sessionStore.updateUserProfile(
83
- sessionId = matrixUser.userId.value,
84
- displayName = matrixUser.displayName,
85
- avatarUrl = matrixUser.avatarUrl,
86
- )
87
- }
88
91
// Avatar indicator
89
92
val showAvatarIndicator by indicatorService.showRoomListTopBarIndicator()
90
93
val directLogoutState = logoutPresenter.present()
0 commit comments