mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Update the SDK and handle breaking changes. (#2527)
This commit is contained in:
@@ -21,6 +21,7 @@ struct ReportContentScreenCoordinatorParameters {
|
||||
let eventID: String
|
||||
let senderID: String
|
||||
let roomProxy: RoomProxyProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
@@ -42,7 +43,10 @@ final class ReportContentScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: ReportContentScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = ReportContentScreenViewModel(eventID: parameters.eventID, senderID: parameters.senderID, roomProxy: parameters.roomProxy)
|
||||
viewModel = ReportContentScreenViewModel(eventID: parameters.eventID,
|
||||
senderID: parameters.senderID,
|
||||
roomProxy: parameters.roomProxy,
|
||||
clientProxy: parameters.clientProxy)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -55,9 +59,9 @@ final class ReportContentScreenCoordinator: CoordinatorProtocol {
|
||||
switch action {
|
||||
case .submitStarted:
|
||||
startLoading()
|
||||
case let .submitFailed(error):
|
||||
case let .submitFailed(message):
|
||||
stopLoading()
|
||||
showError(description: error.localizedDescription)
|
||||
showError(description: message)
|
||||
case .submitFinished:
|
||||
stopLoading()
|
||||
actionsSubject.send(.finish)
|
||||
|
||||
@@ -20,7 +20,7 @@ enum ReportContentScreenViewModelAction: Equatable {
|
||||
case cancel
|
||||
case submitStarted
|
||||
case submitFinished
|
||||
case submitFailed(error: RoomProxyError)
|
||||
case submitFailed(message: String)
|
||||
}
|
||||
|
||||
struct ReportContentScreenViewState: BindableState {
|
||||
|
||||
@@ -23,16 +23,18 @@ class ReportContentScreenViewModel: ReportContentScreenViewModelType, ReportCont
|
||||
private let eventID: String
|
||||
private let senderID: String
|
||||
private let roomProxy: RoomProxyProtocol
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let actionsSubject: PassthroughSubject<ReportContentScreenViewModelAction, Never> = .init()
|
||||
|
||||
var actions: AnyPublisher<ReportContentScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(eventID: String, senderID: String, roomProxy: RoomProxyProtocol) {
|
||||
init(eventID: String, senderID: String, roomProxy: RoomProxyProtocol, clientProxy: ClientProxyProtocol) {
|
||||
self.eventID = eventID
|
||||
self.senderID = senderID
|
||||
self.roomProxy = roomProxy
|
||||
self.clientProxy = clientProxy
|
||||
|
||||
super.init(initialViewState: ReportContentScreenViewState(bindings: ReportContentScreenViewStateBindings(reasonText: "", ignoreUser: false)))
|
||||
}
|
||||
@@ -55,14 +57,14 @@ class ReportContentScreenViewModel: ReportContentScreenViewModelType, ReportCont
|
||||
|
||||
if case let .failure(error) = await roomProxy.reportContent(eventID, reason: state.bindings.reasonText) {
|
||||
MXLog.error("Submit Report Content failed: \(error)")
|
||||
actionsSubject.send(.submitFailed(error: error))
|
||||
actionsSubject.send(.submitFailed(message: error.localizedDescription))
|
||||
return
|
||||
}
|
||||
|
||||
// Ignore the sender if the user wants to.
|
||||
if state.bindings.ignoreUser, case let .failure(error) = await roomProxy.ignoreUser(senderID) {
|
||||
if state.bindings.ignoreUser, case let .failure(error) = await clientProxy.ignoreUser(senderID) {
|
||||
MXLog.error("Ignore user failed: \(error)")
|
||||
actionsSubject.send(.submitFailed(error: error))
|
||||
actionsSubject.send(.submitFailed(message: error.localizedDescription))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ struct ReportContentScreen: View {
|
||||
struct ReportContentScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = ReportContentScreenViewModel(eventID: "",
|
||||
senderID: "",
|
||||
roomProxy: RoomProxyMock(with: .init()))
|
||||
roomProxy: RoomProxyMock(with: .init()),
|
||||
clientProxy: ClientProxyMock(.init()))
|
||||
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
|
||||
Reference in New Issue
Block a user