mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Fixes #2179 - Open direct chat directly from the room member details screen
This commit is contained in:
committed by
Stefan Ceriu
parent
742a924037
commit
e4788e615f
@@ -108,6 +108,7 @@
|
|||||||
"common_dark" = "Dark";
|
"common_dark" = "Dark";
|
||||||
"common_decryption_error" = "Decryption error";
|
"common_decryption_error" = "Decryption error";
|
||||||
"common_developer_options" = "Developer options";
|
"common_developer_options" = "Developer options";
|
||||||
|
"common_direct_chat" = "Direct chat";
|
||||||
"common_edited_suffix" = "(edited)";
|
"common_edited_suffix" = "(edited)";
|
||||||
"common_editing" = "Editing";
|
"common_editing" = "Editing";
|
||||||
"common_emote" = "* %1$@ %2$@";
|
"common_emote" = "* %1$@ %2$@";
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
||||||
switch appRoute {
|
switch appRoute {
|
||||||
case .room(let roomID):
|
case .room(let roomID):
|
||||||
if case .room(let identifier) = stateMachine.state,
|
if case .room(let roomID) = stateMachine.state,
|
||||||
roomID == identifier {
|
roomID == roomID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,6 +853,42 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
mediaProvider: userSession.mediaProvider,
|
mediaProvider: userSession.mediaProvider,
|
||||||
userIndicatorController: userIndicatorController)
|
userIndicatorController: userIndicatorController)
|
||||||
let coordinator = RoomMemberDetailsScreenCoordinator(parameters: params)
|
let coordinator = RoomMemberDetailsScreenCoordinator(parameters: params)
|
||||||
|
|
||||||
|
coordinator.actions.sink { [weak self] action in
|
||||||
|
guard let self else { return }
|
||||||
|
switch action {
|
||||||
|
case .openDirectChat:
|
||||||
|
let loadingIndicatorIdentifier = "OpenDirectChatLoadingIndicator"
|
||||||
|
|
||||||
|
userIndicatorController.submitIndicator(UserIndicator(id: loadingIndicatorIdentifier,
|
||||||
|
type: .modal(progress: .indeterminate, interactiveDismissDisabled: true, allowsInteraction: false),
|
||||||
|
title: L10n.commonLoading,
|
||||||
|
persistent: true))
|
||||||
|
|
||||||
|
Task { [weak self] in
|
||||||
|
guard let self else { return }
|
||||||
|
|
||||||
|
let currentDirectRoom = await userSession.clientProxy.directRoomForUserID(member.userID)
|
||||||
|
switch currentDirectRoom {
|
||||||
|
case .success(.some(let roomID)):
|
||||||
|
stateMachine.tryEvent(.presentRoom(roomID: roomID))
|
||||||
|
case .success(nil):
|
||||||
|
switch await userSession.clientProxy.createDirectRoom(with: member.userID, expectedRoomName: member.displayName) {
|
||||||
|
case .success(let roomID):
|
||||||
|
analytics.trackCreatedRoom(isDM: true)
|
||||||
|
stateMachine.tryEvent(.presentRoom(roomID: roomID))
|
||||||
|
case .failure:
|
||||||
|
userIndicatorController.alertInfo = .init(id: UUID())
|
||||||
|
}
|
||||||
|
case .failure:
|
||||||
|
userIndicatorController.alertInfo = .init(id: UUID())
|
||||||
|
}
|
||||||
|
|
||||||
|
userIndicatorController.retractIndicatorWithId(loadingIndicatorIdentifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
|
|
||||||
navigationStackCoordinator.push(coordinator) { [weak self] in
|
navigationStackCoordinator.push(coordinator) { [weak self] in
|
||||||
self?.stateMachine.tryEvent(.dismissRoomMemberDetails)
|
self?.stateMachine.tryEvent(.dismissRoomMemberDetails)
|
||||||
|
|||||||
@@ -250,6 +250,8 @@ public enum L10n {
|
|||||||
public static var commonDecryptionError: String { return L10n.tr("Localizable", "common_decryption_error") }
|
public static var commonDecryptionError: String { return L10n.tr("Localizable", "common_decryption_error") }
|
||||||
/// Developer options
|
/// Developer options
|
||||||
public static var commonDeveloperOptions: String { return L10n.tr("Localizable", "common_developer_options") }
|
public static var commonDeveloperOptions: String { return L10n.tr("Localizable", "common_developer_options") }
|
||||||
|
/// Direct chat
|
||||||
|
public static var commonDirectChat: String { return L10n.tr("Localizable", "common_direct_chat") }
|
||||||
/// (edited)
|
/// (edited)
|
||||||
public static var commonEditedSuffix: String { return L10n.tr("Localizable", "common_edited_suffix") }
|
public static var commonEditedSuffix: String { return L10n.tr("Localizable", "common_edited_suffix") }
|
||||||
/// Editing
|
/// Editing
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ enum A11yIdentifiers {
|
|||||||
struct RoomMemberDetailsScreen {
|
struct RoomMemberDetailsScreen {
|
||||||
let ignore = "room_member_details-ignore"
|
let ignore = "room_member_details-ignore"
|
||||||
let unignore = "room_member_details-unignore"
|
let unignore = "room_member_details-unignore"
|
||||||
|
let directChat = "room_member_details-direct_chat"
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RoomNotificationSettingsScreen {
|
struct RoomNotificationSettingsScreen {
|
||||||
|
|||||||
+15
-3
@@ -24,7 +24,9 @@ struct RoomMemberDetailsScreenCoordinatorParameters {
|
|||||||
let userIndicatorController: UserIndicatorControllerProtocol
|
let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RoomMemberDetailsScreenCoordinatorAction { }
|
enum RoomMemberDetailsScreenCoordinatorAction {
|
||||||
|
case openDirectChat
|
||||||
|
}
|
||||||
|
|
||||||
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
||||||
private let parameters: RoomMemberDetailsScreenCoordinatorParameters
|
private let parameters: RoomMemberDetailsScreenCoordinatorParameters
|
||||||
@@ -45,8 +47,18 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
|||||||
mediaProvider: parameters.mediaProvider,
|
mediaProvider: parameters.mediaProvider,
|
||||||
userIndicatorController: parameters.userIndicatorController)
|
userIndicatorController: parameters.userIndicatorController)
|
||||||
}
|
}
|
||||||
|
|
||||||
func start() { }
|
func start() {
|
||||||
|
viewModel.actions.sink { [weak self] action in
|
||||||
|
guard let self else { return }
|
||||||
|
|
||||||
|
switch action {
|
||||||
|
case .openDirectChat:
|
||||||
|
actionsSubject.send(.openDirectChat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
|
}
|
||||||
|
|
||||||
func stop() { viewModel.stop() }
|
func stop() { viewModel.stop() }
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum RoomMemberDetailsScreenViewModelAction { }
|
enum RoomMemberDetailsScreenViewModelAction {
|
||||||
|
case openDirectChat
|
||||||
|
}
|
||||||
|
|
||||||
struct RoomMemberDetailsScreenViewState: BindableState {
|
struct RoomMemberDetailsScreenViewState: BindableState {
|
||||||
var details: RoomMemberDetails
|
var details: RoomMemberDetails
|
||||||
@@ -77,6 +79,7 @@ enum RoomMemberDetailsScreenViewAction {
|
|||||||
case ignoreConfirmed
|
case ignoreConfirmed
|
||||||
case unignoreConfirmed
|
case unignoreConfirmed
|
||||||
case displayAvatar
|
case displayAvatar
|
||||||
|
case openDirectChat
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RoomMemberDetailsScreenError: Hashable {
|
enum RoomMemberDetailsScreenError: Hashable {
|
||||||
|
|||||||
+2
@@ -65,6 +65,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
|||||||
Task { await unignoreUser() }
|
Task { await unignoreUser() }
|
||||||
case .displayAvatar:
|
case .displayAvatar:
|
||||||
displayFullScreenAvatar()
|
displayFullScreenAvatar()
|
||||||
|
case .openDirectChat:
|
||||||
|
actionsSubject.send(.openDirectChat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct RoomMemberDetailsScreen: View {
|
|||||||
headerSection
|
headerSection
|
||||||
|
|
||||||
if !context.viewState.details.isAccountOwner {
|
if !context.viewState.details.isAccountOwner {
|
||||||
|
directChatSection
|
||||||
blockUserSection
|
blockUserSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +59,17 @@ struct RoomMemberDetailsScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var directChatSection: some View {
|
||||||
|
Section {
|
||||||
|
ListRow(label: .default(title: L10n.commonDirectChat,
|
||||||
|
icon: \.chat),
|
||||||
|
kind: .button {
|
||||||
|
context.send(viewAction: .openDirectChat)
|
||||||
|
})
|
||||||
|
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var blockUserSection: some View {
|
private var blockUserSection: some View {
|
||||||
Section {
|
Section {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Open direct chat directly from the room member details screen
|
||||||
Reference in New Issue
Block a user