-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
join and leave methods moved from MembershipService to RoomService an… #5183
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,10 @@ internal class DefaultSpaceService @Inject constructor( | |
return joinSpaceTask.execute(JoinSpaceTask.Params(spaceIdOrAlias, reason, viaServers)) | ||
} | ||
|
||
override suspend fun leaveSpace(roomId: String, reason: String?) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spaceId instead of roomId? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initially changed to spaceId, but since we use Room for Space sometimes wasn't sure if it won't be confusing. Like |
||
leaveRoomTask.execute(LeaveRoomTask.Params(roomId, reason)) | ||
} | ||
|
||
override suspend fun rejectInvite(spaceId: String, reason: String?) { | ||
leaveRoomTask.execute(LeaveRoomTask.Params(spaceId, reason)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ class RoomListViewModel @AssistedInject constructor( | |
val room = session.getRoom(roomId) ?: return@withState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this line? |
||
viewModelScope.launch { | ||
try { | ||
room.join() | ||
session.joinRoom(room.roomId) | ||
analyticsTracker.capture(action.roomSummary.toAnalyticsJoinedRoom()) | ||
// 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 | ||
|
@@ -245,10 +245,9 @@ class RoomListViewModel @AssistedInject constructor( | |
return@withState | ||
} | ||
|
||
val room = session.getRoom(roomId) ?: return@withState | ||
viewModelScope.launch { | ||
try { | ||
room.leave(null) | ||
session.leaveRoom(roomId) | ||
// 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. | ||
|
@@ -333,9 +332,8 @@ class RoomListViewModel @AssistedInject constructor( | |
|
||
private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) { | ||
_viewEvents.post(RoomListViewEvents.Loading(null)) | ||
val room = session.getRoom(action.roomId) ?: return | ||
viewModelScope.launch { | ||
val value = runCatching { room.leave(null) } | ||
val value = runCatching { session.leaveRoom(action.roomId) } | ||
.fold({ RoomListViewEvents.Done }, { RoomListViewEvents.Failure(it) }) | ||
_viewEvents.post(value) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,14 +72,14 @@ class SpaceLeaveAdvancedViewModel @AssistedInject constructor( | |
try { | ||
state.selectedRooms.forEach { | ||
try { | ||
session.getRoom(it)?.leave(null) | ||
session.leaveRoom(it) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Behind the scene I think this is equivalent to leave a room or a space, but can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far i understand we leave all selected rooms in a space here. Maybe there could be also subspaces, but I think rooms is more often and more relevant here. |
||
} catch (failure: Throwable) { | ||
// silently ignore? | ||
Timber.e(failure, "Fail to leave sub rooms/spaces") | ||
} | ||
} | ||
|
||
session.getRoom(initialState.spaceId)?.leave(null) | ||
session.spaceService().leaveSpace(initialState.spaceId) | ||
// We observe the membership and to dismiss when we have remote echo of leaving | ||
} catch (failure: Throwable) { | ||
setState { copy(leaveState = Fail(failure)) } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaceId instead of roomId?