Add retry decryption encrypted timeline item debug menu option (#384)

* Fixed a couple of warnings (+2 squashed commits)
Squashed commits:
[21fbc3b0] Add changelog
[abb092c6] Add retry decryption encrypted timeline item debug menu option

* Cleanup room list state computations

* Bump the RustSDK to v1.0.25-alpha

* Fix brew CI errors: remove imagemagick and brew lock file entirely

* Fix release script version bumping

* Bump ruby dependencies
This commit is contained in:
Stefan Ceriu
2022-12-22 13:59:38 +02:00
committed by GitHub
parent 131197b7d7
commit ac77743c7a
23 changed files with 117 additions and 266 deletions
@@ -193,7 +193,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
private func contextMenuActionsForItemId(_ itemId: String) -> TimelineItemContextMenuActions {
guard let timelineItem = timelineController.timelineItems.first(where: { $0.id == itemId }),
let item = timelineItem as? EventBasedTimelineItemProtocol else {
return .init(actions: [])
return .init(actions: [], debugActions: [])
}
var actions: [TimelineItemContextMenuAction] = [
@@ -208,7 +208,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
actions.append(.redact)
}
return .init(actions: actions)
var debugActions: [TimelineItemContextMenuAction] = [.viewSource]
if let item = timelineItem as? EncryptedRoomTimelineItem,
case let .megolmV1AesSha2(sessionId) = item.encryptionType {
debugActions.append(.retryDecryption(sessionId: sessionId))
}
return .init(actions: actions, debugActions: debugActions)
}
// swiftlint:disable:next cyclomatic_complexity
@@ -238,7 +245,9 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
displayError(.alert(ElementL10n.roomTimelinePermalinkCreationFailure))
}
case .redact:
redact(itemId)
Task {
await timelineController.redact(itemId)
}
case .reply:
state.bindings.composerFocused = true
state.composerMode = .reply(id: item.id, displayName: item.senderDisplayName ?? item.senderId)
@@ -246,16 +255,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
let debugDescription = timelineController.debugDescriptionFor(item.id)
MXLog.info(debugDescription)
state.bindings.debugInfo = .init(title: "Timeline item", content: debugDescription)
case .retryDecryption(let sessionId):
Task {
await timelineController.retryDecryption(forSessionId: sessionId)
}
}
if action.switchToDefaultComposer {
state.composerMode = .default
}
}
private func redact(_ eventID: String) {
Task {
await timelineController.redact(eventID)
}
}
}