Allow the user to forward the same message to multiple rooms at once

This will send the item to the rooms in order they were chosen and only deep link
into the target room if single, otherwise it will just dismiss the forwarding screen
after sending.
This commit is contained in:
Stefan Ceriu
2026-05-27 13:55:35 +03:00
parent 7093d966b4
commit f040964d3f
7 changed files with 51 additions and 32 deletions
@@ -12,7 +12,7 @@ import Foundation
enum PinnedEventsTimelineFlowCoordinatorAction {
case finished
case displayUser(userID: String)
case forwardedMessageToRoom(roomID: String)
case forwardedMessageToRooms(roomIDs: [String])
case displayRoomScreenWithFocussedPin(eventID: String, threadRootEventID: String?)
}
@@ -148,9 +148,9 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
switch action {
case .dismiss:
navigationStackCoordinator.setSheetCoordinator(nil)
case .sent(let roomID):
case .sent(let roomIDs):
navigationStackCoordinator.setSheetCoordinator(nil)
actionsSubject.send(.forwardedMessageToRoom(roomID: roomID))
actionsSubject.send(.forwardedMessageToRooms(roomIDs: roomIDs))
}
}
.store(in: &cancellables)
@@ -1282,10 +1282,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
switch action {
case .dismiss:
navigationStackCoordinator.setSheetCoordinator(nil)
case .sent(let roomID):
case .sent(let roomIDs):
navigationStackCoordinator.setSheetCoordinator(nil)
// Timelines are cached - the local echo will be visible when fetching the room by its ID.
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
processPostMessageForwardingTo(rooms: roomIDs)
}
}
.store(in: &cancellables)
@@ -1524,6 +1523,15 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
}
private func processPostMessageForwardingTo(rooms roomIDs: [String]) {
// Only open forwarding target room if single.
guard roomIDs.count == 1, let roomID = roomIDs.last else {
return
}
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
}
// MARK: - Other flows
private func startChildFlow(for roomID: String, via: [String], entryPoint: RoomFlowCoordinatorEntryPoint) {
@@ -1582,9 +1590,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
case .displayUser(let userID):
navigationStackCoordinator.setSheetCoordinator(nil)
stateMachine.tryEvent(.startMembersFlow(entryPoint: .roomMember(userID: userID)))
case .forwardedMessageToRoom(let roomID):
case .forwardedMessageToRooms(let roomIDs):
navigationStackCoordinator.setSheetCoordinator(nil)
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
processPostMessageForwardingTo(rooms: roomIDs)
case .displayRoomScreenWithFocussedPin(let eventID, let threadRootEventID):
navigationStackCoordinator.setSheetCoordinator(nil)
if let threadRootEventID {