mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Handle threaded pinned events (#4704)
* implemented focussing a threaded event through the banner tap * view in timeline implementation for threaded events * added a test and improved the existing one * pr suggestions * put the logic for fetching the event in the view models
This commit is contained in:
@@ -85,11 +85,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
override func process(viewAction: RoomScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .tappedPinnedEventsBanner:
|
||||
analyticsService.trackInteraction(name: .PinnedMessageBannerClick)
|
||||
if let eventID = state.pinnedEventsBannerState.selectedPinnedEventID {
|
||||
actionsSubject.send(.focusEvent(eventID: eventID))
|
||||
}
|
||||
state.pinnedEventsBannerState.previousPin()
|
||||
handleTappedPinnedEventsBanner()
|
||||
case .viewAllPins:
|
||||
analyticsService.trackInteraction(name: .PinnedMessageBannerViewAllButton)
|
||||
actionsSubject.send(.displayPinnedEventsTimeline)
|
||||
@@ -402,6 +398,27 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
state.handledEventIDs.subtract(failedIDs)
|
||||
}
|
||||
|
||||
private func handleTappedPinnedEventsBanner() {
|
||||
analyticsService.trackInteraction(name: .PinnedMessageBannerClick)
|
||||
if let eventID = state.pinnedEventsBannerState.selectedPinnedEventID {
|
||||
Task {
|
||||
switch await roomProxy.loadOrFetchEventDetails(for: eventID) {
|
||||
case .success(let event):
|
||||
if appSettings.threadsEnabled,
|
||||
let threadRootEventID = event.threadRootEventId() {
|
||||
actionsSubject.send(.focusEvent(eventID: threadRootEventID))
|
||||
actionsSubject.send(.displayThread(threadRootEventID: threadRootEventID, focussedEventID: eventID))
|
||||
} else {
|
||||
actionsSubject.send(.focusEvent(eventID: eventID))
|
||||
}
|
||||
case .failure:
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
}
|
||||
}
|
||||
}
|
||||
state.pinnedEventsBannerState.previousPin()
|
||||
}
|
||||
|
||||
// MARK: Loading indicators
|
||||
|
||||
private static let loadingIndicatorIdentifier = "\(RoomScreenViewModel.self)-Loading"
|
||||
|
||||
Reference in New Issue
Block a user