diff --git a/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersDataSource.kt b/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersDataSource.kt index 35fe657099385114c9413adc22beb3196cf6cc01..d804c1283eb119ef78c47cfd4b65c5961b7bb6e4 100644 --- a/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersDataSource.kt +++ b/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersDataSource.kt @@ -11,6 +11,7 @@ import org.futo.circles.model.NoResultsItem import org.futo.circles.model.UserListItem import org.futo.circles.provider.MatrixSessionProvider import org.matrix.android.sdk.api.session.getRoom +import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams import org.matrix.android.sdk.api.session.user.model.User class SelectUsersDataSource(roomId: String?) { @@ -25,6 +26,12 @@ class SelectUsersDataSource(roomId: String?) { val selectedUsersFlow = MutableStateFlow<List<UserListItem>>(emptyList()) + suspend fun loadAllRoomMembersIfNeeded(){ + session?.roomService()?.getRoomSummaries(roomSummaryQueryParams())?.forEach { + session.getRoom(it.roomId)?.membershipService()?.loadRoomMembersIfNeeded() + } + } + suspend fun search(query: String) = combine( searchKnownUsers(query), diff --git a/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersViewModel.kt b/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersViewModel.kt index 69c5e8e5205701d41e25ef2663693cea0e7e7f6f..87833f7b4acafe876e3db66a27410e2026f07873 100644 --- a/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersViewModel.kt +++ b/app/src/main/java/org/futo/circles/feature/room/select_users/SelectUsersViewModel.kt @@ -16,6 +16,10 @@ class SelectUsersViewModel( val searchUsersLiveData = MutableLiveData<List<InviteMemberListItem>>() val selectedUsersLiveData = dataSource.selectedUsersFlow.asLiveData() + init { + launchBg { dataSource.loadAllRoomMembersIfNeeded() } + } + fun initSearchListener(queryFlow: StateFlow<String>) { launchUi { queryFlow