Skip to content

Commit

Permalink
Fixes #1482 - Popping the user back to the home screen after leaving …
Browse files Browse the repository at this point in the history
…a room.
  • Loading branch information
stefanceriu committed Aug 13, 2021
1 parent 1a5f0ee commit f979240
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Riot/Modules/Room/RoomInfo/RoomInfoCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ extension RoomInfoCoordinator: RoomInfoListCoordinatorDelegate {
func roomInfoListCoordinatorDidCancel(_ coordinator: RoomInfoListCoordinatorType) {
self.delegate?.roomInfoCoordinatorDidComplete(self)
}

func roomInfoListCoordinatorDidLeaveRoom(_ coordinator: RoomInfoListCoordinatorType) {
self.delegate?.roomInfoCoordinatorDidLeaveRoom(self)
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Foundation
@objc protocol RoomInfoCoordinatorBridgePresenterDelegate {
func roomInfoCoordinatorBridgePresenterDelegateDidComplete(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter)
func roomInfoCoordinatorBridgePresenter(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter, didRequestMentionForMember member: MXRoomMember)
func roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter)
}

/// RoomInfoCoordinatorBridgePresenter enables to start RoomInfoCoordinator from a view controller.
Expand Down Expand Up @@ -120,6 +121,9 @@ extension RoomInfoCoordinatorBridgePresenter: RoomInfoCoordinatorDelegate {
self.delegate?.roomInfoCoordinatorBridgePresenter(self, didRequestMentionForMember: member)
}

func roomInfoCoordinatorDidLeaveRoom(_ coordinator: RoomInfoCoordinatorType) {
self.delegate?.roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom(self)
}
}

// MARK: - UIAdaptivePresentationControllerDelegate
Expand Down
1 change: 1 addition & 0 deletions Riot/Modules/Room/RoomInfo/RoomInfoCoordinatorType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Foundation
protocol RoomInfoCoordinatorDelegate: AnyObject {
func roomInfoCoordinatorDidComplete(_ coordinator: RoomInfoCoordinatorType)
func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, didRequestMentionForMember member: MXRoomMember)
func roomInfoCoordinatorDidLeaveRoom(_ coordinator: RoomInfoCoordinatorType)
}

/// `RoomInfoCoordinatorType` is a protocol describing a Coordinator that handle keybackup setup navigation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ extension RoomInfoListCoordinator: RoomInfoListViewModelCoordinatorDelegate {
func roomInfoListViewModelDidCancel(_ viewModel: RoomInfoListViewModelType) {
self.delegate?.roomInfoListCoordinatorDidCancel(self)
}

func roomInfoListViewModelDidLeaveRoom(_ viewModel: RoomInfoListViewModelType) {
self.delegate?.roomInfoListCoordinatorDidLeaveRoom(self)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Foundation
protocol RoomInfoListCoordinatorDelegate: AnyObject {
func roomInfoListCoordinator(_ coordinator: RoomInfoListCoordinatorType, wantsToNavigateTo target: RoomInfoListTarget)
func roomInfoListCoordinatorDidCancel(_ coordinator: RoomInfoListCoordinatorType)
func roomInfoListCoordinatorDidLeaveRoom(_ coordinator: RoomInfoListCoordinatorType)
}

/// `RoomInfoListCoordinatorType` is a protocol describing a Coordinator that handle key backup setup passphrase navigation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ final class RoomInfoListViewModel: NSObject, RoomInfoListViewModelType {
self.room.leave { (response) in
switch response {
case .success:
self.coordinatorDelegate?.roomInfoListViewModelDidCancel(self)
self.coordinatorDelegate?.roomInfoListViewModelDidLeaveRoom(self)
case .failure(let error):
self.startObservingSummaryChanges()
self.update(viewState: .error(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protocol RoomInfoListViewModelViewDelegate: AnyObject {

protocol RoomInfoListViewModelCoordinatorDelegate: AnyObject {
func roomInfoListViewModelDidCancel(_ viewModel: RoomInfoListViewModelType)
func roomInfoListViewModelDidLeaveRoom(_ viewModel: RoomInfoListViewModelType)
func roomInfoListViewModel(_ viewModel: RoomInfoListViewModelType, wantsToNavigateTo target: RoomInfoListTarget)
}

Expand Down
7 changes: 7 additions & 0 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ - (void)leaveRoomOnEvent:(MXEvent*)event
self.jumpToLastUnreadBannerContainer.hidden = YES;

[super leaveRoomOnEvent:event];

[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
}

// Set the input toolbar according to the current display
Expand Down Expand Up @@ -6146,6 +6148,11 @@ - (void)roomInfoCoordinatorBridgePresenter:(RoomInfoCoordinatorBridgePresenter *
[self mention:member];
}

- (void)roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom:(RoomInfoCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
}

#pragma mark - RemoveJitsiWidgetViewDelegate

- (void)removeJitsiWidgetViewDidCompleteSliding:(RemoveJitsiWidgetView *)view
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Room/Settings/RoomSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3494,7 +3494,7 @@ - (void)onLeave:(id)sender
[self startActivityIndicator];
[self->mxRoom leave:^{

[self withdrawViewControllerAnimated:YES completion:nil];
[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];

} failure:^(NSError *error) {

Expand Down
1 change: 1 addition & 0 deletions changelog.d/1482.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Popping the user back to the home screen after leaving a room.

0 comments on commit f979240

Please sign in to comment.