Fix review comments

Also fix a crash on iPad.
This commit is contained in:
Doug 2022-10-05 15:51:43 +01:00 committed by Doug
parent bb07a11e7e
commit cb2207ec14
4 changed files with 19 additions and 15 deletions

View file

@ -29,3 +29,14 @@ class AuthenticatedEndpointRequest: NSObject {
super.init()
}
}
// MARK: - Helper methods
extension AuthenticatedEndpointRequest {
/// Create an authenticated request on `_matrix/client/r0/devices/{deviceID}`.
/// - Parameter deviceID: The device ID that is to be deleted.
static func deleteDevice(_ deviceID: String) -> AuthenticatedEndpointRequest {
let path = String(format: "%@/devices/%@", kMXAPIPrefixPathR0, MXTools.encodeURIComponent(deviceID))
return AuthenticatedEndpointRequest(path: path, httpMethod: "DELETE")
}
}

View file

@ -19,7 +19,7 @@ import Foundation
struct UserSessionsFlowCoordinatorParameters {
let session: MXSession
let router: NavigationRouterType?
let router: NavigationRouterType
}
final class UserSessionsFlowCoordinator: Coordinator, Presentable {
@ -41,11 +41,9 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
init(parameters: UserSessionsFlowCoordinatorParameters) {
self.parameters = parameters
let navigationRouter = parameters.router ?? NavigationRouter(navigationController: RiotNavigationController())
self.navigationRouter = navigationRouter
self.navigationRouter = parameters.router
errorPresenter = MXKErrorAlertPresentation()
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: navigationRouter.toPresentable())
indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: parameters.router.toPresentable())
}
// MARK: - Private
@ -146,6 +144,7 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
self?.showLogoutAuthentication(for: sessionInfo)
})
alert.addAction(UIAlertAction(title: VectorL10n.cancel, style: .cancel))
alert.popoverPresentationController?.sourceView = toPresentable().view
navigationRouter.present(alert, animated: true)
}
@ -154,9 +153,7 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
private func showLogoutAuthentication(for sessionInfo: UserSessionInfo) {
startLoading()
let path = String(format: "%@/devices/%@", kMXAPIPrefixPathR0, MXTools.encodeURIComponent(sessionInfo.id))
let deleteDeviceRequest = AuthenticatedEndpointRequest(path: path, httpMethod: "DELETE")
let deleteDeviceRequest = AuthenticatedEndpointRequest.deleteDevice(sessionInfo.id)
let coordinatorParameters = ReauthenticationCoordinatorParameters(session: parameters.session,
presenter: navigationRouter.toPresentable(),
title: VectorL10n.deviceDetailsDeletePromptTitle,

View file

@ -42,12 +42,8 @@ final class UserSessionsFlowCoordinatorBridgePresenter: NSObject {
// MARK: - Private
private func startUserSessionsFlow(mxSession: MXSession, navigationController: UINavigationController?) {
var navigationRouter: NavigationRouterType?
if let navigationController = navigationController {
navigationRouter = NavigationRouterStore.shared.navigationRouter(for: navigationController)
}
private func startUserSessionsFlow(mxSession: MXSession, navigationController: UINavigationController) {
let navigationRouter = NavigationRouterStore.shared.navigationRouter(for: navigationController)
let parameters = UserSessionsFlowCoordinatorParameters(session: mxSession, router: navigationRouter)
let coordinator = UserSessionsFlowCoordinator(parameters: parameters)

View file

@ -51,7 +51,7 @@ struct UserSessionOverviewItem: View {
}
}
struct UserSessionOverviewButtonCell_Previews: PreviewProvider {
struct UserSessionOverviewItem_Previews: PreviewProvider {
static var buttons: some View {
NavigationView {
ScrollView {