mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 20:39:24 +00:00
A bunch of random tweaks. (#3317)
- Fix warning on single case enum. - Remove unused subjects. - Fix a lint warning. - Remove unused success value. - Fix warning about position of try await. - Add a note about the common tracing configuration. - Show an indicator when resolving a send failure fails. - Make sure the whole row is clickable in the GlobalSearchScreen.
This commit is contained in:
@@ -28,7 +28,7 @@ struct CallScreenViewState: BindableState {
|
||||
struct Bindings {
|
||||
var javaScriptMessageHandler: ((Any) -> Void)?
|
||||
var javaScriptEvaluator: ((String) async throws -> Any)?
|
||||
var requestPictureInPictureHandler: (() async -> Result<AVPictureInPictureController, CallScreenError>)?
|
||||
var requestPictureInPictureHandler: (() async -> Result<Void, CallScreenError>)?
|
||||
|
||||
var alertInfo: AlertInfo<UUID>?
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
}
|
||||
|
||||
switch await requestPictureInPictureHandler() {
|
||||
case .success(let controller):
|
||||
case .success:
|
||||
actionsSubject.send(.pictureInPictureStarted)
|
||||
case .failure:
|
||||
actionsSubject.send(.dismiss)
|
||||
|
||||
@@ -200,7 +200,7 @@ private struct CallView: UIViewRepresentable {
|
||||
|
||||
// MARK: - Picture in Picture
|
||||
|
||||
func requestPictureInPicture() async -> Result<AVPictureInPictureController, CallScreenError> {
|
||||
func requestPictureInPicture() async -> Result<Void, CallScreenError> {
|
||||
guard let pictureInPictureController,
|
||||
pictureInPictureController.isPictureInPicturePossible,
|
||||
case .success(true) = await webViewCanEnterPictureInPicture() else {
|
||||
@@ -208,7 +208,7 @@ private struct CallView: UIViewRepresentable {
|
||||
}
|
||||
|
||||
pictureInPictureController.startPictureInPicture()
|
||||
return .success(pictureInPictureController)
|
||||
return .success(())
|
||||
}
|
||||
|
||||
func stopPictureInPicture() {
|
||||
|
||||
@@ -23,6 +23,7 @@ struct GlobalSearchScreen: View {
|
||||
GlobalSearchScreenListRow(room: room, context: context)
|
||||
.listRowBackground(backgroundColor(for: room))
|
||||
.listRowInsets(.init())
|
||||
.contentShape(.rect)
|
||||
.onTapGesture {
|
||||
context.send(viewAction: .select(roomID: room.id))
|
||||
}
|
||||
|
||||
+3
-1
@@ -21,6 +21,7 @@ struct ResolveVerifiedUserSendFailureScreenCoordinatorParameters {
|
||||
let failure: TimelineItemSendFailure.VerifiedUser
|
||||
let itemID: TimelineItemIdentifier
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum ResolveVerifiedUserSendFailureScreenCoordinatorAction {
|
||||
@@ -43,7 +44,8 @@ final class ResolveVerifiedUserSendFailureScreenCoordinator: CoordinatorProtocol
|
||||
|
||||
viewModel = ResolveVerifiedUserSendFailureScreenViewModel(failure: parameters.failure,
|
||||
itemID: parameters.itemID,
|
||||
roomProxy: parameters.roomProxy)
|
||||
roomProxy: parameters.roomProxy,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
+21
-4
@@ -26,12 +26,17 @@ class ResolveVerifiedUserSendFailureScreenViewModel: ResolveVerifiedUserSendFail
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private var members: [String: RoomMemberProxyProtocol]
|
||||
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<ResolveVerifiedUserSendFailureScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<ResolveVerifiedUserSendFailureScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(failure: TimelineItemSendFailure.VerifiedUser, itemID: TimelineItemIdentifier, roomProxy: JoinedRoomProxyProtocol) {
|
||||
init(failure: TimelineItemSendFailure.VerifiedUser,
|
||||
itemID: TimelineItemIdentifier,
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
iterator = switch failure {
|
||||
case .hasUnsignedDevice(let devices): UnsignedDeviceFailureIterator(devices: devices)
|
||||
case .changedIdentity(let users): ChangedIdentityFailureIterator(users: users)
|
||||
@@ -40,6 +45,7 @@ class ResolveVerifiedUserSendFailureScreenViewModel: ResolveVerifiedUserSendFail
|
||||
self.failure = failure
|
||||
self.itemID = itemID
|
||||
self.roomProxy = roomProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
members = Dictionary(uniqueKeysWithValues: roomProxy.membersPublisher.value.map { ($0.userID, $0) })
|
||||
|
||||
@@ -77,7 +83,8 @@ class ResolveVerifiedUserSendFailureScreenViewModel: ResolveVerifiedUserSendFail
|
||||
}
|
||||
|
||||
if case let .failure(error) = result {
|
||||
#warning("Show the error?")
|
||||
MXLog.error("Failed to resolve send failure: \(error)")
|
||||
showFailureIndicator()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,10 +101,20 @@ class ResolveVerifiedUserSendFailureScreenViewModel: ResolveVerifiedUserSendFail
|
||||
switch await roomProxy.resend(itemID: itemID) {
|
||||
case .success:
|
||||
actionsSubject.send(.dismiss)
|
||||
case .failure(let failure):
|
||||
#warning("Show the error?")
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed to resend message: \(error)")
|
||||
showFailureIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
private static let failureIndicatorIdentifier = "\(ResolveVerifiedUserSendFailureScreenViewModel.self)-Failure"
|
||||
|
||||
private func showFailureIndicator() {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.failureIndicatorIdentifier,
|
||||
type: .toast,
|
||||
title: L10n.errorUnknown,
|
||||
iconName: "xmark"))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Iterators
|
||||
|
||||
+4
-2
@@ -95,14 +95,16 @@ struct ResolveVerifiedUserSendFailureScreen_Previews: PreviewProvider, TestableP
|
||||
static func makeViewModel(failure: TimelineItemSendFailure.VerifiedUser) -> ResolveVerifiedUserSendFailureScreenViewModel {
|
||||
ResolveVerifiedUserSendFailureScreenViewModel(failure: failure,
|
||||
itemID: .random,
|
||||
roomProxy: JoinedRoomProxyMock(.init()))
|
||||
roomProxy: JoinedRoomProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
struct ResolveVerifiedUserSendFailureScreenSheet_Previews: PreviewProvider {
|
||||
static let viewModel = ResolveVerifiedUserSendFailureScreenViewModel(failure: .changedIdentity(users: ["@alice:matrix.org"]),
|
||||
itemID: .random,
|
||||
roomProxy: JoinedRoomProxyMock(.init()))
|
||||
roomProxy: JoinedRoomProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
static var previews: some View {
|
||||
Text("Hello")
|
||||
|
||||
@@ -565,10 +565,8 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
}
|
||||
|
||||
private func slashCommand(message: String) -> SlashCommand? {
|
||||
for command in SlashCommand.allCases {
|
||||
if message.starts(with: command.rawValue) {
|
||||
return command
|
||||
}
|
||||
for command in SlashCommand.allCases where message.starts(with: command.rawValue) {
|
||||
return command
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user