Merge pull request #6110 from vector-im/defect/jorgem/PSE-613-fix-multi-invites-to-room
Fix sending multiple invites to a room reaching only one or two people
This commit is contained in:
commit
71e14ea43b
|
@ -0,0 +1 @@
|
||||||
|
Fix sending multiple invites to a room reaching only one or two people
|
|
@ -28,8 +28,9 @@ import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.userdirectory.PendingSelection
|
import im.vector.app.features.userdirectory.PendingSelection
|
||||||
import kotlinx.coroutines.flow.asFlow
|
import kotlinx.coroutines.flow.asFlow
|
||||||
import kotlinx.coroutines.flow.catch
|
import kotlinx.coroutines.flow.catch
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.flow.onCompletion
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.getRoom
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
|
|
||||||
|
@ -55,7 +56,6 @@ class InviteUsersToRoomViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun inviteUsersToRoom(selections: Set<PendingSelection>) {
|
private fun inviteUsersToRoom(selections: Set<PendingSelection>) {
|
||||||
viewModelScope.launch {
|
|
||||||
_viewEvents.post(InviteUsersToRoomViewEvents.Loading)
|
_viewEvents.post(InviteUsersToRoomViewEvents.Loading)
|
||||||
selections.asFlow()
|
selections.asFlow()
|
||||||
.map { user ->
|
.map { user ->
|
||||||
|
@ -63,11 +63,9 @@ class InviteUsersToRoomViewModel @AssistedInject constructor(
|
||||||
is PendingSelection.UserPendingSelection -> room.membershipService().invite(user.user.userId, null)
|
is PendingSelection.UserPendingSelection -> room.membershipService().invite(user.user.userId, null)
|
||||||
is PendingSelection.ThreePidPendingSelection -> room.membershipService().invite3pid(user.threePid)
|
is PendingSelection.ThreePidPendingSelection -> room.membershipService().invite3pid(user.threePid)
|
||||||
}
|
}
|
||||||
}
|
}.onCompletion { error ->
|
||||||
.catch { cause ->
|
if (error != null) return@onCompletion
|
||||||
_viewEvents.post(InviteUsersToRoomViewEvents.Failure(cause))
|
|
||||||
}
|
|
||||||
.collect {
|
|
||||||
val successMessage = when (selections.size) {
|
val successMessage = when (selections.size) {
|
||||||
1 -> stringProvider.getString(
|
1 -> stringProvider.getString(
|
||||||
R.string.invitation_sent_to_one_user,
|
R.string.invitation_sent_to_one_user,
|
||||||
|
@ -87,7 +85,9 @@ class InviteUsersToRoomViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
_viewEvents.post(InviteUsersToRoomViewEvents.Success(successMessage))
|
_viewEvents.post(InviteUsersToRoomViewEvents.Success(successMessage))
|
||||||
}
|
}
|
||||||
}
|
.catch { cause ->
|
||||||
|
_viewEvents.post(InviteUsersToRoomViewEvents.Failure(cause))
|
||||||
|
}.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUserIdsOfRoomMembers(): Set<String> {
|
fun getUserIdsOfRoomMembers(): Set<String> {
|
||||||
|
|
Loading…
Reference in New Issue