mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 20:56:57 +02:00
Wrong copy for upgrade room message (#6003)
* Wrong copy for upgrade room message - fixed
This commit is contained in:
@@ -154,6 +154,7 @@ final class RoomAccessCoordinator: Coordinator {
|
||||
let paramaters = RoomUpgradeCoordinatorParameters(
|
||||
session: parameters.room.mxSession,
|
||||
roomId: roomId,
|
||||
parentSpaceId: parameters.parentSpaceId,
|
||||
versionOverride: versionOverride)
|
||||
let coordinator = RoomUpgradeCoordinator(parameters: paramaters)
|
||||
|
||||
|
||||
+8
-3
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
import UIKit
|
||||
import MatrixSDK
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
@objc protocol RoomAccessCoordinatorBridgePresenterDelegate {
|
||||
@@ -34,6 +35,7 @@ final class RoomAccessCoordinatorBridgePresenter: NSObject {
|
||||
// MARK: Private
|
||||
|
||||
private let room: MXRoom
|
||||
private let parentSpaceId: String?
|
||||
private let allowsRoomUpgrade: Bool
|
||||
private var coordinator: RoomAccessCoordinator?
|
||||
|
||||
@@ -44,21 +46,24 @@ final class RoomAccessCoordinatorBridgePresenter: NSObject {
|
||||
// MARK: - Setup
|
||||
|
||||
init(room: MXRoom,
|
||||
parentSpaceId: String?,
|
||||
allowsRoomUpgrade: Bool) {
|
||||
self.room = room
|
||||
self.parentSpaceId = parentSpaceId
|
||||
self.allowsRoomUpgrade = allowsRoomUpgrade
|
||||
super.init()
|
||||
}
|
||||
|
||||
convenience init(room: MXRoom) {
|
||||
self.init(room: room, allowsRoomUpgrade: true)
|
||||
convenience init(room: MXRoom,
|
||||
parentSpaceId: String?) {
|
||||
self.init(room: room, parentSpaceId: parentSpaceId, allowsRoomUpgrade: true)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func present(from viewController: UIViewController, animated: Bool) {
|
||||
let navigationRouter = NavigationRouter()
|
||||
let coordinator = RoomAccessCoordinator(parameters: RoomAccessCoordinatorParameters(room: room, allowsRoomUpgrade: allowsRoomUpgrade, navigationRouter: navigationRouter))
|
||||
let coordinator = RoomAccessCoordinator(parameters: RoomAccessCoordinatorParameters(room: room, parentSpaceId: parentSpaceId, allowsRoomUpgrade: allowsRoomUpgrade, navigationRouter: navigationRouter))
|
||||
coordinator.callback = { [weak self] result in
|
||||
guard let self = self else { return }
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ struct RoomAccessCoordinatorParameters {
|
||||
/// The Matrix room
|
||||
let room: MXRoom
|
||||
|
||||
/// ID of the currently selected space. `nil` if home space
|
||||
let parentSpaceId: String?
|
||||
|
||||
/// Set this value to false if you want to avoid room to be upgraded
|
||||
let allowsRoomUpgrade: Bool
|
||||
|
||||
@@ -31,9 +34,11 @@ struct RoomAccessCoordinatorParameters {
|
||||
let navigationRouter: NavigationRouterType
|
||||
|
||||
init(room: MXRoom,
|
||||
parentSpaceId: String?,
|
||||
allowsRoomUpgrade: Bool = true,
|
||||
navigationRouter: NavigationRouterType? = nil) {
|
||||
self.room = room
|
||||
self.parentSpaceId = parentSpaceId
|
||||
self.allowsRoomUpgrade = allowsRoomUpgrade
|
||||
self.navigationRouter = navigationRouter ?? NavigationRouter(navigationController: RiotNavigationController())
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import MatrixSDK
|
||||
struct RoomUpgradeCoordinatorParameters {
|
||||
let session: MXSession
|
||||
let roomId: String
|
||||
let parentSpaceId: String?
|
||||
let versionOverride: String
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ final class RoomUpgradeCoordinator: Coordinator, Presentable {
|
||||
@available(iOS 14.0, *)
|
||||
init(parameters: RoomUpgradeCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
let viewModel = RoomUpgradeViewModel.makeRoomUpgradeViewModel(roomUpgradeService: RoomUpgradeService(session: parameters.session, roomId: parameters.roomId, versionOverride: parameters.versionOverride))
|
||||
let viewModel = RoomUpgradeViewModel.makeRoomUpgradeViewModel(roomUpgradeService: RoomUpgradeService(session: parameters.session, roomId: parameters.roomId, parentSpaceId: parameters.parentSpaceId, versionOverride: parameters.versionOverride))
|
||||
let view = RoomUpgrade(viewModel: viewModel.context)
|
||||
.addDependency(AvatarService.instantiate(mediaManager: parameters.session.mediaManager))
|
||||
roomUpgradeViewModel = viewModel
|
||||
|
||||
@@ -25,7 +25,7 @@ enum MockRoomUpgradeScreenState: MockScreenState, CaseIterable {
|
||||
// with specific, minimal associated data that will allow you
|
||||
// mock that screen.
|
||||
case initial
|
||||
|
||||
|
||||
/// The associated screen
|
||||
var screenType: Any.Type {
|
||||
RoomUpgrade.self
|
||||
|
||||
@@ -35,6 +35,7 @@ enum RoomUpgradeViewModelResult {
|
||||
struct RoomUpgradeViewState: BindableState {
|
||||
var waitingMessage: String?
|
||||
var isLoading: Bool
|
||||
var parentSpaceName: String?
|
||||
}
|
||||
|
||||
enum RoomUpgradeViewAction {
|
||||
|
||||
@@ -47,7 +47,7 @@ class RoomUpgradeViewModel: RoomUpgradeViewModelType, RoomUpgradeViewModelProtoc
|
||||
}
|
||||
|
||||
private static func defaultState(roomUpgradeService: RoomUpgradeServiceProtocol) -> RoomUpgradeViewState {
|
||||
return RoomUpgradeViewState(waitingMessage: nil, isLoading: false)
|
||||
return RoomUpgradeViewState(waitingMessage: nil, isLoading: false, parentSpaceName: roomUpgradeService.parentSpaceName)
|
||||
}
|
||||
|
||||
private func setupObservers() {
|
||||
|
||||
@@ -26,7 +26,7 @@ class RoomUpgradeService: RoomUpgradeServiceProtocol {
|
||||
// MARK: Private
|
||||
|
||||
private let session: MXSession
|
||||
|
||||
private let parentSpaceId: String?
|
||||
private let versionOverride: String
|
||||
private var currentOperation: MXHTTPOperation?
|
||||
private var didBuildSpaceGraphObserver: Any?
|
||||
@@ -37,11 +37,25 @@ class RoomUpgradeService: RoomUpgradeServiceProtocol {
|
||||
private(set) var errorSubject: CurrentValueSubject<Error?, Never>
|
||||
private(set) var currentRoomId: String
|
||||
|
||||
var parentSpaceName: String? {
|
||||
guard let parentId = self.parentSpaceId else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let parent = session.spaceService?.getSpace(withId: parentId) else {
|
||||
MXLog.error("[RoomUpgradeService] parentSpaceName: parent space not found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
return parent.room?.displayName
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(session: MXSession, roomId: String, versionOverride: String) {
|
||||
init(session: MXSession, roomId: String, parentSpaceId: String?, versionOverride: String) {
|
||||
self.session = session
|
||||
self.currentRoomId = roomId
|
||||
self.parentSpaceId = parentSpaceId
|
||||
self.versionOverride = versionOverride
|
||||
self.upgradingSubject = CurrentValueSubject(false)
|
||||
self.errorSubject = CurrentValueSubject(nil)
|
||||
|
||||
@@ -23,6 +23,9 @@ class MockRoomUpgradeService: RoomUpgradeServiceProtocol {
|
||||
|
||||
var errorSubject: CurrentValueSubject<Error?, Never>
|
||||
var upgradingSubject: CurrentValueSubject<Bool, Never>
|
||||
var parentSpaceName: String? {
|
||||
return "Parent space name"
|
||||
}
|
||||
|
||||
init() {
|
||||
self.errorSubject = CurrentValueSubject(nil)
|
||||
|
||||
@@ -20,6 +20,7 @@ import Combine
|
||||
@available(iOS 14.0, *)
|
||||
protocol RoomUpgradeServiceProtocol {
|
||||
var currentRoomId: String { get }
|
||||
var parentSpaceName: String? { get }
|
||||
var upgradingSubject: CurrentValueSubject<Bool, Never> { get }
|
||||
var errorSubject: CurrentValueSubject<Error?, Never> { get }
|
||||
|
||||
|
||||
@@ -46,43 +46,44 @@ struct RoomUpgrade: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var alertContent: some View {
|
||||
VStack(alignment: .center) {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertTitle)
|
||||
.font(theme.fonts.title3SB)
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
ZStack {
|
||||
VStack(alignment: .center) {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertTitle)
|
||||
.font(theme.fonts.title3SB)
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.padding(.bottom, 24)
|
||||
if let spaceName = viewModel.viewState.parentSpaceName {
|
||||
noteText(VectorL10n.roomAccessSettingsScreenUpgradeAlertMessage(spaceName))
|
||||
.padding(.bottom)
|
||||
} else {
|
||||
noteText(VectorL10n.roomAccessSettingsScreenUpgradeAlertMessageNoParam)
|
||||
.padding(.bottom)
|
||||
}
|
||||
noteText(VectorL10n.roomAccessSettingsScreenUpgradeAlertNote)
|
||||
.padding(.bottom, 35)
|
||||
Toggle(isOn: $autoInviteUsers) {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertAutoInviteSwitch)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: theme.colors.accent))
|
||||
Divider()
|
||||
Button {
|
||||
viewModel.send(viewAction: .done(autoInviteUsers))
|
||||
} label: {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertUpgradeButton)
|
||||
}
|
||||
.buttonStyle(PrimaryActionButtonStyle())
|
||||
.accessibilityIdentifier("upgradeButton")
|
||||
.padding(.top, 16)
|
||||
.padding(.bottom, 24)
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertMessage)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(theme.fonts.subheadline)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
.padding(.bottom, 35)
|
||||
.padding(.horizontal, 12)
|
||||
Toggle(isOn: $autoInviteUsers) {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertAutoInviteSwitch)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
Button {
|
||||
viewModel.send(viewAction: .cancel)
|
||||
} label: {
|
||||
Text(VectorL10n.cancel)
|
||||
}
|
||||
.buttonStyle(SecondaryActionButtonStyle())
|
||||
.accessibilityIdentifier("cancelButton")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: theme.colors.accent))
|
||||
.padding(.horizontal, 28)
|
||||
Divider()
|
||||
.padding(.horizontal, 28)
|
||||
Button {
|
||||
viewModel.send(viewAction: .done(autoInviteUsers))
|
||||
} label: {
|
||||
Text(VectorL10n.roomAccessSettingsScreenUpgradeAlertUpgradeButton)
|
||||
}
|
||||
.buttonStyle(PrimaryActionButtonStyle())
|
||||
.accessibilityIdentifier("upgradeButton")
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.top, 16)
|
||||
Button {
|
||||
viewModel.send(viewAction: .cancel)
|
||||
} label: {
|
||||
Text(VectorL10n.cancel)
|
||||
}
|
||||
.buttonStyle(SecondaryActionButtonStyle())
|
||||
.accessibilityIdentifier("cancelButton")
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.vertical, 16)
|
||||
}
|
||||
@@ -90,6 +91,13 @@ struct RoomUpgrade: View {
|
||||
.padding(.horizontal, 20)
|
||||
.frame(minWidth: 0, maxWidth: 500)
|
||||
}
|
||||
|
||||
private func noteText(_ message: String) -> some View {
|
||||
return Text(message)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(theme.fonts.subheadline)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
Reference in New Issue
Block a user