generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce a `MediaEventsTimelineFlowCoordinator` * Update SDK API and architecture * Add a feature flag, add translations * Move the media events timeline presentation under the room flow coordinator state machine * Rename `TimelineViewState.timelineViewState` of type `TimelineState` to `timelineState` * Enabled SwiftLint's `trailing_closure` rule and fix the warnings.
- Loading branch information
1 parent
a9e4837
commit caaa89a
Showing
83 changed files
with
1,247 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
ElementX/Sources/FlowCoordinators/MediaEventsTimelineFlowCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// Copyright 2024 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// Please see LICENSE in the repository root for full details. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
|
||
enum MediaEventsTimelineFlowCoordinatorAction { | ||
case finished | ||
} | ||
|
||
class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol { | ||
private let navigationStackCoordinator: NavigationStackCoordinator | ||
private let userSession: UserSessionProtocol | ||
private let roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol | ||
private let roomProxy: JoinedRoomProxyProtocol | ||
private let userIndicatorController: UserIndicatorControllerProtocol | ||
private let appMediator: AppMediatorProtocol | ||
private let emojiProvider: EmojiProviderProtocol | ||
|
||
private let actionsSubject: PassthroughSubject<MediaEventsTimelineFlowCoordinatorAction, Never> = .init() | ||
var actionsPublisher: AnyPublisher<MediaEventsTimelineFlowCoordinatorAction, Never> { | ||
actionsSubject.eraseToAnyPublisher() | ||
} | ||
|
||
private var cancellables = Set<AnyCancellable>() | ||
|
||
init(navigationStackCoordinator: NavigationStackCoordinator, | ||
userSession: UserSessionProtocol, | ||
roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol, | ||
roomProxy: JoinedRoomProxyProtocol, | ||
userIndicatorController: UserIndicatorControllerProtocol, | ||
appMediator: AppMediatorProtocol, | ||
emojiProvider: EmojiProviderProtocol) { | ||
self.navigationStackCoordinator = navigationStackCoordinator | ||
self.userSession = userSession | ||
self.roomTimelineControllerFactory = roomTimelineControllerFactory | ||
self.roomProxy = roomProxy | ||
self.userIndicatorController = userIndicatorController | ||
self.appMediator = appMediator | ||
self.emojiProvider = emojiProvider | ||
} | ||
|
||
func start() { | ||
Task { await presentMediaEventsTimeline() } | ||
} | ||
|
||
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) { | ||
fatalError() | ||
} | ||
|
||
func clearRoute(animated: Bool) { | ||
fatalError() | ||
} | ||
|
||
// MARK: - Private | ||
|
||
private func presentMediaEventsTimeline() async { | ||
let timelineItemFactory = RoomTimelineItemFactory(userID: userSession.clientProxy.userID, | ||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), | ||
stateEventStringBuilder: RoomStateEventStringBuilder(userID: userSession.clientProxy.userID)) | ||
|
||
guard case let .success(mediaTimelineController) = await roomTimelineControllerFactory.buildMessageFilteredRoomTimelineController(allowedMessageTypes: [.image, .video], | ||
roomProxy: roomProxy, | ||
timelineItemFactory: timelineItemFactory, | ||
mediaProvider: userSession.mediaProvider) else { | ||
MXLog.error("Failed presenting media timeline") | ||
return | ||
} | ||
|
||
guard case let .success(filesTimelineController) = await roomTimelineControllerFactory.buildMessageFilteredRoomTimelineController(allowedMessageTypes: [.file, .audio], | ||
roomProxy: roomProxy, | ||
timelineItemFactory: timelineItemFactory, | ||
mediaProvider: userSession.mediaProvider) else { | ||
MXLog.error("Failed presenting media timeline") | ||
return | ||
} | ||
|
||
let parameters = MediaEventsTimelineScreenCoordinatorParameters(roomProxy: roomProxy, | ||
mediaTimelineController: mediaTimelineController, | ||
filesTimelineController: filesTimelineController, | ||
mediaProvider: userSession.mediaProvider, | ||
mediaPlayerProvider: MediaPlayerProvider(), | ||
voiceMessageMediaManager: userSession.voiceMessageMediaManager, | ||
appMediator: appMediator, | ||
emojiProvider: emojiProvider) | ||
|
||
let coordinator = MediaEventsTimelineScreenCoordinator(parameters: parameters) | ||
|
||
navigationStackCoordinator.push(coordinator) { [weak self] in | ||
self?.actionsSubject.send(.finished) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.