Hook up the actions in the media details sheet. (#3607)

This commit is contained in:
Doug
2024-12-12 09:22:36 +00:00
committed by GitHub
parent 114255c5ec
commit 88b5426e97
12 changed files with 109 additions and 13 deletions
@@ -55,9 +55,9 @@ class TimelineMediaPreviewController: QLPreviewController, QLPreviewControllerDa
switch action {
case .loadedMediaFile:
self?.refreshCurrentPreviewItem()
case .viewInTimeline:
case .viewInRoomTimeline, .dismiss:
self?.dismiss(animated: true) // Dismiss the details sheet.
// Errrr, hmmmmm, do something else here.
// And let the view model handle the rest.
}
}
.store(in: &cancellables)
@@ -7,9 +7,10 @@
import QuickLook
enum TimelineMediaPreviewViewModelAction {
enum TimelineMediaPreviewViewModelAction: Equatable {
case loadedMediaFile
case viewInTimeline
case viewInRoomTimeline(TimelineItemIdentifier)
case dismiss
}
struct TimelineMediaPreviewViewState: BindableState {
@@ -51,14 +51,16 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
case .menuAction(let action):
switch action {
case .viewInRoomTimeline:
actionsSubject.send(.viewInTimeline)
actionsSubject.send(.viewInRoomTimeline(state.currentItem.id))
case .redact:
state.bindings.isPresentingRedactConfirmation = true
default:
MXLog.error("Received unexpected action: \(action)")
}
case .redactConfirmation:
break // Do it here??
timelineViewModel.context.send(viewAction: .handleTimelineItemMenuAction(itemID: state.currentItem.id, action: .redact))
state.bindings.isPresentingRedactConfirmation = false
actionsSubject.send(.dismiss) // Will dismiss the details sheet and the QuickLook view.
}
}