mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Use the new preview screen when tapping media on the room and pinned events screens. (#3736)
* Use the new TimelineMediaPreview modifier on the room and pinned timeline screens. * Use the same presentation logic for all timeline media previews. * Fix a bug with the detection of the timeline end. * Send pagination requests from the media preview screen. * Add SwiftLint to the Danger workflow (it is no longer installed on the runner). * Put SwiftLint back on all of the GitHub runners too. * Set the function_parameter_count lint rule to 10. * Make sure to clean-up any previews when the coordinator is done. * Handle the viewInRoomTimeline action more appropriately.
This commit is contained in:
@@ -63,7 +63,11 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
||||
|
||||
timelineViewModel.context.$viewState.map(\.timelineState.paginationState)
|
||||
.removeDuplicates()
|
||||
.weakAssign(to: \.state.dataSource.paginationState, on: self)
|
||||
.sink { [weak self] paginationState in
|
||||
guard let self else { return }
|
||||
state.dataSource.paginationState = paginationState
|
||||
paginateIfNeeded()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
@@ -77,7 +81,7 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
||||
switch action {
|
||||
case .viewInRoomTimeline:
|
||||
state.previewControllerDriver.send(.dismissDetailsSheet)
|
||||
actionsSubject.send(.viewInRoomTimeline(item.id))
|
||||
actionsSubject.send(.viewInRoomTimeline(item.timelineItem.id))
|
||||
case .save:
|
||||
Task { await saveCurrentItem() }
|
||||
case .redact:
|
||||
@@ -111,6 +115,23 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
||||
mediaItem.downloadError = error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
paginateIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
private func paginateIfNeeded() {
|
||||
switch state.currentItem {
|
||||
case .loading(.paginatingBackwards):
|
||||
if state.dataSource.paginationState.backward == .idle {
|
||||
timelineViewModel.context.send(viewAction: .paginateBackwards)
|
||||
}
|
||||
case .loading(.paginatingForwards):
|
||||
if state.dataSource.paginationState.forward == .idle {
|
||||
timelineViewModel.context.send(viewAction: .paginateForwards)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +187,7 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
||||
}
|
||||
|
||||
private func redactItem(_ item: TimelineMediaPreviewItem.Media) {
|
||||
timelineViewModel.context.send(viewAction: .handleTimelineItemMenuAction(itemID: item.id, action: .redact))
|
||||
timelineViewModel.context.send(viewAction: .handleTimelineItemMenuAction(itemID: item.timelineItem.id, action: .redact))
|
||||
state.bindings.redactConfirmationItem = nil
|
||||
state.previewControllerDriver.send(.dismissDetailsSheet)
|
||||
actionsSubject.send(.dismiss)
|
||||
|
||||
Reference in New Issue
Block a user