Skip to content

Commit

Permalink
[Spaces] M10.6.1 Handle space link #4498
Browse files Browse the repository at this point in the history
- Update after code review
  • Loading branch information
gileluard committed Sep 23, 2021
1 parent 5b50ce2 commit ca7bf18
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 46 deletions.
54 changes: 27 additions & 27 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2084,23 +2084,23 @@ public class VectorL10n: NSObject {
return VectorL10n.tr("Vector", "leave")
}
/// Leave all rooms and spaces
internal static var leaveSpaceAndAllRoomsAction: String {
public static var leaveSpaceAndAllRoomsAction: String {
return VectorL10n.tr("Vector", "leave_space_and_all_rooms_action")
}
/// Are you sure you want to leave %@? Do you also want to leave all rooms and spaces of this space?
internal static func leaveSpaceMessage(_ p1: String) -> String {
public static func leaveSpaceMessage(_ p1: String) -> String {
return VectorL10n.tr("Vector", "leave_space_message", p1)
}
/// You are admin of this space, ensure that you have transferred admin right to another member before leaving.
internal static var leaveSpaceMessageAdminWarning: String {
public static var leaveSpaceMessageAdminWarning: String {
return VectorL10n.tr("Vector", "leave_space_message_admin_warning")
}
/// Don't leave any rooms
internal static var leaveSpaceOnlyAction: String {
public static var leaveSpaceOnlyAction: String {
return VectorL10n.tr("Vector", "leave_space_only_action")
}
/// Leave %@
internal static func leaveSpaceTitle(_ p1: String) -> String {
public static func leaveSpaceTitle(_ p1: String) -> String {
return VectorL10n.tr("Vector", "leave_space_title", p1)
}
/// Less
Expand Down Expand Up @@ -2212,7 +2212,7 @@ public class VectorL10n: NSObject {
return VectorL10n.tr("Vector", "on")
}
/// Open
internal static var `open`: String {
public static var `open`: String {
return VectorL10n.tr("Vector", "open")
}
/// or
Expand Down Expand Up @@ -3444,7 +3444,7 @@ public class VectorL10n: NSObject {
return VectorL10n.tr("Vector", "room_recents_start_chat_with")
}
/// SUGGESTED ROOMS
internal static var roomRecentsSuggestedRoomsSection: String {
public static var roomRecentsSuggestedRoomsSection: String {
return VectorL10n.tr("Vector", "room_recents_suggested_rooms_section")
}
/// Can't find this room. Make sure it exists
Expand Down Expand Up @@ -4820,11 +4820,11 @@ public class VectorL10n: NSObject {
return VectorL10n.tr("Vector", "social_login_list_title_sign_up")
}
/// Change space avatar
internal static var spaceAvatarViewAccessibilityHint: String {
public static var spaceAvatarViewAccessibilityHint: String {
return VectorL10n.tr("Vector", "space_avatar_view_accessibility_hint")
}
/// avatar
internal static var spaceAvatarViewAccessibilityLabel: String {
public static var spaceAvatarViewAccessibilityLabel: String {
return VectorL10n.tr("Vector", "space_avatar_view_accessibility_label")
}
/// BETA
Expand Down Expand Up @@ -4856,75 +4856,75 @@ public class VectorL10n: NSObject {
return VectorL10n.tr("Vector", "space_feature_unavailable_title")
}
/// Ban from this space
internal static var spaceParticipantsActionBan: String {
public static var spaceParticipantsActionBan: String {
return VectorL10n.tr("Vector", "space_participants_action_ban")
}
/// Remove from this space
internal static var spaceParticipantsActionRemove: String {
public static var spaceParticipantsActionRemove: String {
return VectorL10n.tr("Vector", "space_participants_action_remove")
}
/// Private space
internal static var spacePrivateJoinRule: String {
public static var spacePrivateJoinRule: String {
return VectorL10n.tr("Vector", "space_private_join_rule")
}
/// Public space
internal static var spacePublicJoinRule: String {
public static var spacePublicJoinRule: String {
return VectorL10n.tr("Vector", "space_public_join_rule")
}
/// space
internal static var spaceTag: String {
public static var spaceTag: String {
return VectorL10n.tr("Vector", "space_tag")
}
/// Adding rooms coming soon
internal static var spacesAddRoomsComingSoonTitle: String {
public static var spacesAddRoomsComingSoonTitle: String {
return VectorL10n.tr("Vector", "spaces_add_rooms_coming_soon_title")
}
/// This feature hasn’t been implemented here, but it’s on the way. For now, you can do that with Element on your computer.
internal static var spacesComingSoonDetail: String {
public static var spacesComingSoonDetail: String {
return VectorL10n.tr("Vector", "spaces_coming_soon_detail")
}
/// Coming soon
internal static var spacesComingSoonTitle: String {
public static var spacesComingSoonTitle: String {
return VectorL10n.tr("Vector", "spaces_coming_soon_title")
}
/// Some rooms may be hidden because they’re private and you need an invite.
internal static var spacesEmptySpaceDetail: String {
public static var spacesEmptySpaceDetail: String {
return VectorL10n.tr("Vector", "spaces_empty_space_detail")
}
/// This space has no rooms (yet)
internal static var spacesEmptySpaceTitle: String {
public static var spacesEmptySpaceTitle: String {
return VectorL10n.tr("Vector", "spaces_empty_space_title")
}
/// Explore rooms
internal static var spacesExploreRooms: String {
public static var spacesExploreRooms: String {
return VectorL10n.tr("Vector", "spaces_explore_rooms")
}
/// Home
internal static var spacesHomeSpaceTitle: String {
public static var spacesHomeSpaceTitle: String {
return VectorL10n.tr("Vector", "spaces_home_space_title")
}
/// Invites coming soon
internal static var spacesInvitesComingSoonTitle: String {
public static var spacesInvitesComingSoonTitle: String {
return VectorL10n.tr("Vector", "spaces_invites_coming_soon_title")
}
/// Spaces
internal static var spacesLeftPanelTitle: String {
public static var spacesLeftPanelTitle: String {
return VectorL10n.tr("Vector", "spaces_left_panel_title")
}
/// Looking for someone not in %@? For now, you can invite them on web or desktop.
internal static func spacesNoMemberFoundDetail(_ p1: String) -> String {
public static func spacesNoMemberFoundDetail(_ p1: String) -> String {
return VectorL10n.tr("Vector", "spaces_no_member_found_detail", p1)
}
/// No results found
internal static var spacesNoResultFoundTitle: String {
public static var spacesNoResultFoundTitle: String {
return VectorL10n.tr("Vector", "spaces_no_result_found_title")
}
/// Some results may be hidden because they’re private and you need an invite to join them.
internal static var spacesNoRoomFoundDetail: String {
public static var spacesNoRoomFoundDetail: String {
return VectorL10n.tr("Vector", "spaces_no_room_found_detail")
}
/// Suggested
internal static var spacesSuggestedRoom: String {
public static var spacesSuggestedRoom: String {
return VectorL10n.tr("Vector", "spaces_suggested_room")
}
/// Start
Expand Down
6 changes: 3 additions & 3 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -1365,9 +1365,9 @@ - (BOOL)handleUniversalLinkFragment:(NSString*)fragment fromURL:(NSURL*)universa
// So, come back to the home VC and show its loading wheel while processing
[self restoreInitialDisplay:^{

if ([_masterTabBarController.selectedViewController isKindOfClass:MXKViewController.class])
if ([_masterTabBarController.selectedViewController isKindOfClass:MXKActivityHandlingViewController.class])
{
MXKViewController *homeViewController = (MXKViewController*)_masterTabBarController.selectedViewController;
MXKActivityHandlingViewController *homeViewController = (MXKActivityHandlingViewController*)_masterTabBarController.selectedViewController;

[homeViewController startActivityIndicator];

Expand Down Expand Up @@ -1469,7 +1469,7 @@ - (BOOL)handleUniversalLinkFragment:(NSString*)fragment fromURL:(NSURL*)universa

self.spaceDetailPresenter = [SpaceDetailPresenter new];
self.spaceDetailPresenter.delegate = self;
[self.spaceDetailPresenter presentForSpaceWithSummary:room from:self.masterNavigationController sourceView:nil session:account.mxSession animated:YES];
[self.spaceDetailPresenter presentForSpaceWithPublicRoom:room from:self.masterNavigationController sourceView:nil session:account.mxSession animated:YES];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Foundation

class HomeViewControllerWithBannerWrapperViewController: MXKViewController, BannerPresentationProtocol {
class HomeViewControllerWithBannerWrapperViewController: MXKActivityHandlingViewController, BannerPresentationProtocol {

@objc let homeViewController: HomeViewController
private var bannerContainerView: UIView!
Expand Down
6 changes: 3 additions & 3 deletions Riot/Modules/Room/RoomViewController+Spaces.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ extension RoomViewController {
return
}

self.requestSummary(forRoomWithId: roomId, via: viaServers, from: url)
self.requestSummaryAndShowSpaceDetail(forRoomWithId: roomId, via: viaServers, from: url)
}
} else {
self.requestSummary(forRoomWithId: roomIdOrAlias, via: viaServers, from: url)
self.requestSummaryAndShowSpaceDetail(forRoomWithId: roomIdOrAlias, via: viaServers, from: url)
}
}

private func requestSummary(forRoomWithId roomId: String, via: [String], from url: URL?) {
private func requestSummaryAndShowSpaceDetail(forRoomWithId roomId: String, via: [String], from url: URL?) {
if self.mainSession.spaceService.getSpace(withId: roomId) != nil {
self.stopActivityIndicator()
self.showSpaceDetail(withId: roomId)
Expand Down
3 changes: 1 addition & 2 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,6 @@ - (BOOL)handleUniversalLinkURL:(NSURL*)universalLinkURL
{
[self handleSpaceUniversalLinkWith:universalLinkURL];
return YES;
// return [[AppDelegate theDelegate] handleUniversalLinkURL:universalLinkURL];
}
}

Expand Down Expand Up @@ -6487,7 +6486,7 @@ - (void)showSpaceDetailWithPublicRoom:(MXPublicRoom *)publicRoom
{
self.spaceDetailPresenter = [SpaceDetailPresenter new];
self.spaceDetailPresenter.delegate = self;
[self.spaceDetailPresenter presentForSpaceWithSummary:publicRoom from:self sourceView:nil session:self.mainSession animated:YES];
[self.spaceDetailPresenter presentForSpaceWithPublicRoom:publicRoom from:self sourceView:nil session:self.mainSession animated:YES];
}

- (void)showSpaceDetailWithId:(NSString *)spaceId
Expand Down
6 changes: 3 additions & 3 deletions Riot/Modules/Spaces/SpaceDetail/SpaceDetailPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class SpaceDetailPresenter: NSObject {
self.show(with: session)
}

@objc func present(forSpaceWithSummary spaceSummary: MXPublicRoom,
@objc func present(forSpaceWithPublicRoom publicRoom: MXPublicRoom,
from viewController: UIViewController,
sourceView: UIView?,
session: MXSession,
animated: Bool) {
self.session = session
self.spaceId = spaceSummary.roomId
self.spaceId = publicRoom.roomId

self.viewModel = SpaceDetailViewModel(session: session, publicRoom: spaceSummary)
self.viewModel = SpaceDetailViewModel(session: session, publicRoom: publicRoom)
self.viewModel.coordinatorDelegate = self
self.presentingViewController = viewController
self.sourceView = sourceView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ class SpaceDetailViewController: UIViewController {
self.inviterAvatarView.fill(with: avatarViewData)
}
}

view.layoutIfNeeded()
}

private func render(error: Error) {
Expand Down
15 changes: 8 additions & 7 deletions Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
private var currentSpaceId: String?
private var homeViewControllerWrapperViewController: HomeViewControllerWithBannerWrapperViewController?

private var currentMatrixSession: MXSession? {
return parameters.userSessionsService.mainUserSession?.matrixSession
}

// MARK: Public

// Must be used only internally
Expand Down Expand Up @@ -259,10 +263,8 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {

private func updateMasterTabBarController(with spaceId: String?) {

let currentMatrixSession = self.parameters.userSessionsService.mainUserSession?.matrixSession

self.updateTabControllers(for: self.masterTabBarController, showCommunities: spaceId == nil)
self.masterTabBarController.filterRooms(withParentId: spaceId, inMatrixSession: currentMatrixSession)
self.masterTabBarController.filterRooms(withParentId: spaceId, inMatrixSession: self.currentMatrixSession)
}

private func updateTabControllers(for tabBarController: MasterTabBarController, showCommunities: Bool) {
Expand All @@ -286,8 +288,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
viewControllers.append(roomsViewController)
}

let matrixSession = parameters.userSessionsService.mainUserSession?.matrixSession
if RiotSettings.shared.homeScreenShowCommunitiesTab && !(matrixSession?.groups().isEmpty ?? false) && showCommunities {
if RiotSettings.shared.homeScreenShowCommunitiesTab && !(self.currentMatrixSession?.groups().isEmpty ?? false) && showCommunities {
let groupsViewController = self.createGroupsViewController()
viewControllers.append(groupsViewController)
}
Expand Down Expand Up @@ -350,7 +351,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {

self.addMatrixSessionToMasterTabBarController(userSession.matrixSession)

if let matrixSession = parameters.userSessionsService.mainUserSession?.matrixSession, matrixSession.groups().isEmpty {
if let matrixSession = self.currentMatrixSession, matrixSession.groups().isEmpty {
self.masterTabBarController.removeTab(at: .groups)
}
}
Expand Down Expand Up @@ -380,7 +381,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
}

@objc private func sessionDidSync(_ notification: Notification) {
if parameters.userSessionsService.mainUserSession?.matrixSession.groups().isEmpty ?? true {
if self.currentMatrixSession?.groups().isEmpty ?? true {
self.masterTabBarController.removeTab(at: .groups)
}
}
Expand Down

0 comments on commit ca7bf18

Please sign in to comment.