mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add hooks for the RoomDetails, RoomMemberDetails and UserProfile screens. (#5980)
Also adds an @AppHook macro.
This commit is contained in:
@@ -7,105 +7,57 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Macros
|
||||
import Synchronization
|
||||
|
||||
final nonisolated class AppHooks: AppHooksProtocol {
|
||||
#if IS_MAIN_APP
|
||||
func configure(with userSession: UserSessionProtocol?) async {
|
||||
await roomScreenHook.configure(with: userSession)
|
||||
await userSessionHook.configure(with: userSession)
|
||||
}
|
||||
|
||||
private let _appSettingsHook: Mutex<AppSettingsHookProtocol> = Mutex(DefaultAppSettingsHook())
|
||||
var appSettingsHook: AppSettingsHookProtocol {
|
||||
_appSettingsHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultAppSettingsHook())
|
||||
var appSettingsHook: AppSettingsHookProtocol
|
||||
|
||||
func registerAppSettingsHook(_ hook: AppSettingsHookProtocol) {
|
||||
_appSettingsHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultCompoundHook())
|
||||
var compoundHook: CompoundHookProtocol
|
||||
|
||||
private let _compoundHook: Mutex<CompoundHookProtocol> = Mutex(DefaultCompoundHook())
|
||||
var compoundHook: CompoundHookProtocol {
|
||||
_compoundHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultBugReportHook())
|
||||
var bugReportHook: BugReportHookProtocol
|
||||
|
||||
func registerCompoundHook(_ hook: CompoundHookProtocol) {
|
||||
_compoundHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultOAuthPresenterHook())
|
||||
var oAuthPresenterHook: OAuthPresenterHookProtocol
|
||||
|
||||
private let _bugReportHook: Mutex<BugReportHookProtocol> = Mutex(DefaultBugReportHook())
|
||||
var bugReportHook: BugReportHookProtocol {
|
||||
_bugReportHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultUserSessionHook())
|
||||
var userSessionHook: UserSessionHookProtocol
|
||||
|
||||
func registerBugReportHook(_ hook: BugReportHookProtocol) {
|
||||
_bugReportHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultRoomScreenHook())
|
||||
var roomScreenHook: RoomScreenHookProtocol
|
||||
|
||||
private let _oAuthPresenterHook: Mutex<OAuthPresenterHookProtocol> = Mutex(DefaultOAuthPresenterHook())
|
||||
var oAuthPresenterHook: OAuthPresenterHookProtocol {
|
||||
_oAuthPresenterHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultRoomDetailsScreenHook())
|
||||
var roomDetailsScreenHook: RoomDetailsScreenHookProtocol
|
||||
|
||||
func registerOAuthPresenterHook(_ hook: OAuthPresenterHookProtocol) {
|
||||
_oAuthPresenterHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultRoomMemberDetailsScreenHook())
|
||||
var roomMemberDetailsScreenHook: RoomMemberDetailsScreenHookProtocol
|
||||
|
||||
private let _roomScreenHook: Mutex<RoomScreenHookProtocol> = Mutex(DefaultRoomScreenHook())
|
||||
var roomScreenHook: RoomScreenHookProtocol {
|
||||
_roomScreenHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultUserProfileScreenHook())
|
||||
var userProfileScreenHook: UserProfileScreenHookProtocol
|
||||
|
||||
func registerRoomScreenHook(_ hook: RoomScreenHookProtocol) {
|
||||
_roomScreenHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultDeveloperOptionsScreenHook())
|
||||
var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol
|
||||
|
||||
private let _developerOptionsScreenHook: Mutex<DeveloperOptionsScreenHookProtocol> = Mutex(DefaultDeveloperOptionsScreenHook())
|
||||
var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol {
|
||||
_developerOptionsScreenHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerDeveloperOptionsScreenHook(_ hook: DeveloperOptionsScreenHookProtocol) {
|
||||
_developerOptionsScreenHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _recoveryKeyScreenHook: Mutex<RecoveryKeyScreenHookProtocol> = Mutex(DefaultRecoveryKeyScreenHook())
|
||||
var recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol {
|
||||
_recoveryKeyScreenHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerRecoveryKeyScreenHook(_ hook: RecoveryKeyScreenHookProtocol) {
|
||||
_recoveryKeyScreenHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultRecoveryKeyScreenHook())
|
||||
var recoveryKeyScreenHook: RecoveryKeyScreenHookProtocol
|
||||
#endif
|
||||
|
||||
private let _tracingHook: Mutex<TracingHookProtocol> = Mutex(DefaultTracingHook())
|
||||
var tracingHook: TracingHookProtocol {
|
||||
_tracingHook.withLock { $0 }
|
||||
}
|
||||
@AppHook(default: DefaultTracingHook())
|
||||
var tracingHook: TracingHookProtocol
|
||||
|
||||
func registerTracingHook(_ hook: TracingHookProtocol) {
|
||||
_tracingHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultClientBuilderHook())
|
||||
var clientBuilderHook: ClientBuilderHookProtocol
|
||||
|
||||
private let _clientBuilderHook: Mutex<ClientBuilderHookProtocol> = Mutex(DefaultClientBuilderHook())
|
||||
var clientBuilderHook: ClientBuilderHookProtocol {
|
||||
_clientBuilderHook.withLock { $0 }
|
||||
}
|
||||
|
||||
// periphery:ignore - might be useful to have
|
||||
func registerClientBuilderHook(_ hook: ClientBuilderHookProtocol) {
|
||||
_clientBuilderHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _remoteSettingsHook: Mutex<RemoteSettingsHookProtocol> = Mutex(DefaultRemoteSettingsHook())
|
||||
var remoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
_remoteSettingsHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerRemoteSettingsHook(_ hook: RemoteSettingsHookProtocol) {
|
||||
_remoteSettingsHook.withLock { $0 = hook }
|
||||
}
|
||||
@AppHook(default: DefaultRemoteSettingsHook())
|
||||
var remoteSettingsHook: RemoteSettingsHookProtocol
|
||||
}
|
||||
|
||||
nonisolated protocol AppHooksProtocol: Sendable {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
nonisolated protocol RoomDetailsScreenHookProtocol: Sendable {
|
||||
@MainActor func update(_ viewState: RoomDetailsScreenViewState) -> RoomDetailsScreenViewState
|
||||
}
|
||||
|
||||
struct DefaultRoomDetailsScreenHook: RoomDetailsScreenHookProtocol {
|
||||
func update(_ viewState: RoomDetailsScreenViewState) -> RoomDetailsScreenViewState {
|
||||
viewState
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
nonisolated protocol RoomMemberDetailsScreenHookProtocol: Sendable {
|
||||
@MainActor func update(_ viewState: RoomMemberDetailsScreenViewState) -> RoomMemberDetailsScreenViewState
|
||||
}
|
||||
|
||||
struct DefaultRoomMemberDetailsScreenHook: RoomMemberDetailsScreenHookProtocol {
|
||||
func update(_ viewState: RoomMemberDetailsScreenViewState) -> RoomMemberDetailsScreenViewState {
|
||||
viewState
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,10 @@
|
||||
import Foundation
|
||||
|
||||
nonisolated protocol RoomScreenHookProtocol: Sendable {
|
||||
@MainActor func configure(with userSession: UserSessionProtocol?) async
|
||||
@MainActor func update(_ viewState: RoomScreenViewState) -> RoomScreenViewState
|
||||
}
|
||||
|
||||
struct DefaultRoomScreenHook: RoomScreenHookProtocol {
|
||||
func configure(with userSession: UserSessionProtocol?) async { }
|
||||
func update(_ viewState: RoomScreenViewState) -> RoomScreenViewState {
|
||||
viewState
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
nonisolated protocol UserProfileScreenHookProtocol: Sendable {
|
||||
@MainActor func update(_ viewState: UserProfileScreenViewState) -> UserProfileScreenViewState
|
||||
}
|
||||
|
||||
struct DefaultUserProfileScreenHook: UserProfileScreenHookProtocol {
|
||||
func update(_ viewState: UserProfileScreenViewState) -> UserProfileScreenViewState {
|
||||
viewState
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
nonisolated protocol UserSessionHookProtocol: Sendable {
|
||||
func configure(with userSession: UserSessionProtocol?) async
|
||||
}
|
||||
|
||||
nonisolated struct DefaultUserSessionHook: UserSessionHookProtocol {
|
||||
func configure(with userSession: UserSessionProtocol?) async { }
|
||||
}
|
||||
@@ -750,8 +750,9 @@ class ChatsTabFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let parameters = UserProfileScreenCoordinatorParameters(userID: userID,
|
||||
isPresentedModally: true,
|
||||
userSession: userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
analytics: flowParameters.analytics)
|
||||
appHooks: flowParameters.appHooks,
|
||||
analytics: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = UserProfileScreenCoordinator(parameters: parameters)
|
||||
coordinator.actionsPublisher.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
@@ -940,6 +940,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentRoomDetails(isRoot: Bool, animated: Bool) async {
|
||||
let params = RoomDetailsScreenCoordinatorParameters(roomProxy: roomProxy,
|
||||
userSession: userSession,
|
||||
appHooks: flowParameters.appHooks,
|
||||
analyticsService: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
notificationSettings: userSession.clientProxy.notificationSettings,
|
||||
|
||||
@@ -231,8 +231,9 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let params = RoomMemberDetailsScreenCoordinatorParameters(userID: userID,
|
||||
roomProxy: roomProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
analytics: flowParameters.analytics)
|
||||
appHooks: flowParameters.appHooks,
|
||||
analytics: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = RoomMemberDetailsScreenCoordinator(parameters: params)
|
||||
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
@@ -287,8 +288,9 @@ final class RoomMembersFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let parameters = UserProfileScreenCoordinatorParameters(userID: userID,
|
||||
isPresentedModally: false,
|
||||
userSession: flowParameters.userSession,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
analytics: flowParameters.analytics)
|
||||
appHooks: flowParameters.appHooks,
|
||||
analytics: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController)
|
||||
let coordinator = UserProfileScreenCoordinator(parameters: parameters)
|
||||
coordinator.actionsPublisher.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
@@ -211,6 +211,7 @@ final class SpaceSettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||
private func presentSpaceSettings(animated: Bool) {
|
||||
let coordinator = RoomDetailsScreenCoordinator(parameters: .init(roomProxy: roomProxy,
|
||||
userSession: flowParameters.userSession,
|
||||
appHooks: flowParameters.appHooks,
|
||||
analyticsService: flowParameters.analytics,
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
notificationSettings: flowParameters.userSession.clientProxy.notificationSettings,
|
||||
|
||||
@@ -12,6 +12,7 @@ import SwiftUI
|
||||
struct RoomDetailsScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let appHooks: AppHooks
|
||||
let analyticsService: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let notificationSettings: NotificationSettingsProxyProtocol
|
||||
@@ -52,6 +53,7 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
isSpace = parameters.roomProxy.infoPublisher.value.isSpace
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
userSession: parameters.userSession,
|
||||
appHooks: parameters.appHooks,
|
||||
analyticsService: parameters.analyticsService,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
notificationSettingsProxy: parameters.notificationSettings,
|
||||
|
||||
@@ -62,6 +62,7 @@ struct RoomDetailsScreenViewState: BindableState {
|
||||
var canKickUsers = false
|
||||
var canBanUsers = false
|
||||
var notificationSettingsState: RoomDetailsNotificationSettingsState = .loading
|
||||
var isCallingEnabled = true
|
||||
var canJoinCall = false
|
||||
var pinnedEventsActionState = RoomDetailsScreenPinnedEventsActionState.loading
|
||||
|
||||
@@ -93,7 +94,7 @@ struct RoomDetailsScreenViewState: BindableState {
|
||||
|
||||
var shortcuts: [RoomDetailsScreenViewShortcut] {
|
||||
var shortcuts: [RoomDetailsScreenViewShortcut] = [.mute]
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac, canJoinCall {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac, isCallingEnabled, canJoinCall {
|
||||
if isDirect {
|
||||
shortcuts.append(.voiceCall)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
appHooks: AppHooks,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
notificationSettingsProxy: NotificationSettingsProxyProtocol,
|
||||
@@ -58,14 +59,15 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
|
||||
let topic = attributedStringBuilder.fromPlain(roomProxy.infoPublisher.value.topic)
|
||||
|
||||
super.init(initialViewState: .init(details: roomProxy.details,
|
||||
isEncrypted: roomProxy.infoPublisher.value.isEncrypted,
|
||||
isDirect: roomProxy.infoPublisher.value.isDirect,
|
||||
topic: topic,
|
||||
topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(),
|
||||
joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
||||
notificationSettingsState: .loading,
|
||||
bindings: .init()),
|
||||
let viewState = RoomDetailsScreenViewState(details: roomProxy.details,
|
||||
isEncrypted: roomProxy.infoPublisher.value.isEncrypted,
|
||||
isDirect: roomProxy.infoPublisher.value.isDirect,
|
||||
topic: topic,
|
||||
topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(),
|
||||
joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
||||
notificationSettingsState: .loading,
|
||||
bindings: .init())
|
||||
super.init(initialViewState: appHooks.roomDetailsScreenHook.update(viewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
Task {
|
||||
|
||||
@@ -441,6 +441,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
@@ -468,6 +469,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
@@ -505,6 +507,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
|
||||
+5
-3
@@ -13,8 +13,9 @@ struct RoomMemberDetailsScreenCoordinatorParameters {
|
||||
let userID: String
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum RoomMemberDetailsScreenCoordinatorAction {
|
||||
@@ -38,8 +39,9 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel = RoomMemberDetailsScreenViewModel(userID: parameters.userID,
|
||||
roomProxy: parameters.roomProxy,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
analytics: parameters.analytics)
|
||||
appHooks: parameters.appHooks,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -22,6 +22,7 @@ struct RoomMemberDetailsScreenViewState: BindableState {
|
||||
var isOwnMemberDetails = false
|
||||
var isProcessingIgnoreRequest = false
|
||||
var dmRoomID: String?
|
||||
var isCallingEnabled = true
|
||||
|
||||
var bindings: RoomMemberDetailsScreenViewStateBindings
|
||||
|
||||
|
||||
+6
-4
@@ -14,8 +14,8 @@ typealias RoomMemberDetailsScreenViewModelType = StateStoreViewModel<RoomMemberD
|
||||
class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, RoomMemberDetailsScreenViewModelProtocol {
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let userSession: UserSessionProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private var actionsSubject: PassthroughSubject<RoomMemberDetailsScreenViewModelAction, Never> = .init()
|
||||
|
||||
@@ -28,8 +28,9 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
init(userID: String,
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
analytics: AnalyticsServiceProtocol) {
|
||||
appHooks: AppHooks,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.roomProxy = roomProxy
|
||||
self.userSession = userSession
|
||||
self.userIndicatorController = userIndicatorController
|
||||
@@ -37,7 +38,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
|
||||
let initialViewState = RoomMemberDetailsScreenViewState(userID: userID, bindings: .init())
|
||||
|
||||
super.init(initialViewState: initialViewState, mediaProvider: userSession.mediaProvider)
|
||||
super.init(initialViewState: appHooks.roomMemberDetailsScreenHook.update(initialViewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
showMemberLoadingIndicator()
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ struct RoomMemberDetailsScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
|
||||
}
|
||||
|
||||
if let roomID = context.viewState.dmRoomID {
|
||||
if let roomID = context.viewState.dmRoomID, context.viewState.isCallingEnabled {
|
||||
Button {
|
||||
context.send(viewAction: .startCall(roomID: roomID, isVoiceCall: true))
|
||||
} label: {
|
||||
@@ -239,7 +239,8 @@ struct RoomMemberDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
return RoomMemberDetailsScreenViewModel(userID: member.userID,
|
||||
roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: AnalyticsServiceMock(.init()))
|
||||
appHooks: AppHooks(),
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
canonicalAlias: "#space:matrix.org",
|
||||
members: members)),
|
||||
userSession: UserSessionMock(.init()),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
|
||||
@@ -13,8 +13,9 @@ struct UserProfileScreenCoordinatorParameters {
|
||||
let userID: String
|
||||
let isPresentedModally: Bool
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum UserProfileScreenCoordinatorAction {
|
||||
@@ -37,8 +38,9 @@ final class UserProfileScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel = UserProfileScreenViewModel(userID: parameters.userID,
|
||||
isPresentedModally: parameters.isPresentedModally,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
analytics: parameters.analytics)
|
||||
appHooks: parameters.appHooks,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -24,6 +24,7 @@ struct UserProfileScreenViewState: BindableState {
|
||||
var isVerified: Bool?
|
||||
var permalink: URL?
|
||||
var dmRoomID: String?
|
||||
var isCallingEnabled = true
|
||||
|
||||
var bindings: UserProfileScreenViewStateBindings
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ typealias UserProfileScreenViewModelType = StateStoreViewModelV2<UserProfileScre
|
||||
|
||||
class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScreenViewModelProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private var actionsSubject: PassthroughSubject<UserProfileScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<UserProfileScreenViewModelAction, Never> {
|
||||
@@ -25,18 +25,20 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
|
||||
init(userID: String,
|
||||
isPresentedModally: Bool,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
analytics: AnalyticsServiceProtocol) {
|
||||
appHooks: AppHooks,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSession = userSession
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
let initialViewState = UserProfileScreenViewState(userID: userID,
|
||||
isOwnUser: userID == userSession.clientProxy.userID,
|
||||
isPresentedModally: isPresentedModally,
|
||||
bindings: .init())
|
||||
|
||||
super.init(initialViewState: initialViewState, mediaProvider: userSession.mediaProvider)
|
||||
super.init(initialViewState: appHooks.userProfileScreenHook.update(initialViewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
showLoadingIndicator(allowsInteraction: true)
|
||||
Task {
|
||||
|
||||
@@ -65,7 +65,7 @@ struct UserProfileScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.roomMemberDetailsScreen.directChat)
|
||||
}
|
||||
|
||||
if let roomID = context.viewState.dmRoomID {
|
||||
if let roomID = context.viewState.dmRoomID, context.viewState.isCallingEnabled {
|
||||
Button {
|
||||
context.send(viewAction: .startCall(roomID: roomID, isVoiceCall: true))
|
||||
} label: {
|
||||
@@ -147,7 +147,8 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview {
|
||||
return UserProfileScreenViewModel(userID: userID,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: AnalyticsServiceMock(.init()))
|
||||
appHooks: AppHooks(),
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user