Fixes #2179 - Open direct chat directly from the room member details screen
This commit is contained in:
committed by
Stefan Ceriu
parent
67d30f490c
commit
84ec5a37ff
@@ -108,6 +108,7 @@
|
||||
"common_dark" = "Dark";
|
||||
"common_decryption_error" = "Decryption error";
|
||||
"common_developer_options" = "Developer options";
|
||||
"common_direct_chat" = "Direct chat";
|
||||
"common_edited_suffix" = "(edited)";
|
||||
"common_editing" = "Editing";
|
||||
"common_emote" = "* %1$@ %2$@";
|
||||
|
||||
@@ -86,8 +86,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
||||
switch appRoute {
|
||||
case .room(let roomID):
|
||||
if case .room(let identifier) = stateMachine.state,
|
||||
roomID == identifier {
|
||||
if case .room(let roomID) = stateMachine.state,
|
||||
roomID == roomID {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -853,6 +853,42 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
mediaProvider: userSession.mediaProvider,
|
||||
userIndicatorController: userIndicatorController)
|
||||
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
|
||||
self?.stateMachine.tryEvent(.dismissRoomMemberDetails)
|
||||
|
||||
@@ -250,6 +250,8 @@ public enum L10n {
|
||||
public static var commonDecryptionError: String { return L10n.tr("Localizable", "common_decryption_error") }
|
||||
/// 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)
|
||||
public static var commonEditedSuffix: String { return L10n.tr("Localizable", "common_edited_suffix") }
|
||||
/// Editing
|
||||
|
||||
@@ -175,6 +175,7 @@ enum A11yIdentifiers {
|
||||
struct RoomMemberDetailsScreen {
|
||||
let ignore = "room_member_details-ignore"
|
||||
let unignore = "room_member_details-unignore"
|
||||
let directChat = "room_member_details-direct_chat"
|
||||
}
|
||||
|
||||
struct RoomNotificationSettingsScreen {
|
||||
|
||||
@@ -24,7 +24,9 @@ struct RoomMemberDetailsScreenCoordinatorParameters {
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum RoomMemberDetailsScreenCoordinatorAction { }
|
||||
enum RoomMemberDetailsScreenCoordinatorAction {
|
||||
case openDirectChat
|
||||
}
|
||||
|
||||
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: RoomMemberDetailsScreenCoordinatorParameters
|
||||
@@ -45,8 +47,18 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
mediaProvider: parameters.mediaProvider,
|
||||
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() }
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum RoomMemberDetailsScreenViewModelAction { }
|
||||
enum RoomMemberDetailsScreenViewModelAction {
|
||||
case openDirectChat
|
||||
}
|
||||
|
||||
struct RoomMemberDetailsScreenViewState: BindableState {
|
||||
var details: RoomMemberDetails
|
||||
@@ -77,6 +79,7 @@ enum RoomMemberDetailsScreenViewAction {
|
||||
case ignoreConfirmed
|
||||
case unignoreConfirmed
|
||||
case displayAvatar
|
||||
case openDirectChat
|
||||
}
|
||||
|
||||
enum RoomMemberDetailsScreenError: Hashable {
|
||||
|
||||
@@ -65,6 +65,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
Task { await unignoreUser() }
|
||||
case .displayAvatar:
|
||||
displayFullScreenAvatar()
|
||||
case .openDirectChat:
|
||||
actionsSubject.send(.openDirectChat)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ struct RoomMemberDetailsScreen: View {
|
||||
headerSection
|
||||
|
||||
if !context.viewState.details.isAccountOwner {
|
||||
directChatSection
|
||||
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 {
|
||||
Section {
|
||||
|
||||
1
changelog.d/2179.feature
Normal file
1
changelog.d/2179.feature
Normal file
@@ -0,0 +1 @@
|
||||
Open direct chat directly from the room member details screen
|
||||
Reference in New Issue
Block a user