diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt index b938f60e39..21db4e1893 100644 --- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxRoom.kt @@ -21,6 +21,7 @@ import io.reactivex.Completable import io.reactivex.Observable import io.reactivex.Single import kotlinx.coroutines.rx2.rxCompletable +import kotlinx.coroutines.rx2.rxSingle import org.matrix.android.sdk.api.query.QueryStringValue import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.identity.ThreePid @@ -90,13 +91,13 @@ class RxRoom(private val room: Room) { return room.getMyReadReceiptLive().asObservable() } - fun loadRoomMembersIfNeeded(): Single = singleBuilder { - room.loadRoomMembersIfNeeded(it) + fun loadRoomMembersIfNeeded(): Single = rxSingle { + room.loadRoomMembersIfNeeded() } fun joinRoom(reason: String? = null, - viaServers: List = emptyList()): Single = singleBuilder { - room.join(reason, viaServers, it) + viaServers: List = emptyList()): Single = rxSingle { + room.join(reason, viaServers) } fun liveEventReadReceipts(eventId: String): Observable> { @@ -114,12 +115,12 @@ class RxRoom(private val room: Room) { return room.getLiveRoomNotificationState().asObservable() } - fun invite(userId: String, reason: String? = null): Completable = completableBuilder { - room.invite(userId, reason, it) + fun invite(userId: String, reason: String? = null): Completable = rxCompletable { + room.invite(userId, reason) } - fun invite3pid(threePid: ThreePid): Completable = completableBuilder { - room.invite3pid(threePid, it) + fun invite3pid(threePid: ThreePid): Completable = rxCompletable { + room.invite3pid(threePid) } fun updateTopic(topic: String): Completable = rxCompletable { diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt index 12f7928835..5815b23c06 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt @@ -112,8 +112,8 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) { bobRoomSummariesLive.observeForever(newRoomObserver) } - mTestHelper.doSync { - aliceRoom.invite(bobSession.myUserId, callback = it) + mTestHelper.runBlockingTest { + aliceRoom.invite(bobSession.myUserId) } mTestHelper.await(lock1) @@ -172,8 +172,8 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) { fun createSamAccountAndInviteToTheRoom(room: Room): Session { val samSession = mTestHelper.createAccount(TestConstants.USER_SAM, defaultSessionParams) - mTestHelper.doSync { - room.invite(samSession.myUserId, null, it) + mTestHelper.runBlockingTest { + room.invite(samSession.myUserId, null) } mTestHelper.doSync { @@ -410,7 +410,7 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) { val sessions = mutableListOf(aliceSession) for (index in 1 until numberOfMembers) { val session = mTestHelper.createAccount("User_$index", defaultSessionParams) - mTestHelper.doSync(timeout = 600_000) { room.invite(session.myUserId, null, it) } + mTestHelper.runBlockingTest(timeout = 600_000) { room.invite(session.myUserId, null) } println("TEST -> " + session.myUserId + " invited") mTestHelper.doSync { session.joinRoom(room.roomId, null, emptyList(), it) } println("TEST -> " + session.myUserId + " joined") diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt index 8c3917adc1..e6b364f3fb 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/KeyShareTests.kt @@ -367,8 +367,8 @@ class KeyShareTests : InstrumentedTest { } // Let alice invite bob - mTestHelper.doSync { - roomAlicePov.invite(bobSession.myUserId, null, it) + mTestHelper.runBlockingTest { + roomAlicePov.invite(bobSession.myUserId, null) } mTestHelper.doSync { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt index 2c3ffac687..198d6677a0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt @@ -17,10 +17,8 @@ package org.matrix.android.sdk.api.session.room.members import androidx.lifecycle.LiveData -import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.session.identity.ThreePid import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary -import org.matrix.android.sdk.api.util.Cancelable /** * This interface defines methods to handling membership. It's implemented at the room level. @@ -29,9 +27,8 @@ interface MembershipService { /** * This methods load all room members if it was done yet. - * @return a [Cancelable] */ - fun loadRoomMembersIfNeeded(matrixCallback: MatrixCallback): Cancelable + suspend fun loadRoomMembersIfNeeded() /** * Return the roomMember with userId or null. @@ -60,47 +57,35 @@ interface MembershipService { /** * Invite a user in the room */ - fun invite(userId: String, - reason: String? = null, - callback: MatrixCallback): Cancelable + suspend fun invite(userId: String, reason: String? = null) /** * Invite a user with email or phone number in the room */ - fun invite3pid(threePid: ThreePid, - callback: MatrixCallback): Cancelable + suspend fun invite3pid(threePid: ThreePid) /** * Ban a user from the room */ - fun ban(userId: String, - reason: String? = null, - callback: MatrixCallback): Cancelable + suspend fun ban(userId: String, reason: String? = null) /** * Unban a user from the room */ - fun unban(userId: String, - reason: String? = null, - callback: MatrixCallback): Cancelable + suspend fun unban(userId: String, reason: String? = null) /** * Kick a user from the room */ - fun kick(userId: String, - reason: String? = null, - callback: MatrixCallback): Cancelable + suspend fun kick(userId: String, reason: String? = null) /** * Join the room, or accept an invitation. */ - fun join(reason: String? = null, - viaServers: List = emptyList(), - callback: MatrixCallback): Cancelable + suspend fun join(reason: String? = null, viaServers: List = emptyList()) /** * Leave the room, or reject an invitation. */ - fun leave(reason: String? = null, - callback: MatrixCallback): Cancelable + suspend fun leave(reason: String? = null) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt index cd1c9bbbdd..41e891f78e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt @@ -21,13 +21,11 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedInject import dagger.assisted.AssistedFactory import com.zhuinden.monarchy.Monarchy -import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.session.identity.ThreePid import org.matrix.android.sdk.api.session.room.members.MembershipService import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary -import org.matrix.android.sdk.api.util.Cancelable import org.matrix.android.sdk.internal.database.mapper.asDomain import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntity import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntityFields @@ -39,8 +37,6 @@ import org.matrix.android.sdk.internal.session.room.membership.joining.InviteTas import org.matrix.android.sdk.internal.session.room.membership.joining.JoinRoomTask import org.matrix.android.sdk.internal.session.room.membership.leaving.LeaveRoomTask import org.matrix.android.sdk.internal.session.room.membership.threepid.InviteThreePidTask -import org.matrix.android.sdk.internal.task.TaskExecutor -import org.matrix.android.sdk.internal.task.configureWith import org.matrix.android.sdk.internal.util.fetchCopied import io.realm.Realm import io.realm.RealmQuery @@ -48,7 +44,6 @@ import io.realm.RealmQuery internal class DefaultMembershipService @AssistedInject constructor( @Assisted private val roomId: String, @SessionDatabase private val monarchy: Monarchy, - private val taskExecutor: TaskExecutor, private val loadRoomMembersTask: LoadRoomMembersTask, private val inviteTask: InviteTask, private val inviteThreePidTask: InviteThreePidTask, @@ -64,13 +59,9 @@ internal class DefaultMembershipService @AssistedInject constructor( fun create(roomId: String): DefaultMembershipService } - override fun loadRoomMembersIfNeeded(matrixCallback: MatrixCallback): Cancelable { + override suspend fun loadRoomMembersIfNeeded() { val params = LoadRoomMembersTask.Params(roomId, Membership.LEAVE) - return loadRoomMembersTask - .configureWith(params) { - this.callback = matrixCallback - } - .executeBy(taskExecutor) + loadRoomMembersTask.execute(params) } override fun getRoomMember(userId: String): RoomMemberSummary? { @@ -120,66 +111,38 @@ internal class DefaultMembershipService @AssistedInject constructor( } } - override fun ban(userId: String, reason: String?, callback: MatrixCallback): Cancelable { + override suspend fun ban(userId: String, reason: String?) { val params = MembershipAdminTask.Params(MembershipAdminTask.Type.BAN, roomId, userId, reason) - return membershipAdminTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + membershipAdminTask.execute(params) } - override fun unban(userId: String, reason: String?, callback: MatrixCallback): Cancelable { + override suspend fun unban(userId: String, reason: String?) { val params = MembershipAdminTask.Params(MembershipAdminTask.Type.UNBAN, roomId, userId, reason) - return membershipAdminTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + membershipAdminTask.execute(params) } - override fun kick(userId: String, reason: String?, callback: MatrixCallback): Cancelable { + override suspend fun kick(userId: String, reason: String?) { val params = MembershipAdminTask.Params(MembershipAdminTask.Type.KICK, roomId, userId, reason) - return membershipAdminTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + membershipAdminTask.execute(params) } - override fun invite(userId: String, reason: String?, callback: MatrixCallback): Cancelable { + override suspend fun invite(userId: String, reason: String?) { val params = InviteTask.Params(roomId, userId, reason) - return inviteTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + inviteTask.execute(params) } - override fun invite3pid(threePid: ThreePid, callback: MatrixCallback): Cancelable { + override suspend fun invite3pid(threePid: ThreePid) { val params = InviteThreePidTask.Params(roomId, threePid) - return inviteThreePidTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + return inviteThreePidTask.execute(params) } - override fun join(reason: String?, viaServers: List, callback: MatrixCallback): Cancelable { + override suspend fun join(reason: String?, viaServers: List) { val params = JoinRoomTask.Params(roomId, reason, viaServers) - return joinTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + joinTask.execute(params) } - override fun leave(reason: String?, callback: MatrixCallback): Cancelable { + override suspend fun leave(reason: String?) { val params = LeaveRoomTask.Params(roomId, reason) - return leaveRoomTask - .configureWith(params) { - this.callback = callback - } - .executeBy(taskExecutor) + leaveRoomTask.execute(params) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 537f625a79..e859d001b7 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -945,14 +945,14 @@ class RoomDetailViewModel @AssistedInject constructor( } private fun handleInviteSlashCommand(invite: ParsedCommand.Invite) { - launchSlashCommandFlow { - room.invite(invite.userId, invite.reason, it) + launchSlashCommandFlowSuspendable { + room.invite(invite.userId, invite.reason) } } private fun handleInvite3pidSlashCommand(invite: ParsedCommand.Invite3Pid) { - launchSlashCommandFlow { - room.invite3pid(invite.threePid, it) + launchSlashCommandFlowSuspendable { + room.invite3pid(invite.threePid) } } @@ -976,20 +976,20 @@ class RoomDetailViewModel @AssistedInject constructor( } private fun handleKickSlashCommand(kick: ParsedCommand.KickUser) { - launchSlashCommandFlow { - room.kick(kick.userId, kick.reason, it) + launchSlashCommandFlowSuspendable { + room.kick(kick.userId, kick.reason) } } private fun handleBanSlashCommand(ban: ParsedCommand.BanUser) { - launchSlashCommandFlow { - room.ban(ban.userId, ban.reason, it) + launchSlashCommandFlowSuspendable { + room.ban(ban.userId, ban.reason) } } private fun handleUnbanSlashCommand(unban: ParsedCommand.UnbanUser) { - launchSlashCommandFlow { - room.unban(unban.userId, unban.reason, it) + launchSlashCommandFlowSuspendable { + room.unban(unban.userId, unban.reason) } } @@ -1093,11 +1093,21 @@ class RoomDetailViewModel @AssistedInject constructor( } private fun handleRejectInvite() { - room.leave(null, NoOpMatrixCallback()) + viewModelScope.launch { + try { + room.leave(null) + } catch (_: Exception) { + } + } } private fun handleAcceptInvite() { - room.join(callback = NoOpMatrixCallback()) + viewModelScope.launch { + try { + room.join() + } catch (_: Exception) { + } + } } private fun handleEditAction(action: RoomDetailAction.EnterEditMode) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index 6e5081a31c..3a5e797f98 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -26,7 +26,6 @@ import im.vector.app.core.utils.DataSource import io.reactivex.schedulers.Schedulers import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.NoOpMatrixCallback import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.Session @@ -127,17 +126,17 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, return@withState } - session.getRoom(roomId)?.join(callback = object : MatrixCallback { - override fun onSuccess(data: Unit) { + val room = session.getRoom(roomId) ?: return@withState + viewModelScope.launch { + try { + room.join() // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined - } - - override fun onFailure(failure: Throwable) { + } catch (failure: Throwable) { // Notify the user _viewEvents.post(RoomListViewEvents.Failure(failure)) } - }) + } } private fun handleRejectInvitation(action: RoomListAction.RejectInvitation) = withState { state -> @@ -149,19 +148,19 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, return@withState } - session.getRoom(roomId)?.leave(null, object : MatrixCallback { - override fun onSuccess(data: Unit) { + val room = session.getRoom(roomId) ?: return@withState + viewModelScope.launch { + try { + room.leave(null) // We do not update the rejectingRoomsIds here, because, the room is not rejected yet regarding the sync data. // Instead, we wait for the room to be rejected // Known bug: if the user is invited again (after rejecting the first invitation), the loading will be displayed instead of the buttons. // If we update the state, the button will be displayed again, so it's not ideal... - } - - override fun onFailure(failure: Throwable) { + } catch (failure: Throwable) { // Notify the user _viewEvents.post(RoomListViewEvents.Failure(failure)) } - }) + } } private fun handleMarkAllRoomsRead() = withState { state -> @@ -220,15 +219,12 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) { _viewEvents.post(RoomListViewEvents.Loading(null)) - session.getRoom(action.roomId)?.leave(null, object : MatrixCallback { - override fun onSuccess(data: Unit) { - _viewEvents.post(RoomListViewEvents.Done) - } - - override fun onFailure(failure: Throwable) { - _viewEvents.post(RoomListViewEvents.Failure(failure)) - } - }) + val room = session.getRoom(action.roomId) ?: return + viewModelScope.launch { + val value = runCatching { room.leave(null) } + .fold({ RoomListViewEvents.Done }, { RoomListViewEvents.Failure(it) }) + _viewEvents.post(value) + } } private fun observeMembershipChanges() { diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt index 9dd41e4cea..7b0707ad61 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationBroadcastReceiver.kt @@ -76,15 +76,23 @@ class NotificationBroadcastReceiver : BroadcastReceiver() { private fun handleJoinRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> - session.getRoom(roomId) - ?.join(callback = NoOpMatrixCallback()) + val room = session.getRoom(roomId) + if (room != null) { + GlobalScope.launch { + room.join() + } + } } } private fun handleRejectRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> - session.getRoom(roomId) - ?.leave(callback = NoOpMatrixCallback()) + val room = session.getRoom(roomId) + if (room != null) { + GlobalScope.launch { + room.leave() + } + } } } diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt index 108841faa0..64081a1683 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -52,7 +52,6 @@ import org.matrix.android.sdk.api.session.room.powerlevels.Role import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toOptional -import org.matrix.android.sdk.internal.util.awaitCallback import org.matrix.android.sdk.rx.rx import org.matrix.android.sdk.rx.unwrap @@ -197,9 +196,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v viewModelScope.launch { try { _viewEvents.post(RoomMemberProfileViewEvents.Loading()) - awaitCallback { - room.invite(initialState.userId, callback = it) - } + room.invite(initialState.userId) _viewEvents.post(RoomMemberProfileViewEvents.OnInviteActionSuccess) } catch (failure: Throwable) { _viewEvents.post(RoomMemberProfileViewEvents.Failure(failure)) @@ -214,9 +211,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v viewModelScope.launch { try { _viewEvents.post(RoomMemberProfileViewEvents.Loading()) - awaitCallback { - room.kick(initialState.userId, action.reason, it) - } + room.kick(initialState.userId, action.reason) _viewEvents.post(RoomMemberProfileViewEvents.OnKickActionSuccess) } catch (failure: Throwable) { _viewEvents.post(RoomMemberProfileViewEvents.Failure(failure)) @@ -232,12 +227,10 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v viewModelScope.launch { try { _viewEvents.post(RoomMemberProfileViewEvents.Loading()) - awaitCallback { - if (membership == Membership.BAN) { - room.unban(initialState.userId, action.reason, it) - } else { - room.ban(initialState.userId, action.reason, it) - } + if (membership == Membership.BAN) { + room.unban(initialState.userId, action.reason) + } else { + room.ban(initialState.userId, action.reason) } _viewEvents.post(RoomMemberProfileViewEvents.OnBanActionSuccess) } catch (failure: Throwable) { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt index c8bb6b5b5c..209ebcc35b 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt @@ -32,7 +32,6 @@ import im.vector.app.features.home.ShortcutCreator import im.vector.app.features.powerlevel.PowerLevelsObservableFactory import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.query.QueryStringValue import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.events.model.EventType @@ -169,15 +168,14 @@ class RoomProfileViewModel @AssistedInject constructor( private fun handleLeaveRoom() { _viewEvents.post(RoomProfileViewEvents.Loading(stringProvider.getString(R.string.room_profile_leaving_room))) - room.leave(null, object : MatrixCallback { - override fun onSuccess(data: Unit) { + viewModelScope.launch { + try { + room.leave(null) // Do nothing, we will be closing the room automatically when it will get back from sync - } - - override fun onFailure(failure: Throwable) { + } catch (failure: Throwable) { _viewEvents.post(RoomProfileViewEvents.Failure(failure)) } - }) + } } private fun handleShareRoomProfile() { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/banned/RoomBannedMemberListViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/banned/RoomBannedMemberListViewModel.kt index 5663392c6c..9e12e30399 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/banned/RoomBannedMemberListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/banned/RoomBannedMemberListViewModel.kt @@ -39,7 +39,6 @@ import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomMemberContent import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper -import org.matrix.android.sdk.internal.util.awaitCallback import org.matrix.android.sdk.rx.rx import org.matrix.android.sdk.rx.unwrap @@ -124,9 +123,7 @@ class RoomBannedMemberListViewModel @AssistedInject constructor(@Assisted initia } viewModelScope.launch(Dispatchers.IO) { try { - awaitCallback { - room.unban(roomMemberSummary.userId, null, it) - } + room.unban(roomMemberSummary.userId, null) } catch (failure: Throwable) { _viewEvents.post(RoomBannedMemberListViewEvents.ToastError(stringProvider.getString(R.string.failed_to_unban))) } finally { diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetPostAPIHandler.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetPostAPIHandler.kt index e20c8cf4c6..c05956bea2 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetPostAPIHandler.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetPostAPIHandler.kt @@ -387,7 +387,9 @@ class WidgetPostAPIHandler @AssistedInject constructor(@Assisted private val roo if (member != null && member.membership == Membership.JOIN) { widgetPostAPIMediator.sendSuccess(eventData) } else { - room.invite(userId = userId, callback = createWidgetAPICallback(widgetPostAPIMediator, eventData)) + launchWidgetAPIAction(widgetPostAPIMediator, eventData) { + room.invite(userId = userId) + } } }