Skip to content

Commit

Permalink
selection impossible when filtering in add room screen #5757 (#5758)
Browse files Browse the repository at this point in the history
- Fixed
- Other minor code / UI tweaks
  • Loading branch information
gileluard authored Mar 7, 2022
1 parent aadf1b7 commit 5fef457
Show file tree
Hide file tree
Showing 30 changed files with 64 additions and 31 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 @@ -247,4 +247,8 @@ extension RoomInfoCoordinator: RoomSettingsViewControllerDelegate {
func roomSettingsViewController(_ controller: RoomSettingsViewController!, didReplaceRoomWithReplacementId newRoomId: String!) {
self.delegate?.roomInfoCoordinator(self, didReplaceRoomWithReplacementId: newRoomId)
}

func roomSettingsViewControllerDidLeaveRoom(_ controller: RoomSettingsViewController!) {
self.delegate?.roomInfoCoordinatorDidLeaveRoom(self)
}
}
5 changes: 0 additions & 5 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2260,12 +2260,7 @@ - (void)leaveRoom
- (void)notifyDelegateOnLeaveRoomIfNecessary {
if (self.delegate)
{
// Leaving room often triggers multiple events, incl local delegate callbacks as well as global notifications,
// which may lead to multiple identical UI changes (navigating to home, displaying notification etc).
// To avoid this, as soon as we notify the delegate the first time, we nilify it, preventing future messages
// from being passed along, assuming that after leaving a room there is nothing else to communicate to the delegate.
[self.delegate roomViewControllerDidLeaveRoom:self];
self.delegate = nil;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions Riot/Modules/Room/Settings/RoomSettingsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ typedef enum : NSUInteger {

@protocol RoomSettingsViewControllerDelegate <NSObject>

- (void)roomSettingsViewControllerDidLeaveRoom:(RoomSettingsViewController *)controller;

- (void)roomSettingsViewController:(RoomSettingsViewController *)controller didReplaceRoomWithReplacementId:(NSString *)newRoomId;

- (void)roomSettingsViewControllerDidCancel:(RoomSettingsViewController *)controller;
Expand Down
6 changes: 5 additions & 1 deletion Riot/Modules/Room/Settings/RoomSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3667,7 +3667,11 @@ - (void)onLeave:(id)sender
[self startActivityIndicator];
[self->mxRoom leave:^{

[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
if (self.delegate) {
[self.delegate roomSettingsViewControllerDidLeaveRoom:self];
} else {
[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
}

} failure:^(NSError *error) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ extension SpaceMembersCoordinator: SpaceMemberListCoordinatorDelegate {
return
}

let coordinator = ContactsPickerCoordinator(session: self.parameters.session, room: spaceRoom, initialSearchText: nil, actualParticipants: nil, invitedParticipants: nil, userParticipant: nil, navigationRouter: self.navigationRouter)
let coordinator = ContactsPickerCoordinator(session: self.parameters.session, room: spaceRoom, initialSearchText: nil, actualParticipants: nil, invitedParticipants: nil, userParticipant: nil)
coordinator.delegate = self
coordinator.start()
self.childCoordinators.append(coordinator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ extension SpaceExploreRoomCoordinator: SpaceExploreRoomViewModelCoordinatorDeleg
}
}

func spaceExploreRoomViewModel(_ coordinator: SpaceExploreRoomViewModelType, didJoin item: SpaceExploreRoomListItemViewData) {
self.delegate?.spaceExploreRoomCoordinator(self, didJoin: item)
}

private func showAddRoomMissingPermissionAlert() {
let alert = UIAlertController(title: VectorL10n.spacesAddRoom, message: VectorL10n.spacesAddRoomMissingPermissionMessage, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: VectorL10n.ok, style: .default, handler: nil))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protocol SpaceExploreRoomCoordinatorDelegate: AnyObject {
func spaceExploreRoomCoordinatorDidAddRoom(_ coordinator: SpaceExploreRoomCoordinatorType)
func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, openSettingsOf item: SpaceExploreRoomListItemViewData)
func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, inviteTo item: SpaceExploreRoomListItemViewData)
func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, didJoin item: SpaceExploreRoomListItemViewData)
}

/// `SpaceExploreRoomCoordinatorType` 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 @@ -118,7 +118,7 @@ final class SpaceExploreRoomViewModel: SpaceExploreRoomViewModelType {
case .removeChild(let item):
removeChild(withRoomId: item.childInfo.childRoomId)
case .join(let item):
joinRoom(withRoomId: item.childInfo.childRoomId)
joinRoom(with: item)
case .joinOpenedSpace:
self.joinSpace()
}
Expand All @@ -134,7 +134,7 @@ final class SpaceExploreRoomViewModel: SpaceExploreRoomViewModelType {
canSendSpaceStateEvents = false
}

let roomSummary = session.roomSummary(withRoomId: itemData.childInfo.childRoomId)
let roomSummary = session.room(withRoomId: itemData.childInfo.childRoomId)?.summary
let isJoined = roomSummary?.isJoined ?? false

if itemData.childInfo.roomType == .space {
Expand Down Expand Up @@ -292,13 +292,14 @@ final class SpaceExploreRoomViewModel: SpaceExploreRoomViewModelType {
}
}

private func joinRoom(withRoomId roomId: String) {
private func joinRoom(with itemData: SpaceExploreRoomListItemViewData) {
self.update(viewState: .loading)
self.session.joinRoom(roomId) { [weak self] response in
self.session.joinRoom(itemData.childInfo.childRoomId) { [weak self] response in
guard let self = self else { return }
switch response {
case .success:
self.update(viewState: .loaded(self.filteredItemDataList, self.hasMore))
self.coordinatorDelegate?.spaceExploreRoomViewModel(self, didJoin: itemData)
case .failure(let error):
self.update(viewState: .error(error))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protocol SpaceExploreRoomViewModelCoordinatorDelegate: AnyObject {
func spaceExploreRoomViewModelDidAddRoom(_ viewModel: SpaceExploreRoomViewModelType)
func spaceExploreRoomViewModel(_ viewModel: SpaceExploreRoomViewModelType, openSettingsOf item: SpaceExploreRoomListItemViewData)
func spaceExploreRoomViewModel(_ viewModel: SpaceExploreRoomViewModelType, inviteTo item: SpaceExploreRoomListItemViewData)
func spaceExploreRoomViewModel(_ viewModel: SpaceExploreRoomViewModelType, didJoin item: SpaceExploreRoomListItemViewData)
}

/// Protocol describing the view model used by `SpaceExploreRoomViewController`
Expand Down
10 changes: 9 additions & 1 deletion Riot/Modules/Spaces/SpaceRoomList/ExploreRoomCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ final class ExploreRoomCoordinator: NSObject, ExploreRoomCoordinatorType {
self.remove(childCoordinator: currentCoordinator)
}

let summary = self.session.roomSummary(withRoomId: item.childInfo.childRoomId)
let summary = self.session.room(withRoomId: item.childInfo.childRoomId)?.summary
let isJoined = summary?.isJoined ?? false

if isJoined {
Expand Down Expand Up @@ -291,6 +291,14 @@ extension ExploreRoomCoordinator: SpaceExploreRoomCoordinatorDelegate {
func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, inviteTo item: SpaceExploreRoomListItemViewData) {
self.presentInviteScreen(forRoomWithId: item.childInfo.childRoomId)
}

func spaceExploreRoomCoordinator(_ coordinator: SpaceExploreRoomCoordinatorType, didJoin item: SpaceExploreRoomListItemViewData) {
if item.childInfo.roomType == .space {
self.pushSpace(with: item)
} else {
self.navigateTo(roomWith: item.childInfo.childRoomId)
}
}
}

// MARK: - ShowSpaceChildRoomDetailCoordinator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class SpaceChildRoomDetailViewModel: SpaceChildRoomDetailViewModelType {
private var currentOperation: MXHTTPOperation?
private var userDisplayName: String?
private var isRoomJoined: Bool {
let summary = self.session.roomSummary(withRoomId: self.childInfo.childRoomId)
let summary = self.session.room(withRoomId: self.childInfo.childRoomId)?.summary
return summary?.isJoined ?? false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct RoomAccessTypeChooser: View {
listContent
.waitOverlay(show: viewModel.isLoading, message: viewModel.waitingMessage, allowUserInteraction: false)
.navigationTitle(VectorL10n.roomAccessSettingsScreenNavTitle)
.background(theme.colors.background.ignoresSafeArea())
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button(VectorL10n.cancel) {
Expand Down Expand Up @@ -77,7 +78,7 @@ struct RoomAccessTypeChooser: View {
.padding(.top, 30)
}
.padding(.horizontal)
}.background(theme.colors.background)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct AddRoomSelector: View {

var body: some View {
MatrixItemChooser(viewModel: viewModel, listBottomPadding: nil)
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.navigationBarItems(leading: cancelButton, trailing: doneButton)
.accentColor(theme.colors.accent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,20 @@ enum MatrixListItemDataType {
}

struct MatrixListItemSectionData {
let id = UUID().uuidString
let id: String
let title: String?
let infoText: String?
let items: [MatrixListItemData]

init(id: String = UUID().uuidString,
title: String? = nil,
infoText: String? = nil,
items: [MatrixListItemData] = []) {
self.id = id
self.title = title
self.infoText = infoText
self.items = items
}
}

extension MatrixListItemSectionData: Identifiable, Equatable {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum MockMatrixItemChooserScreenState: MockScreenState, CaseIterable {
let service: MockMatrixItemChooserService
switch self {
case .noItems:
service = MockMatrixItemChooserService(type: .room, sections: [MatrixListItemSectionData(title: nil, infoText: nil, items: [])])
service = MockMatrixItemChooserService(type: .room, sections: [MatrixListItemSectionData()])
case .items:
service = MockMatrixItemChooserService()
case .selectedItems:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MatrixItemChooserRoomAncestorsDataSource: MatrixItemChooserDataSource {
let ancestorsIds = session.spaceService.ancestorsPerRoomId[roomId] ?? []
completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource

completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MatrixItemChooserRoomRestrictedAllowedParentsDataSource: MatrixItemChooser
var sections = [
MatrixListItemSectionData(
title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(room.displayName ?? ""),
infoText: nil,
items: ancestorsId.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MatrixItemChooserRoomsDataSource: MatrixItemChooserDataSource {
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
completion(Result(catching: {
[
MatrixListItemSectionData(title: nil, infoText: nil, items: session.rooms.compactMap { room in
MatrixListItemSectionData(items: session.rooms.compactMap { room in
if room.summary.roomType == .space || room.isDirect {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
itemsProcessor.isItemIncluded($0) && ($0.id.lowercased().contains(lowercasedSearchText) || ($0.displayName ?? "").lowercased().contains(lowercasedSearchText))
}
}
newSections.append(MatrixListItemSectionData(title: section.title, infoText: section.infoText, items: items))
newSections.append(MatrixListItemSectionData(id: section.id, title: section.title, infoText: section.infoText, items: items))
}

return newSections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MatrixItemChooserUsersDataSource: MatrixItemChooserDataSource {
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
completion(Result(catching: {
[
MatrixListItemSectionData(title: nil, infoText: nil, items: session.users().map { user in
MatrixListItemSectionData(items: session.users().map { user in
MatrixListItemData(mxUser: user)
})
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct SpaceCreationEmailInvites: View {
.animation(.easeInOut(duration: 0.2), value: viewModel.viewState.loading)
.waitOverlay(show: viewModel.viewState.loading)
}
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.navigationBarHidden(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct SpaceCreationMatrixItemChooser: View {
}
mainView
}
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.navigationBarHidden(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct SpaceCreationMenu: View {
}
.padding(EdgeInsets(top: 0, leading: 16, bottom: 24, trailing: 16))
}
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct SpaceCreationPostProcess: View {
.animation(.easeIn(duration: 0.2), value: viewModel.viewState.errorCount)
.padding(EdgeInsets(top: 0, leading: 16, bottom: 24, trailing: 16))
.navigationBarHidden(true)
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.frame(maxHeight: .infinity)
.onAppear() {
viewModel.send(viewAction: .runTasks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SpaceCreationRooms: View {
}
mainView
}
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.navigationBarHidden(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct SpaceCreationSettings: View {
}
mainView
}
.background(theme.colors.background)
.background(theme.colors.background.ignoresSafeArea())
.navigationBarHidden(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ final class SpaceSettingsCoordinator: Coordinator, Presentable {
let view = SpaceSettings(viewModel: viewModel.context)
.addDependency(AvatarService.instantiate(mediaManager: parameters.session.mediaManager))
spaceSettingsViewModel = viewModel
spaceSettingsHostingController = VectorHostingController(rootView: view)
let controller = VectorHostingController(rootView: view)
controller.enableNavigationBarScrollEdgesAppearance = true
spaceSettingsHostingController = controller
}

// MARK: - Public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SpaceSettings: View {
.padding(.bottom, 32)
}
}
.background(theme.colors.navigation)
.background(theme.colors.navigation.ignoresSafeArea())
.waitOverlay(show: viewModel.viewState.isLoading, allowUserInteraction: false)
.ignoresSafeArea(.container, edges: .bottom)
.frame(maxHeight: .infinity)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5757.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Selection impossible when filtering in add room screen.

0 comments on commit 5fef457

Please sign in to comment.