mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Add multi selection to the Forward action (#6190)
* Start message selection from the Forward action Behind the multi-select developer option, choosing Forward on a message now starts a selection with that message checked, instead of the dedicated Select menu action which is removed. Only forwardable messages can be selected: remote, decrypted, non-redacted events that aren't state, unsupported, poll or live location items. The chrome follows the Figma exploration: the room header stays, an X in the trailing toolbar position ends the selection, rows show only the checkbox (no highlight, 10pt gap to the bubble), and the composer is replaced by a single primary "Forward N messages" button. The limits are now 10 messages into 5 rooms. Tapping the button forwards the selection in timeline order, never in the order the messages were tapped. MessageForwardingItem carries several contents and the forwarding screen sends them one after the other per room, reporting a single error toast on partial failures. The selection is kept while the forwarding screen is open so cancelling it returns to the selection; it is cleared by the flow coordinator once the messages are sent, or by the X in the timeline. New plural action_forward_messages lives in Untranslated for now; action_select and screen_room_selection_count are no longer used. * Tidy the selection code after review Reuse ToolbarButton's cancel role for the selection's toolbar item so it matches the other screens on every OS version, and disable the room header while selecting so the room details can't cover the selection. Move the forwardable/selected item helpers next to the existing nonisolated array extension, drop the unused MessageForwardingItem initialisers and the single-item makeForwardingItem overload, and simplify the forwarding loop now that a room either sends or isn't reachable. The action bar preview builds its own view model instead of putting the shared mock into selection mode for every later preview, and a test locks that Forward keeps forwarding directly in the pinned timeline. * Select messages to forward from the pinned timeline too Forward is offered in the pinned events timeline, so with the flag on it starts a selection there as well, with the same cancel item in the toolbar and the same forward button at the bottom. Forwarding from that sheet already dismisses the whole sheet, so the selection is discarded with it. Only the media timelines keep forwarding a single item directly. * Confirm with a toast when messages are forwarded to several rooms When a single room is picked the flow opens it, which is confirmation enough. When several rooms are picked the user stays in the origin room, so a "Messages forwarded" toast tells them it worked, as in the designs. The new screen_room_message_forwarded / screen_room_messages_forwarded strings live in Untranslated for now. * Apply review suggestions to multi-message forwarding Strings - The forward button and the multi-room toast now use the Localazy plurals action_forward_messages and screen_room_messages_forwarded; the toast shows the count. The Untranslated copies and the unused action_select are gone. Selection - Drop the dead startSelection view action and the redundant canSelectMessages guard; tests start a selection through Forward like the app does. - Remove two comments on the selection state that restated the code. Forwarding - After a send, clear the selection in the room and any open thread instead of working out which one started it; only one can be selecting at a time. - Explain that stickers are excluded because the SDK can only forward m.room.message content. * Rename the timeline selection to message selection "Selection" alone was too generic in a timeline that also has text and room selections. The selection state, toolbar, action bar and accessibility types, the timeline state's property, the view actions and the public clear method now say "message selection". Private helpers keep their short names. * Rename MessageForwardingItem to MessageForwardingPayload The type now carries several messages, so "item" no longer described it. The factory method and the variables and action labels holding it follow the new name.
This commit is contained in:
@@ -803,6 +803,10 @@ extension AccessibilityTests {
|
|||||||
try await performAccessibilityAudit(named: "TimelineMediaPreviewRedactConfirmationView_Previews")
|
try await performAccessibilityAudit(named: "TimelineMediaPreviewRedactConfirmationView_Previews")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testTimelineMessageSelectionActionBar() async throws {
|
||||||
|
try await performAccessibilityAudit(named: "TimelineMessageSelectionActionBar_Previews")
|
||||||
|
}
|
||||||
|
|
||||||
func testTimelineReactionView() async throws {
|
func testTimelineReactionView() async throws {
|
||||||
try await performAccessibilityAudit(named: "TimelineReactionView_Previews")
|
try await performAccessibilityAudit(named: "TimelineReactionView_Previews")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
053B8BD2496207838878C6C9 /* PinnedItemsBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C9BAE9F9436B14E4E22E8F /* PinnedItemsBannerView.swift */; };
|
053B8BD2496207838878C6C9 /* PinnedItemsBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C9BAE9F9436B14E4E22E8F /* PinnedItemsBannerView.swift */; };
|
||||||
059173B3C77056C406906B6D /* target.yml in Resources */ = {isa = PBXBuildFile; fileRef = D4DA544B2520BFA65D6DB4BB /* target.yml */; };
|
059173B3C77056C406906B6D /* target.yml in Resources */ = {isa = PBXBuildFile; fileRef = D4DA544B2520BFA65D6DB4BB /* target.yml */; };
|
||||||
059A6BEDE9BADF3C81AC4146 /* SpaceAddRoomsScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AB44FFCF7DA5300D943169 /* SpaceAddRoomsScreenSelectedItem.swift */; };
|
059A6BEDE9BADF3C81AC4146 /* SpaceAddRoomsScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AB44FFCF7DA5300D943169 /* SpaceAddRoomsScreenSelectedItem.swift */; };
|
||||||
|
05A7A9E3653E018E383C9890 /* TimelineMessageSelectionActionBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4791FBED207151AE487DBE11 /* TimelineMessageSelectionActionBar.swift */; };
|
||||||
05B02B9508E922677F0E9451 /* LocationSharingScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 052A8C0B00FE8AD7C972F2A4 /* LocationSharingScreenViewModel.swift */; };
|
05B02B9508E922677F0E9451 /* LocationSharingScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 052A8C0B00FE8AD7C972F2A4 /* LocationSharingScreenViewModel.swift */; };
|
||||||
05BAB510CBC2ED35C154ADD0 /* AnalyticsPromptScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFD012C3A9F5EF276DDD4AA /* AnalyticsPromptScreenViewModelProtocol.swift */; };
|
05BAB510CBC2ED35C154ADD0 /* AnalyticsPromptScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFD012C3A9F5EF276DDD4AA /* AnalyticsPromptScreenViewModelProtocol.swift */; };
|
||||||
05E797C4E0048BB487E5C4D6 /* AppLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8495F37D6245AD0CFA1F60B /* AppLockTests.swift */; };
|
05E797C4E0048BB487E5C4D6 /* AppLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8495F37D6245AD0CFA1F60B /* AppLockTests.swift */; };
|
||||||
@@ -426,6 +427,7 @@
|
|||||||
440123E29E2F9B001A775BBE /* TimelineItemProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D505843AB66822EB91F0DF0 /* TimelineItemProxy.swift */; };
|
440123E29E2F9B001A775BBE /* TimelineItemProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D505843AB66822EB91F0DF0 /* TimelineItemProxy.swift */; };
|
||||||
441857143FC100E0A7DE42A8 /* RoomPowerLevelProxyProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D635709C1D6D37C225AD40E /* RoomPowerLevelProxyProtocol.swift */; };
|
441857143FC100E0A7DE42A8 /* RoomPowerLevelProxyProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D635709C1D6D37C225AD40E /* RoomPowerLevelProxyProtocol.swift */; };
|
||||||
446BCD2D0AE27E0CFD1BDC8F /* ImageMediaEventsTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF584D757E768EA7776A532 /* ImageMediaEventsTimelineView.swift */; };
|
446BCD2D0AE27E0CFD1BDC8F /* ImageMediaEventsTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FF584D757E768EA7776A532 /* ImageMediaEventsTimelineView.swift */; };
|
||||||
|
44B698EFE616E1E7FD34C115 /* TimelineItemsSelectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B35297BA5FF73D83D8C72A2A /* TimelineItemsSelectionTests.swift */; };
|
||||||
44BDD670FF9095ACE240A3A2 /* VoiceMessageMediaManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC4F10BDD56FA77FEC742333 /* VoiceMessageMediaManagerTests.swift */; };
|
44BDD670FF9095ACE240A3A2 /* VoiceMessageMediaManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC4F10BDD56FA77FEC742333 /* VoiceMessageMediaManagerTests.swift */; };
|
||||||
44D3EA8583C54BA3D8058499 /* SyncServiceSDKMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DBBBC78047C669166C9F7C /* SyncServiceSDKMock.swift */; };
|
44D3EA8583C54BA3D8058499 /* SyncServiceSDKMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33DBBBC78047C669166C9F7C /* SyncServiceSDKMock.swift */; };
|
||||||
44F0E1B576C7599DF8022071 /* SentrySwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 75361A9D8A3C5501EADB225D /* SentrySwiftUI */; };
|
44F0E1B576C7599DF8022071 /* SentrySwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 75361A9D8A3C5501EADB225D /* SentrySwiftUI */; };
|
||||||
@@ -1191,6 +1193,7 @@
|
|||||||
BCC864190651B3A3CF51E4DF /* MediaFileHandleProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC1D382565A4E9CAC2F14EA /* MediaFileHandleProxy.swift */; };
|
BCC864190651B3A3CF51E4DF /* MediaFileHandleProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC1D382565A4E9CAC2F14EA /* MediaFileHandleProxy.swift */; };
|
||||||
BD0BE20DBCE31253AE4490A1 /* RoomListFiltersEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC1DDB2293A51EA4C2739351 /* RoomListFiltersEmptyStateView.swift */; };
|
BD0BE20DBCE31253AE4490A1 /* RoomListFiltersEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC1DDB2293A51EA4C2739351 /* RoomListFiltersEmptyStateView.swift */; };
|
||||||
BD6685592716CA957D7BAAC4 /* RoomChangeRolesScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9B45D584D232CB9E5C7734 /* RoomChangeRolesScreenSelectedItem.swift */; };
|
BD6685592716CA957D7BAAC4 /* RoomChangeRolesScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9B45D584D232CB9E5C7734 /* RoomChangeRolesScreenSelectedItem.swift */; };
|
||||||
|
BDA14E4B772E28A792D7F5C8 /* TimelineMessageSelectionToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455993E99087FE797278AFD0 /* TimelineMessageSelectionToolbar.swift */; };
|
||||||
BDA68E8D95B2B24B28825B8B /* LoginScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C368CAB3063EF275357ECD4 /* LoginScreenViewModel.swift */; };
|
BDA68E8D95B2B24B28825B8B /* LoginScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C368CAB3063EF275357ECD4 /* LoginScreenViewModel.swift */; };
|
||||||
BDC4EB54CC3036730475CB8B /* QRCodeLoginScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25E7E9B7FEAB6169D960C206 /* QRCodeLoginScreenViewModelTests.swift */; };
|
BDC4EB54CC3036730475CB8B /* QRCodeLoginScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25E7E9B7FEAB6169D960C206 /* QRCodeLoginScreenViewModelTests.swift */; };
|
||||||
BDCF42966007770A33D90E15 /* PreviewScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB56ABD78E60920ACE43087 /* PreviewScrollView.swift */; };
|
BDCF42966007770A33D90E15 /* PreviewScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB56ABD78E60920ACE43087 /* PreviewScrollView.swift */; };
|
||||||
@@ -1600,7 +1603,6 @@
|
|||||||
FCF95603F1D056B1B106A415 /* AdvancedSettingsScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E2B20431F890ED64255CA1 /* AdvancedSettingsScreenViewModelProtocol.swift */; };
|
FCF95603F1D056B1B106A415 /* AdvancedSettingsScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E2B20431F890ED64255CA1 /* AdvancedSettingsScreenViewModelProtocol.swift */; };
|
||||||
FD19654C18E7C6D8AC79408D /* libMatrixRustSDKMocks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73F3153AB9D628110878E24F /* libMatrixRustSDKMocks.a */; };
|
FD19654C18E7C6D8AC79408D /* libMatrixRustSDKMocks.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73F3153AB9D628110878E24F /* libMatrixRustSDKMocks.a */; };
|
||||||
FD29471C72872F8B7580E3E1 /* KeychainControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39C0D861FC397AC34BCF089E /* KeychainControllerMock.swift */; };
|
FD29471C72872F8B7580E3E1 /* KeychainControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39C0D861FC397AC34BCF089E /* KeychainControllerMock.swift */; };
|
||||||
FD387E0B8962056D2092DF3F /* TimelineSelectionToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7C3B926E1BBC7569AC6C682 /* TimelineSelectionToolbar.swift */; };
|
|
||||||
FD573B5D665824EB79EABF06 /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5327E3B3C58BEB0E65F4CF98 /* Observable.swift */; };
|
FD573B5D665824EB79EABF06 /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5327E3B3C58BEB0E65F4CF98 /* Observable.swift */; };
|
||||||
FD9777315A5D9CDC47458AD1 /* MediaEventsTimelineScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A175D0FDEDBFA44C47FE13AE /* MediaEventsTimelineScreenViewModelProtocol.swift */; };
|
FD9777315A5D9CDC47458AD1 /* MediaEventsTimelineScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A175D0FDEDBFA44C47FE13AE /* MediaEventsTimelineScreenViewModelProtocol.swift */; };
|
||||||
FDD5B4B616D9FF4DE3E9A418 /* QRCodeScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92DB574F954CC2B40F7BE892 /* QRCodeScannerView.swift */; };
|
FDD5B4B616D9FF4DE3E9A418 /* QRCodeScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92DB574F954CC2B40F7BE892 /* QRCodeScannerView.swift */; };
|
||||||
@@ -2180,6 +2182,7 @@
|
|||||||
4525E8C0FBDD27D1ACE90952 /* SecureBackupKeyBackupScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupKeyBackupScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
4525E8C0FBDD27D1ACE90952 /* SecureBackupKeyBackupScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupKeyBackupScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
4549FCB53F43DB0B278374BC /* TemplateScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreen.swift; sourceTree = "<group>"; };
|
4549FCB53F43DB0B278374BC /* TemplateScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreen.swift; sourceTree = "<group>"; };
|
||||||
4552D3466B1453F287223ADA /* SwipeRightAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeRightAction.swift; sourceTree = "<group>"; };
|
4552D3466B1453F287223ADA /* SwipeRightAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeRightAction.swift; sourceTree = "<group>"; };
|
||||||
|
455993E99087FE797278AFD0 /* TimelineMessageSelectionToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineMessageSelectionToolbar.swift; sourceTree = "<group>"; };
|
||||||
459A3921046977CBF4F3C359 /* SpaceScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
459A3921046977CBF4F3C359 /* SpaceScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpaceScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
45CDF9A107BFE6C79B58D6B5 /* RoomMembersListScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersListScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
45CDF9A107BFE6C79B58D6B5 /* RoomMembersListScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembersListScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
45D8149FDDA0315CDC553B4B /* UserNotificationCenterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationCenterProtocol.swift; sourceTree = "<group>"; };
|
45D8149FDDA0315CDC553B4B /* UserNotificationCenterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationCenterProtocol.swift; sourceTree = "<group>"; };
|
||||||
@@ -2197,6 +2200,7 @@
|
|||||||
475EB595D7527E9A8A14043E /* uz */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uz; path = uz.lproj/Localizable.strings; sourceTree = "<group>"; };
|
475EB595D7527E9A8A14043E /* uz */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uz; path = uz.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
477A8C656B7B26E99C35927F /* StartChatFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartChatFlowCoordinator.swift; sourceTree = "<group>"; };
|
477A8C656B7B26E99C35927F /* StartChatFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartChatFlowCoordinator.swift; sourceTree = "<group>"; };
|
||||||
47873756E45B46683D97DC32 /* LegalInformationScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegalInformationScreenModels.swift; sourceTree = "<group>"; };
|
47873756E45B46683D97DC32 /* LegalInformationScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegalInformationScreenModels.swift; sourceTree = "<group>"; };
|
||||||
|
4791FBED207151AE487DBE11 /* TimelineMessageSelectionActionBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineMessageSelectionActionBar.swift; sourceTree = "<group>"; };
|
||||||
47EBB5D698CE9A25BB553A2D /* Strings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Strings.swift; sourceTree = "<group>"; };
|
47EBB5D698CE9A25BB553A2D /* Strings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Strings.swift; sourceTree = "<group>"; };
|
||||||
47F29139BC2A804CE5E0757E /* MediaUploadPreviewScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaUploadPreviewScreenViewModel.swift; sourceTree = "<group>"; };
|
47F29139BC2A804CE5E0757E /* MediaUploadPreviewScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaUploadPreviewScreenViewModel.swift; sourceTree = "<group>"; };
|
||||||
47F441A78A5CAA9E2937E463 /* KnockRequestsBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnockRequestsBannerView.swift; sourceTree = "<group>"; };
|
47F441A78A5CAA9E2937E463 /* KnockRequestsBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnockRequestsBannerView.swift; sourceTree = "<group>"; };
|
||||||
@@ -2829,6 +2833,7 @@
|
|||||||
B2EAFFD44F81F86012D6EC27 /* AudioRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRoomTimelineView.swift; sourceTree = "<group>"; };
|
B2EAFFD44F81F86012D6EC27 /* AudioRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRoomTimelineView.swift; sourceTree = "<group>"; };
|
||||||
B3005886F00029F058DB62BE /* StartChatScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartChatScreenCoordinator.swift; sourceTree = "<group>"; };
|
B3005886F00029F058DB62BE /* StartChatScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartChatScreenCoordinator.swift; sourceTree = "<group>"; };
|
||||||
B343C5255FB408DDE853CFDF /* RoomScreenHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomScreenHook.swift; sourceTree = "<group>"; };
|
B343C5255FB408DDE853CFDF /* RoomScreenHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomScreenHook.swift; sourceTree = "<group>"; };
|
||||||
|
B35297BA5FF73D83D8C72A2A /* TimelineItemsSelectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemsSelectionTests.swift; sourceTree = "<group>"; };
|
||||||
B3561843E139EA7CDAED0933 /* ClientFactoryHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientFactoryHook.swift; sourceTree = "<group>"; };
|
B3561843E139EA7CDAED0933 /* ClientFactoryHook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientFactoryHook.swift; sourceTree = "<group>"; };
|
||||||
B383DCD3DCB19E00FD478A5F /* ConfirmationDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmationDialog.swift; sourceTree = "<group>"; };
|
B383DCD3DCB19E00FD478A5F /* ConfirmationDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmationDialog.swift; sourceTree = "<group>"; };
|
||||||
B4005D82E9D27BAF006A8FE1 /* AppLockScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockScreenViewModel.swift; sourceTree = "<group>"; };
|
B4005D82E9D27BAF006A8FE1 /* AppLockScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockScreenViewModel.swift; sourceTree = "<group>"; };
|
||||||
@@ -3131,7 +3136,6 @@
|
|||||||
E7495E1119753B06FF2C2279 /* PhotoLibraryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoLibraryManager.swift; sourceTree = "<group>"; };
|
E7495E1119753B06FF2C2279 /* PhotoLibraryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoLibraryManager.swift; sourceTree = "<group>"; };
|
||||||
E76A706B3EEA32B882DA5E2D /* BlockedUsersScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedUsersScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
E76A706B3EEA32B882DA5E2D /* BlockedUsersScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedUsersScreenViewModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
E78FC546F28E045A560F2963 /* EncryptionKeyProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionKeyProviderProtocol.swift; sourceTree = "<group>"; };
|
E78FC546F28E045A560F2963 /* EncryptionKeyProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionKeyProviderProtocol.swift; sourceTree = "<group>"; };
|
||||||
E7C3B926E1BBC7569AC6C682 /* TimelineSelectionToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineSelectionToolbar.swift; sourceTree = "<group>"; };
|
|
||||||
E8294DB9E95C0C0630418466 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
E8294DB9E95C0C0630418466 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E8495F37D6245AD0CFA1F60B /* AppLockTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockTests.swift; sourceTree = "<group>"; };
|
E8495F37D6245AD0CFA1F60B /* AppLockTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockTests.swift; sourceTree = "<group>"; };
|
||||||
E858B68153E2C6E5800336AB /* CXCallControllerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CXCallControllerMock.swift; sourceTree = "<group>"; };
|
E858B68153E2C6E5800336AB /* CXCallControllerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CXCallControllerMock.swift; sourceTree = "<group>"; };
|
||||||
@@ -3690,9 +3694,10 @@
|
|||||||
02EE0FABA8ED6D6C1D6CE71D /* ReactionsSummaryView.swift */,
|
02EE0FABA8ED6D6C1D6CE71D /* ReactionsSummaryView.swift */,
|
||||||
66F91544AC136BF6477BDAB8 /* TimelineDeliveryStatusView.swift */,
|
66F91544AC136BF6477BDAB8 /* TimelineDeliveryStatusView.swift */,
|
||||||
72614BFF35B8394C6E13F55A /* TimelineItemStatusView.swift */,
|
72614BFF35B8394C6E13F55A /* TimelineItemStatusView.swift */,
|
||||||
|
4791FBED207151AE487DBE11 /* TimelineMessageSelectionActionBar.swift */,
|
||||||
|
455993E99087FE797278AFD0 /* TimelineMessageSelectionToolbar.swift */,
|
||||||
54AD70D6E03D2031AE1B5A52 /* TimelineReactionsView.swift */,
|
54AD70D6E03D2031AE1B5A52 /* TimelineReactionsView.swift */,
|
||||||
33035418BB35754232985871 /* TimelineReadReceiptsView.swift */,
|
33035418BB35754232985871 /* TimelineReadReceiptsView.swift */,
|
||||||
E7C3B926E1BBC7569AC6C682 /* TimelineSelectionToolbar.swift */,
|
|
||||||
);
|
);
|
||||||
path = Supplementary;
|
path = Supplementary;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -5334,6 +5339,7 @@
|
|||||||
53C65A839BC897F6C236E8A5 /* TimelineInteractionHandlerTests.swift */,
|
53C65A839BC897F6C236E8A5 /* TimelineInteractionHandlerTests.swift */,
|
||||||
9AA3AF94A06D319BB37E52DA /* TimelineItemFactoryTests.swift */,
|
9AA3AF94A06D319BB37E52DA /* TimelineItemFactoryTests.swift */,
|
||||||
C98C243A90369929D669873D /* TimelineItemMenuActionProviderTests.swift */,
|
C98C243A90369929D669873D /* TimelineItemMenuActionProviderTests.swift */,
|
||||||
|
B35297BA5FF73D83D8C72A2A /* TimelineItemsSelectionTests.swift */,
|
||||||
ED0AD0C652385F69FA90FAF5 /* TimelineMediaPreviewDataSourceTests.swift */,
|
ED0AD0C652385F69FA90FAF5 /* TimelineMediaPreviewDataSourceTests.swift */,
|
||||||
5C1F000589F2CEE6B03ECFAB /* TimelineMediaPreviewViewModelTests.swift */,
|
5C1F000589F2CEE6B03ECFAB /* TimelineMediaPreviewViewModelTests.swift */,
|
||||||
F968FDB68F9D4CB9010FED70 /* TimelineStateTests.swift */,
|
F968FDB68F9D4CB9010FED70 /* TimelineStateTests.swift */,
|
||||||
@@ -8451,6 +8457,7 @@
|
|||||||
ECE4E03D17E309724013F825 /* TimelineInteractionHandlerTests.swift in Sources */,
|
ECE4E03D17E309724013F825 /* TimelineInteractionHandlerTests.swift in Sources */,
|
||||||
0D4EB2ABAA5FE8CB10FDBCB8 /* TimelineItemFactoryTests.swift in Sources */,
|
0D4EB2ABAA5FE8CB10FDBCB8 /* TimelineItemFactoryTests.swift in Sources */,
|
||||||
0668BECCF11E8EE6936CDF16 /* TimelineItemMenuActionProviderTests.swift in Sources */,
|
0668BECCF11E8EE6936CDF16 /* TimelineItemMenuActionProviderTests.swift in Sources */,
|
||||||
|
44B698EFE616E1E7FD34C115 /* TimelineItemsSelectionTests.swift in Sources */,
|
||||||
C02DE5F62C81FB9E173C3D2F /* TimelineMediaPreviewDataSourceTests.swift in Sources */,
|
C02DE5F62C81FB9E173C3D2F /* TimelineMediaPreviewDataSourceTests.swift in Sources */,
|
||||||
F6BF52CB027393EE03CEC523 /* TimelineMediaPreviewViewModelTests.swift in Sources */,
|
F6BF52CB027393EE03CEC523 /* TimelineMediaPreviewViewModelTests.swift in Sources */,
|
||||||
75E55A763FE8BA64FB8513E4 /* TimelineStateTests.swift in Sources */,
|
75E55A763FE8BA64FB8513E4 /* TimelineStateTests.swift in Sources */,
|
||||||
@@ -9585,6 +9592,8 @@
|
|||||||
6386EA3C898AD1A4BC1DC8A5 /* TimelineMediaPreviewModifier.swift in Sources */,
|
6386EA3C898AD1A4BC1DC8A5 /* TimelineMediaPreviewModifier.swift in Sources */,
|
||||||
A32384E3D85CA65342D3A908 /* TimelineMediaPreviewRedactConfirmationView.swift in Sources */,
|
A32384E3D85CA65342D3A908 /* TimelineMediaPreviewRedactConfirmationView.swift in Sources */,
|
||||||
86769B62BAE17601B3AE1B60 /* TimelineMediaPreviewViewModel.swift in Sources */,
|
86769B62BAE17601B3AE1B60 /* TimelineMediaPreviewViewModel.swift in Sources */,
|
||||||
|
05A7A9E3653E018E383C9890 /* TimelineMessageSelectionActionBar.swift in Sources */,
|
||||||
|
BDA14E4B772E28A792D7F5C8 /* TimelineMessageSelectionToolbar.swift in Sources */,
|
||||||
B818580464CFB5400A3EF6AE /* TimelineModels.swift in Sources */,
|
B818580464CFB5400A3EF6AE /* TimelineModels.swift in Sources */,
|
||||||
4E4EF97B9F9CEFAC726BA72F /* TimelineProviderMock.swift in Sources */,
|
4E4EF97B9F9CEFAC726BA72F /* TimelineProviderMock.swift in Sources */,
|
||||||
E82E13CC3EB923CCB8F8273C /* TimelineProxy.swift in Sources */,
|
E82E13CC3EB923CCB8F8273C /* TimelineProxy.swift in Sources */,
|
||||||
@@ -9594,7 +9603,6 @@
|
|||||||
4DAEE2468669848B6C9F55B4 /* TimelineReadReceiptsView.swift in Sources */,
|
4DAEE2468669848B6C9F55B4 /* TimelineReadReceiptsView.swift in Sources */,
|
||||||
6EB46C92ECFEAE71959D91D2 /* TimelineReplyView.swift in Sources */,
|
6EB46C92ECFEAE71959D91D2 /* TimelineReplyView.swift in Sources */,
|
||||||
291A3E0EECD496D0FCC2ADAA /* TimelineScrollButton.swift in Sources */,
|
291A3E0EECD496D0FCC2ADAA /* TimelineScrollButton.swift in Sources */,
|
||||||
FD387E0B8962056D2092DF3F /* TimelineSelectionToolbar.swift in Sources */,
|
|
||||||
9FBE1FB20171012260A32492 /* TimelineSenderAvatarView.swift in Sources */,
|
9FBE1FB20171012260A32492 /* TimelineSenderAvatarView.swift in Sources */,
|
||||||
C4FE0E11A907C8999F92D5A8 /* TimelineStartRoomTimelineItem.swift in Sources */,
|
C4FE0E11A907C8999F92D5A8 /* TimelineStartRoomTimelineItem.swift in Sources */,
|
||||||
785613C0C092B532198EB3BB /* TimelineStartRoomTimelineView.swift in Sources */,
|
785613C0C092B532198EB3BB /* TimelineStartRoomTimelineView.swift in Sources */,
|
||||||
|
|||||||
@@ -174,7 +174,6 @@
|
|||||||
"action_retry_decryption" = "Retry decryption";
|
"action_retry_decryption" = "Retry decryption";
|
||||||
"action_save" = "Save";
|
"action_save" = "Save";
|
||||||
"action_search" = "Search";
|
"action_search" = "Search";
|
||||||
"action_select" = "Select";
|
|
||||||
"action_select_all" = "Select all";
|
"action_select_all" = "Select all";
|
||||||
"action_send" = "Send";
|
"action_send" = "Send";
|
||||||
"action_send_edited_message" = "Send edited message";
|
"action_send_edited_message" = "Send edited message";
|
||||||
|
|||||||
@@ -174,7 +174,6 @@
|
|||||||
"action_retry_decryption" = "Retry decryption";
|
"action_retry_decryption" = "Retry decryption";
|
||||||
"action_save" = "Save";
|
"action_save" = "Save";
|
||||||
"action_search" = "Search";
|
"action_search" = "Search";
|
||||||
"action_select" = "Select";
|
|
||||||
"action_select_all" = "Select all";
|
"action_select_all" = "Select all";
|
||||||
"action_send" = "Send";
|
"action_send" = "Send";
|
||||||
"action_send_edited_message" = "Send edited message";
|
"action_send_edited_message" = "Send edited message";
|
||||||
|
|||||||
@@ -66,6 +66,22 @@
|
|||||||
<key>NSStringLocalizedFormatKey</key>
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
<string>%#@COUNT@</string>
|
<string>%#@COUNT@</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>action_forward_messages</key>
|
||||||
|
<dict>
|
||||||
|
<key>COUNT</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSStringFormatSpecTypeKey</key>
|
||||||
|
<string>NSStringPluralRuleType</string>
|
||||||
|
<key>NSStringFormatValueTypeKey</key>
|
||||||
|
<string>d</string>
|
||||||
|
<key>one</key>
|
||||||
|
<string>Forward %1$d message</string>
|
||||||
|
<key>other</key>
|
||||||
|
<string>Forward %1$d messages</string>
|
||||||
|
</dict>
|
||||||
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
|
<string>%#@COUNT@</string>
|
||||||
|
</dict>
|
||||||
<key>common_gallery_reply_attachments</key>
|
<key>common_gallery_reply_attachments</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>COUNT</key>
|
<key>COUNT</key>
|
||||||
@@ -530,6 +546,22 @@
|
|||||||
<key>NSStringLocalizedFormatKey</key>
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
<string>%#@COUNT@</string>
|
<string>%#@COUNT@</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>screen_room_messages_forwarded</key>
|
||||||
|
<dict>
|
||||||
|
<key>COUNT</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSStringFormatSpecTypeKey</key>
|
||||||
|
<string>NSStringPluralRuleType</string>
|
||||||
|
<key>NSStringFormatValueTypeKey</key>
|
||||||
|
<string>d</string>
|
||||||
|
<key>one</key>
|
||||||
|
<string>%1$d message forwarded</string>
|
||||||
|
<key>other</key>
|
||||||
|
<string>%1$d messages forwarded</string>
|
||||||
|
</dict>
|
||||||
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
|
<string>%#@COUNT@</string>
|
||||||
|
</dict>
|
||||||
<key>screen_room_multiple_knock_requests_title</key>
|
<key>screen_room_multiple_knock_requests_title</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>COUNT</key>
|
<key>COUNT</key>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
"screen_home_tab_search" = "Search";
|
"screen_home_tab_search" = "Search";
|
||||||
"screen_notification_settings_show_all_room_list_activity" = "Show all activity in the room list (dots or number of unread messages)";
|
|
||||||
"screen_search_empty_state_message" = "Search for chats and messages";
|
"screen_search_empty_state_message" = "Search for chats and messages";
|
||||||
"screen_search_empty_state_title" = "Start searching...";
|
"screen_search_empty_state_title" = "Start searching...";
|
||||||
"screen_search_no_results_message" = "There are no results for “%1$@.” Try a new search term.";
|
"screen_search_no_results_message" = "There are no results for “%1$@.” Try a new search term.";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Foundation
|
|||||||
|
|
||||||
enum MediaEventsTimelineFlowCoordinatorAction {
|
enum MediaEventsTimelineFlowCoordinatorAction {
|
||||||
case viewInRoomTimeline(TimelineItemIdentifier)
|
case viewInRoomTimeline(TimelineItemIdentifier)
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
case finished
|
case finished
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
.sink { [weak self] action in
|
.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
case .viewInRoomTimeline(let itemID):
|
case .viewInRoomTimeline(let itemID):
|
||||||
navigationStackCoordinator.pop(animated: false)
|
navigationStackCoordinator.pop(animated: false)
|
||||||
actionsSubject.send(.viewInRoomTimeline(itemID))
|
actionsSubject.send(.viewInRoomTimeline(itemID))
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
case .presentLiveLocationViewer(let sender, let initialLiveLocationShare):
|
case .presentLiveLocationViewer(let sender, let initialLiveLocationShare):
|
||||||
presentMapNavigator(interactionMode: .viewLive(sender: sender, initialLiveLocationShare: initialLiveLocationShare),
|
presentMapNavigator(interactionMode: .viewLive(sender: sender, initialLiveLocationShare: initialLiveLocationShare),
|
||||||
timelineController: timelineController)
|
timelineController: timelineController)
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
presentMessageForwarding(with: forwardingItem)
|
presentMessageForwarding(with: forwardingPayload)
|
||||||
case .displayRoomScreenWithFocussedPin(let eventID, let threadRootEventID):
|
case .displayRoomScreenWithFocussedPin(let eventID, let threadRootEventID):
|
||||||
actionsSubject.send(.displayRoomScreenWithFocussedPin(eventID: eventID, threadRootEventID: threadRootEventID))
|
actionsSubject.send(.displayRoomScreenWithFocussedPin(eventID: eventID, threadRootEventID: threadRootEventID))
|
||||||
}
|
}
|
||||||
@@ -132,12 +132,12 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
navigationStackCoordinator.setSheetCoordinator(stackCoordinator)
|
navigationStackCoordinator.setSheetCoordinator(stackCoordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) {
|
private func presentMessageForwarding(with forwardingPayload: MessageForwardingPayload) {
|
||||||
let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
|
let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
|
||||||
|
|
||||||
let stackCoordinator = NavigationStackCoordinator()
|
let stackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let parameters = MessageForwardingScreenCoordinatorParameters(forwardingItem: forwardingItem,
|
let parameters = MessageForwardingScreenCoordinatorParameters(forwardingPayload: forwardingPayload,
|
||||||
userSession: userSession,
|
userSession: userSession,
|
||||||
roomSummaryProvider: roomSummaryProvider,
|
roomSummaryProvider: roomSummaryProvider,
|
||||||
userIndicatorController: flowParameters.userIndicatorController)
|
userIndicatorController: flowParameters.userIndicatorController)
|
||||||
|
|||||||
@@ -438,8 +438,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
emojiPickerContinuation: continuation,
|
emojiPickerContinuation: continuation,
|
||||||
animated: animated)
|
animated: animated)
|
||||||
|
|
||||||
case (_, .presentMessageForwarding(let forwardingItem), .messageForwarding):
|
case (_, .presentMessageForwarding(let forwardingPayload), .messageForwarding):
|
||||||
presentMessageForwarding(with: forwardingItem)
|
presentMessageForwarding(with: forwardingPayload)
|
||||||
|
|
||||||
case (_, .presentMapNavigator(let mode), .mapNavigator):
|
case (_, .presentMapNavigator(let mode), .mapNavigator):
|
||||||
guard let timelineController = (context.userInfo as? EventUserInfo)?.timelineController else {
|
guard let timelineController = (context.userInfo as? EventUserInfo)?.timelineController else {
|
||||||
@@ -723,8 +723,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
userInfo: EventUserInfo(animated: animated, timelineController: timelineController))
|
userInfo: EventUserInfo(animated: animated, timelineController: timelineController))
|
||||||
case .presentRoomMemberDetails(userID: let userID):
|
case .presentRoomMemberDetails(userID: let userID):
|
||||||
stateMachine.tryEvent(.startMembersFlow(entryPoint: .roomMember(userID: userID)))
|
stateMachine.tryEvent(.startMembersFlow(entryPoint: .roomMember(userID: userID)))
|
||||||
case .presentMessageForwarding(let forwardingItem):
|
case .presentMessageForwarding(let forwardingPayload):
|
||||||
stateMachine.tryEvent(.presentMessageForwarding(forwardingItem: forwardingItem))
|
stateMachine.tryEvent(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .presentCallScreen(let isVoiceCall):
|
case .presentCallScreen(let isVoiceCall):
|
||||||
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy, isVoiceCall: isVoiceCall))
|
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy, isVoiceCall: isVoiceCall))
|
||||||
case .presentPinnedEventsTimeline:
|
case .presentPinnedEventsTimeline:
|
||||||
@@ -835,8 +835,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
userInfo: EventUserInfo(animated: animated, emojiPickerContinuation: continuation))
|
userInfo: EventUserInfo(animated: animated, emojiPickerContinuation: continuation))
|
||||||
case .presentRoomMemberDetails(let userID):
|
case .presentRoomMemberDetails(let userID):
|
||||||
stateMachine.tryEvent(.startMembersFlow(entryPoint: .roomMember(userID: userID)))
|
stateMachine.tryEvent(.startMembersFlow(entryPoint: .roomMember(userID: userID)))
|
||||||
case .presentMessageForwarding(let forwardingItem):
|
case .presentMessageForwarding(let forwardingPayload):
|
||||||
stateMachine.tryEvent(.presentMessageForwarding(forwardingItem: forwardingItem))
|
stateMachine.tryEvent(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .presentResolveSendFailure(let failure, let sendHandle):
|
case .presentResolveSendFailure(let failure, let sendHandle):
|
||||||
stateMachine.tryEvent(.presentResolveSendFailure(failure: failure,
|
stateMachine.tryEvent(.presentResolveSendFailure(failure: failure,
|
||||||
sendHandle: sendHandle))
|
sendHandle: sendHandle))
|
||||||
@@ -1262,12 +1262,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func presentMessageForwarding(with forwardingItem: MessageForwardingItem) {
|
private func presentMessageForwarding(with forwardingPayload: MessageForwardingPayload) {
|
||||||
let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
|
let roomSummaryProvider = userSession.clientProxy.alternateRoomSummaryProvider
|
||||||
|
|
||||||
let stackCoordinator = NavigationStackCoordinator()
|
let stackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let parameters = MessageForwardingScreenCoordinatorParameters(forwardingItem: forwardingItem,
|
let parameters = MessageForwardingScreenCoordinatorParameters(forwardingPayload: forwardingPayload,
|
||||||
userSession: userSession,
|
userSession: userSession,
|
||||||
roomSummaryProvider: roomSummaryProvider,
|
roomSummaryProvider: roomSummaryProvider,
|
||||||
userIndicatorController: flowParameters.userIndicatorController)
|
userIndicatorController: flowParameters.userIndicatorController)
|
||||||
@@ -1281,6 +1281,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||||
case .sent(let roomIDs):
|
case .sent(let roomIDs):
|
||||||
navigationStackCoordinator.setSheetCoordinator(nil)
|
navigationStackCoordinator.setSheetCoordinator(nil)
|
||||||
|
clearMessageSelection()
|
||||||
processPostMessageForwardingTo(rooms: roomIDs)
|
processPostMessageForwardingTo(rooms: roomIDs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1293,6 +1294,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ends the message selection now that the forwarding has completed. Only one timeline can be selecting at a time.
|
||||||
|
private func clearMessageSelection() {
|
||||||
|
roomScreenCoordinator?.clearMessageSelection()
|
||||||
|
childThreadScreenCoordinators.forEach { $0.clearMessageSelection() }
|
||||||
|
}
|
||||||
|
|
||||||
private func presentNotificationSettingsScreen() {
|
private func presentNotificationSettingsScreen() {
|
||||||
let parameters = RoomNotificationSettingsScreenCoordinatorParameters(notificationSettingsProxy: userSession.clientProxy.notificationSettings,
|
let parameters = RoomNotificationSettingsScreenCoordinatorParameters(notificationSettingsProxy: userSession.clientProxy.notificationSettings,
|
||||||
roomProxy: roomProxy,
|
roomProxy: roomProxy,
|
||||||
@@ -1628,8 +1635,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
userInfo: EventUserInfo(animated: false)) // No animation so the timeline visible when the preview animates away.
|
userInfo: EventUserInfo(animated: false)) // No animation so the timeline visible when the preview animates away.
|
||||||
case .finished:
|
case .finished:
|
||||||
stateMachine.tryEvent(.dismissMediaEventsTimeline)
|
stateMachine.tryEvent(.dismissMediaEventsTimeline)
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
stateMachine.tryEvent(.presentMessageForwarding(forwardingItem: forwardingItem))
|
stateMachine.tryEvent(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ extension RoomFlowCoordinator {
|
|||||||
case mediaUploadPreview(mediaURLs: [URL], caption: NSAttributedString?, previousState: State)
|
case mediaUploadPreview(mediaURLs: [URL], caption: NSAttributedString?, previousState: State)
|
||||||
case emojiPicker(selectedEmojis: Set<String>, previousState: State)
|
case emojiPicker(selectedEmojis: Set<String>, previousState: State)
|
||||||
case mapNavigator(previousState: State)
|
case mapNavigator(previousState: State)
|
||||||
case messageForwarding(forwardingItem: MessageForwardingItem, previousState: State)
|
case messageForwarding(forwardingPayload: MessageForwardingPayload, previousState: State)
|
||||||
case reportContent(itemID: TimelineItemIdentifier, senderID: String, previousState: State)
|
case reportContent(itemID: TimelineItemIdentifier, senderID: String, previousState: State)
|
||||||
case pollForm(previousState: State)
|
case pollForm(previousState: State)
|
||||||
case pollsHistory
|
case pollsHistory
|
||||||
@@ -140,7 +140,7 @@ extension RoomFlowCoordinator {
|
|||||||
case presentMapNavigator(interactionMode: LocationSharingInteractionMode)
|
case presentMapNavigator(interactionMode: LocationSharingInteractionMode)
|
||||||
case dismissMapNavigator
|
case dismissMapNavigator
|
||||||
|
|
||||||
case presentMessageForwarding(forwardingItem: MessageForwardingItem)
|
case presentMessageForwarding(forwardingPayload: MessageForwardingPayload)
|
||||||
case dismissMessageForwarding
|
case dismissMessageForwarding
|
||||||
|
|
||||||
case presentPollForm(mode: PollFormMode)
|
case presentPollForm(mode: PollFormMode)
|
||||||
@@ -208,10 +208,10 @@ extension RoomFlowCoordinator {
|
|||||||
case (.room, .presentEmojiPicker(let selectedEmojis)):
|
case (.room, .presentEmojiPicker(let selectedEmojis)):
|
||||||
return .emojiPicker(selectedEmojis: selectedEmojis, previousState: fromState)
|
return .emojiPicker(selectedEmojis: selectedEmojis, previousState: fromState)
|
||||||
|
|
||||||
case (.room, .presentMessageForwarding(let forwardingItem)):
|
case (.room, .presentMessageForwarding(let forwardingPayload)):
|
||||||
return .messageForwarding(forwardingItem: forwardingItem, previousState: fromState)
|
return .messageForwarding(forwardingPayload: forwardingPayload, previousState: fromState)
|
||||||
case (.mediaEventsTimeline, .presentMessageForwarding(forwardingItem: let forwardingItem)):
|
case (.mediaEventsTimeline, .presentMessageForwarding(forwardingPayload: let forwardingPayload)):
|
||||||
return .messageForwarding(forwardingItem: forwardingItem, previousState: fromState)
|
return .messageForwarding(forwardingPayload: forwardingPayload, previousState: fromState)
|
||||||
|
|
||||||
case (.room, .presentMapNavigator):
|
case (.room, .presentMapNavigator):
|
||||||
return .mapNavigator(previousState: fromState)
|
return .mapNavigator(previousState: fromState)
|
||||||
@@ -257,8 +257,8 @@ extension RoomFlowCoordinator {
|
|||||||
case (.thread, .presentEmojiPicker(let selectedEmojis)):
|
case (.thread, .presentEmojiPicker(let selectedEmojis)):
|
||||||
return .emojiPicker(selectedEmojis: selectedEmojis, previousState: fromState)
|
return .emojiPicker(selectedEmojis: selectedEmojis, previousState: fromState)
|
||||||
|
|
||||||
case (.thread, .presentMessageForwarding(let forwardingItem)):
|
case (.thread, .presentMessageForwarding(let forwardingPayload)):
|
||||||
return .messageForwarding(forwardingItem: forwardingItem, previousState: fromState)
|
return .messageForwarding(forwardingPayload: forwardingPayload, previousState: fromState)
|
||||||
|
|
||||||
case (.thread, .presentMapNavigator):
|
case (.thread, .presentMapNavigator):
|
||||||
return .mapNavigator(previousState: fromState)
|
return .mapNavigator(previousState: fromState)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import Foundation
|
|||||||
internal nonisolated enum UntranslatedL10n {
|
internal nonisolated enum UntranslatedL10n {
|
||||||
/// Search
|
/// Search
|
||||||
internal static var screenHomeTabSearch: String { return UntranslatedL10n.tr("Untranslated", "screen_home_tab_search") }
|
internal static var screenHomeTabSearch: String { return UntranslatedL10n.tr("Untranslated", "screen_home_tab_search") }
|
||||||
/// Show all activity in the room list (dots or number of unread messages)
|
|
||||||
internal static var screenNotificationSettingsShowAllRoomListActivity: String { return UntranslatedL10n.tr("Untranslated", "screen_notification_settings_show_all_room_list_activity") }
|
|
||||||
/// Search for chats and messages
|
/// Search for chats and messages
|
||||||
internal static var screenSearchEmptyStateMessage: String { return UntranslatedL10n.tr("Untranslated", "screen_search_empty_state_message") }
|
internal static var screenSearchEmptyStateMessage: String { return UntranslatedL10n.tr("Untranslated", "screen_search_empty_state_message") }
|
||||||
/// Start searching...
|
/// Start searching...
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ internal nonisolated enum L10n {
|
|||||||
internal static var actionForgotPassword: String { return L10n.tr("Localizable", "action_forgot_password") }
|
internal static var actionForgotPassword: String { return L10n.tr("Localizable", "action_forgot_password") }
|
||||||
/// Forward
|
/// Forward
|
||||||
internal static var actionForward: String { return L10n.tr("Localizable", "action_forward") }
|
internal static var actionForward: String { return L10n.tr("Localizable", "action_forward") }
|
||||||
|
/// Plural format key: "%#@COUNT@"
|
||||||
|
internal static func actionForwardMessages(_ p1: Int) -> String {
|
||||||
|
return L10n.tr("Localizable", "action_forward_messages", p1)
|
||||||
|
}
|
||||||
/// Go back
|
/// Go back
|
||||||
internal static var actionGoBack: String { return L10n.tr("Localizable", "action_go_back") }
|
internal static var actionGoBack: String { return L10n.tr("Localizable", "action_go_back") }
|
||||||
/// Go to roles & permissions
|
/// Go to roles & permissions
|
||||||
@@ -398,8 +402,6 @@ internal nonisolated enum L10n {
|
|||||||
internal static var actionSave: String { return L10n.tr("Localizable", "action_save") }
|
internal static var actionSave: String { return L10n.tr("Localizable", "action_save") }
|
||||||
/// Search
|
/// Search
|
||||||
internal static var actionSearch: String { return L10n.tr("Localizable", "action_search") }
|
internal static var actionSearch: String { return L10n.tr("Localizable", "action_search") }
|
||||||
/// Select
|
|
||||||
internal static var actionSelect: String { return L10n.tr("Localizable", "action_select") }
|
|
||||||
/// Select all
|
/// Select all
|
||||||
internal static var actionSelectAll: String { return L10n.tr("Localizable", "action_select_all") }
|
internal static var actionSelectAll: String { return L10n.tr("Localizable", "action_select_all") }
|
||||||
/// Send
|
/// Send
|
||||||
@@ -3175,6 +3177,10 @@ internal nonisolated enum L10n {
|
|||||||
/// Everyone
|
/// Everyone
|
||||||
internal static var screenRoomMentionsAtRoomTitle: String { return L10n.tr("Localizable", "screen_room_mentions_at_room_title") }
|
internal static var screenRoomMentionsAtRoomTitle: String { return L10n.tr("Localizable", "screen_room_mentions_at_room_title") }
|
||||||
/// Plural format key: "%#@COUNT@"
|
/// Plural format key: "%#@COUNT@"
|
||||||
|
internal static func screenRoomMessagesForwarded(_ p1: Int) -> String {
|
||||||
|
return L10n.tr("Localizable", "screen_room_messages_forwarded", p1)
|
||||||
|
}
|
||||||
|
/// Plural format key: "%#@COUNT@"
|
||||||
internal static func screenRoomMultipleKnockRequestsTitle(_ p1: Int) -> String {
|
internal static func screenRoomMultipleKnockRequestsTitle(_ p1: Int) -> String {
|
||||||
return L10n.tr("Localizable", "screen_room_multiple_knock_requests_title", p1)
|
return L10n.tr("Localizable", "screen_room_multiple_knock_requests_title", p1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,20 @@ nonisolated extension Array where Element == RoomTimelineItemProtocol {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The items that can be forwarded, in timeline order.
|
||||||
|
var forwardableItems: [EventBasedTimelineItemProtocol] {
|
||||||
|
compactMap { item in
|
||||||
|
guard let item = item as? EventBasedTimelineItemProtocol, item.isForwardable else { return nil }
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The selected items in timeline order, whatever the order they were selected in.
|
||||||
|
func selectedItems(_ selectedEventIDs: Set<String>) -> [EventBasedTimelineItemProtocol] {
|
||||||
|
forwardableItems.filter { item in
|
||||||
|
guard let eventID = item.id.eventID else { return false }
|
||||||
|
return selectedEventIDs.contains(eventID)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ enum TestablePreviewsDictionary {
|
|||||||
"TimelineItemStyler_Previews" : TimelineItemStyler_Previews.self,
|
"TimelineItemStyler_Previews" : TimelineItemStyler_Previews.self,
|
||||||
"TimelineMediaContentScanningFailureView_Previews" : TimelineMediaContentScanningFailureView_Previews.self,
|
"TimelineMediaContentScanningFailureView_Previews" : TimelineMediaContentScanningFailureView_Previews.self,
|
||||||
"TimelineMediaPreviewRedactConfirmationView_Previews" : TimelineMediaPreviewRedactConfirmationView_Previews.self,
|
"TimelineMediaPreviewRedactConfirmationView_Previews" : TimelineMediaPreviewRedactConfirmationView_Previews.self,
|
||||||
|
"TimelineMessageSelectionActionBar_Previews" : TimelineMessageSelectionActionBar_Previews.self,
|
||||||
"TimelineReactionView_Previews" : TimelineReactionView_Previews.self,
|
"TimelineReactionView_Previews" : TimelineReactionView_Previews.self,
|
||||||
"TimelineReadReceiptsView_Previews" : TimelineReadReceiptsView_Previews.self,
|
"TimelineReadReceiptsView_Previews" : TimelineReadReceiptsView_Previews.self,
|
||||||
"TimelineReplyView_Previews" : TimelineReplyView_Previews.self,
|
"TimelineReplyView_Previews" : TimelineReplyView_Previews.self,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import SwiftUI
|
|||||||
|
|
||||||
enum TimelineMediaPreviewViewModelAction: Equatable {
|
enum TimelineMediaPreviewViewModelAction: Equatable {
|
||||||
case viewInRoomTimeline(TimelineItemIdentifier)
|
case viewInRoomTimeline(TimelineItemIdentifier)
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
case dismiss
|
case dismiss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func forwardItem(itemID: TimelineItemIdentifier) async {
|
private func forwardItem(itemID: TimelineItemIdentifier) async {
|
||||||
guard let forwardingItem = await timelineViewModel.makeForwardingItem(for: itemID) else { return }
|
guard let forwardingPayload = await timelineViewModel.makeForwardingPayload(for: [itemID]) else { return }
|
||||||
state.previewControllerDriver.send(.dismissDetailsSheet)
|
state.previewControllerDriver.send(.dismissDetailsSheet)
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateCurrentItem(_ previewItem: TimelineMediaPreviewItem) async {
|
private func updateCurrentItem(_ previewItem: TimelineMediaPreviewItem) async {
|
||||||
@@ -231,7 +231,6 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
|||||||
pinnedEventIDs: timelineContext.viewState.pinnedEventIDs,
|
pinnedEventIDs: timelineContext.viewState.pinnedEventIDs,
|
||||||
isViewSourceEnabled: timelineContext.viewState.isViewSourceEnabled,
|
isViewSourceEnabled: timelineContext.viewState.isViewSourceEnabled,
|
||||||
areThreadsEnabled: timelineContext.viewState.areThreadsEnabled,
|
areThreadsEnabled: timelineContext.viewState.areThreadsEnabled,
|
||||||
isMultiSelectEnabled: timelineContext.viewState.canSelectMessages,
|
|
||||||
timelineKind: timelineContext.viewState.timelineKind,
|
timelineKind: timelineContext.viewState.timelineKind,
|
||||||
emojiProvider: timelineContext.viewState.emojiProvider)
|
emojiProvider: timelineContext.viewState.emojiProvider)
|
||||||
.makeActions()
|
.makeActions()
|
||||||
|
|||||||
+3
-3
@@ -26,7 +26,7 @@ struct MediaEventsTimelineScreenCoordinatorParameters {
|
|||||||
|
|
||||||
enum MediaEventsTimelineScreenCoordinatorAction {
|
enum MediaEventsTimelineScreenCoordinatorAction {
|
||||||
case viewInRoomTimeline(TimelineItemIdentifier)
|
case viewInRoomTimeline(TimelineItemIdentifier)
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
}
|
}
|
||||||
|
|
||||||
final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||||
@@ -74,8 +74,8 @@ final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
.sink { [weak self] action in
|
.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
case .viewInRoomTimeline(let itemID):
|
case .viewInRoomTimeline(let itemID):
|
||||||
actionsSubject.send(.viewInRoomTimeline(itemID))
|
actionsSubject.send(.viewInRoomTimeline(itemID))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum MediaEventsTimelineScreenViewModelAction {
|
enum MediaEventsTimelineScreenViewModelAction {
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
case viewInRoomTimeline(TimelineItemIdentifier)
|
case viewInRoomTimeline(TimelineItemIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -169,8 +169,8 @@ class MediaEventsTimelineScreenViewModel: MediaEventsTimelineScreenViewModelType
|
|||||||
sheetModel.actions.sink { [weak self] action in
|
sheetModel.actions.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
displayMessageForwarding(forwardingItem: forwardingItem)
|
displayMessageForwarding(forwardingPayload: forwardingPayload)
|
||||||
case .viewInRoomTimeline(let itemID):
|
case .viewInRoomTimeline(let itemID):
|
||||||
actionsSubject.send(.viewInRoomTimeline(itemID))
|
actionsSubject.send(.viewInRoomTimeline(itemID))
|
||||||
case .dismiss:
|
case .dismiss:
|
||||||
@@ -246,8 +246,8 @@ class MediaEventsTimelineScreenViewModel: MediaEventsTimelineScreenViewModelType
|
|||||||
viewModel.actions.sink { [weak self] action in
|
viewModel.actions.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
displayMessageForwarding(forwardingItem: forwardingItem)
|
displayMessageForwarding(forwardingPayload: forwardingPayload)
|
||||||
case .viewInRoomTimeline(let itemID):
|
case .viewInRoomTimeline(let itemID):
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
actionsSubject.send(.viewInRoomTimeline(itemID))
|
actionsSubject.send(.viewInRoomTimeline(itemID))
|
||||||
@@ -268,12 +268,12 @@ class MediaEventsTimelineScreenViewModel: MediaEventsTimelineScreenViewModelType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func displayMessageForwarding(forwardingItem: MessageForwardingItem) {
|
private func displayMessageForwarding(forwardingPayload: MessageForwardingPayload) {
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
state.bindings.mediaPreviewSheetViewModel = nil
|
state.bindings.mediaPreviewSheetViewModel = nil
|
||||||
// We need a small delay because we need to wait for the presented sheet to be fully dismissed.
|
// We need a small delay because we need to wait for the presented sheet to be fully dismissed.
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
||||||
self.actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
self.actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ import Combine
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct MessageForwardingScreenCoordinatorParameters {
|
struct MessageForwardingScreenCoordinatorParameters {
|
||||||
let forwardingItem: MessageForwardingItem
|
let forwardingPayload: MessageForwardingPayload
|
||||||
let userSession: UserSessionProtocol
|
let userSession: UserSessionProtocol
|
||||||
let roomSummaryProvider: RoomSummaryProviderProtocol
|
let roomSummaryProvider: RoomSummaryProviderProtocol
|
||||||
let userIndicatorController: UserIndicatorControllerProtocol
|
let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
@@ -31,7 +31,7 @@ final class MessageForwardingScreenCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init(parameters: MessageForwardingScreenCoordinatorParameters) {
|
init(parameters: MessageForwardingScreenCoordinatorParameters) {
|
||||||
viewModel = MessageForwardingScreenViewModel(forwardingItem: parameters.forwardingItem,
|
viewModel = MessageForwardingScreenViewModel(forwardingPayload: parameters.forwardingPayload,
|
||||||
userSession: parameters.userSession,
|
userSession: parameters.userSession,
|
||||||
roomSummaryProvider: parameters.roomSummaryProvider,
|
roomSummaryProvider: parameters.roomSummaryProvider,
|
||||||
userIndicatorController: parameters.userIndicatorController)
|
userIndicatorController: parameters.userIndicatorController)
|
||||||
|
|||||||
+10
-10
@@ -17,7 +17,7 @@ enum MessageForwardingScreenViewModelAction {
|
|||||||
struct MessageForwardingScreenViewState: BindableState {
|
struct MessageForwardingScreenViewState: BindableState {
|
||||||
var rooms: [MessageForwardingRoom] = []
|
var rooms: [MessageForwardingRoom] = []
|
||||||
var selectedRoomIDs: Set<String> = []
|
var selectedRoomIDs: Set<String> = []
|
||||||
let maxRoomSelectionCount = 10
|
let maxRoomSelectionCount = 5
|
||||||
var bindings = MessageForwardingScreenViewStateBindings()
|
var bindings = MessageForwardingScreenViewStateBindings()
|
||||||
|
|
||||||
var isAtRoomSelectionLimit: Bool {
|
var isAtRoomSelectionLimit: Bool {
|
||||||
@@ -44,20 +44,20 @@ struct MessageForwardingRoom: Identifiable, Equatable {
|
|||||||
let avatar: RoomAvatar
|
let avatar: RoomAvatar
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MessageForwardingItem: Hashable {
|
struct MessageForwardingPayload: Hashable {
|
||||||
/// The source item's timeline ID. Only necessary for a rough Hashable conformance.
|
/// The source items' timeline IDs. Only necessary for a rough Hashable conformance.
|
||||||
let id: TimelineItemIdentifier
|
let ids: [TimelineItemIdentifier]
|
||||||
/// The source item's room ID.
|
/// The source items' room ID.
|
||||||
let roomID: String
|
let roomID: String
|
||||||
/// The item's content to be forwarded.
|
/// The contents to be forwarded, in timeline order.
|
||||||
let content: RoomMessageEventContentWithoutRelation
|
let contents: [RoomMessageEventContentWithoutRelation]
|
||||||
|
|
||||||
static func == (lhs: MessageForwardingItem, rhs: MessageForwardingItem) -> Bool {
|
static func == (lhs: MessageForwardingPayload, rhs: MessageForwardingPayload) -> Bool {
|
||||||
lhs.id == rhs.id && lhs.roomID == rhs.roomID
|
lhs.ids == rhs.ids && lhs.roomID == rhs.roomID
|
||||||
}
|
}
|
||||||
|
|
||||||
func hash(into hasher: inout Hasher) {
|
func hash(into hasher: inout Hasher) {
|
||||||
hasher.combine(id)
|
hasher.combine(ids)
|
||||||
hasher.combine(roomID)
|
hasher.combine(roomID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-9
@@ -12,7 +12,7 @@ import SwiftUI
|
|||||||
typealias MessageForwardingScreenViewModelType = StateStoreViewModel<MessageForwardingScreenViewState, MessageForwardingScreenViewAction>
|
typealias MessageForwardingScreenViewModelType = StateStoreViewModel<MessageForwardingScreenViewState, MessageForwardingScreenViewAction>
|
||||||
|
|
||||||
class MessageForwardingScreenViewModel: MessageForwardingScreenViewModelType, MessageForwardingScreenViewModelProtocol {
|
class MessageForwardingScreenViewModel: MessageForwardingScreenViewModelType, MessageForwardingScreenViewModelProtocol {
|
||||||
private let forwardingItem: MessageForwardingItem
|
private let forwardingPayload: MessageForwardingPayload
|
||||||
private let clientProxy: ClientProxyProtocol
|
private let clientProxy: ClientProxyProtocol
|
||||||
private let roomSummaryProvider: RoomSummaryProviderProtocol
|
private let roomSummaryProvider: RoomSummaryProviderProtocol
|
||||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
@@ -23,11 +23,11 @@ class MessageForwardingScreenViewModel: MessageForwardingScreenViewModelType, Me
|
|||||||
actionsSubject.eraseToAnyPublisher()
|
actionsSubject.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
init(forwardingItem: MessageForwardingItem,
|
init(forwardingPayload: MessageForwardingPayload,
|
||||||
userSession: UserSessionProtocol,
|
userSession: UserSessionProtocol,
|
||||||
roomSummaryProvider: RoomSummaryProviderProtocol,
|
roomSummaryProvider: RoomSummaryProviderProtocol,
|
||||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||||
self.forwardingItem = forwardingItem
|
self.forwardingPayload = forwardingPayload
|
||||||
clientProxy = userSession.clientProxy
|
clientProxy = userSession.clientProxy
|
||||||
self.roomSummaryProvider = roomSummaryProvider
|
self.roomSummaryProvider = roomSummaryProvider
|
||||||
self.userIndicatorController = userIndicatorController
|
self.userIndicatorController = userIndicatorController
|
||||||
@@ -86,7 +86,7 @@ class MessageForwardingScreenViewModel: MessageForwardingScreenViewModelType, Me
|
|||||||
var rooms = [MessageForwardingRoom]()
|
var rooms = [MessageForwardingRoom]()
|
||||||
|
|
||||||
for summary in roomSummaryProvider.roomListPublisher.value {
|
for summary in roomSummaryProvider.roomListPublisher.value {
|
||||||
if summary.id == forwardingItem.roomID {
|
if summary.id == forwardingPayload.roomID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,23 +123,33 @@ class MessageForwardingScreenViewModel: MessageForwardingScreenViewModelType, Me
|
|||||||
}
|
}
|
||||||
|
|
||||||
var succeededRoomIdentifiers = [String]()
|
var succeededRoomIdentifiers = [String]()
|
||||||
|
var hasFailures = false
|
||||||
|
|
||||||
for roomID in state.selectedRoomIDs {
|
for roomID in state.selectedRoomIDs {
|
||||||
guard case let .joined(targetRoomProxy) = await clientProxy.roomForIdentifier(roomID) else {
|
guard case let .joined(targetRoomProxy) = await clientProxy.roomForIdentifier(roomID) else {
|
||||||
MXLog.error("Failed retrieving room to forward to with id: \(roomID)")
|
MXLog.error("Failed retrieving room to forward to with id: \(roomID)")
|
||||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.errorUnknown))
|
hasFailures = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if case .failure(let error) = await targetRoomProxy.timeline.sendMessageEventContent(forwardingItem.content) {
|
// The contents are already in timeline order and the send queue preserves it.
|
||||||
MXLog.error("Failed forwarding message with error: \(error)")
|
for content in forwardingPayload.contents {
|
||||||
userIndicatorController.submitIndicator(UserIndicator(title: L10n.errorUnknown))
|
if case .failure(let error) = await targetRoomProxy.timeline.sendMessageEventContent(content) {
|
||||||
continue
|
MXLog.error("Failed forwarding message with error: \(error)")
|
||||||
|
hasFailures = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
succeededRoomIdentifiers.append(roomID)
|
succeededRoomIdentifiers.append(roomID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hasFailures {
|
||||||
|
userIndicatorController.submitIndicator(UserIndicator(title: L10n.errorUnknown))
|
||||||
|
} else if succeededRoomIdentifiers.count > 1 {
|
||||||
|
// The flow opens the room when there is a single one, otherwise the user stays here and needs to know it worked.
|
||||||
|
userIndicatorController.submitIndicator(UserIndicator(title: L10n.screenRoomMessagesForwarded(forwardingPayload.contents.count)))
|
||||||
|
}
|
||||||
|
|
||||||
if !succeededRoomIdentifiers.isEmpty {
|
if !succeededRoomIdentifiers.isEmpty {
|
||||||
actionsSubject.send(.sent(roomIDs: succeededRoomIdentifiers))
|
actionsSubject.send(.sent(roomIDs: succeededRoomIdentifiers))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ private struct MessageForwardingListRow: View {
|
|||||||
struct MessageForwardingScreen_Previews: PreviewProvider, TestablePreview {
|
struct MessageForwardingScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
let summaryProvider = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
let summaryProvider = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||||
let viewModel = MessageForwardingScreenViewModel(forwardingItem: .init(id: .randomEvent,
|
let viewModel = MessageForwardingScreenViewModel(forwardingPayload: .init(ids: [.randomEvent],
|
||||||
roomID: "",
|
roomID: "",
|
||||||
content: RoomMessageEventContentWithoutRelationSDKMock()),
|
contents: [RoomMessageEventContentWithoutRelationSDKMock()]),
|
||||||
userSession: UserSessionMock(.init()),
|
userSession: UserSessionMock(.init()),
|
||||||
roomSummaryProvider: summaryProvider,
|
roomSummaryProvider: summaryProvider,
|
||||||
userIndicatorController: UserIndicatorControllerMock())
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
|
|||||||
+5
-5
@@ -28,7 +28,7 @@ enum PinnedEventsTimelineScreenCoordinatorAction {
|
|||||||
case displayUser(userID: String)
|
case displayUser(userID: String)
|
||||||
case presentLocationViewer(StaticLocationData)
|
case presentLocationViewer(StaticLocationData)
|
||||||
case presentLiveLocationViewer(sender: TimelineItemSender, initialLiveLocationShare: LiveLocationShare)
|
case presentLiveLocationViewer(sender: TimelineItemSender, initialLiveLocationShare: LiveLocationShare)
|
||||||
case displayMessageForwarding(forwardingItem: MessageForwardingItem)
|
case displayMessageForwarding(forwardingPayload: MessageForwardingPayload)
|
||||||
case displayRoomScreenWithFocussedPin(eventID: String, threadRootEventID: String?)
|
case displayRoomScreenWithFocussedPin(eventID: String, threadRootEventID: String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .viewInRoomTimeline(let eventID, let threadRootEventID):
|
case .viewInRoomTimeline(let eventID, let threadRootEventID):
|
||||||
actionsSubject.send(.displayRoomScreenWithFocussedPin(eventID: eventID, threadRootEventID: threadRootEventID))
|
actionsSubject.send(.displayRoomScreenWithFocussedPin(eventID: eventID, threadRootEventID: threadRootEventID))
|
||||||
case .dismiss:
|
case .dismiss:
|
||||||
@@ -84,8 +84,8 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
switch action {
|
switch action {
|
||||||
case .displaySenderDetails(let userID):
|
case .displaySenderDetails(let userID):
|
||||||
actionsSubject.send(.displayUser(userID: userID))
|
actionsSubject.send(.displayUser(userID: userID))
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .displayMediaPreview(let mediaPreviewViewModel):
|
case .displayMediaPreview(let mediaPreviewViewModel):
|
||||||
viewModel.displayMediaPreview(mediaPreviewViewModel)
|
viewModel.displayMediaPreview(mediaPreviewViewModel)
|
||||||
case .displayLocation(let location):
|
case .displayLocation(let location):
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
enum PinnedEventsTimelineScreenViewModelAction {
|
enum PinnedEventsTimelineScreenViewModelAction {
|
||||||
case viewInRoomTimeline(eventID: String, threadRootEventID: String?)
|
case viewInRoomTimeline(eventID: String, threadRootEventID: String?)
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
case dismiss
|
case dismiss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -54,11 +54,11 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy
|
|||||||
mediaPreviewViewModel.actions.sink { [weak self] action in
|
mediaPreviewViewModel.actions.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
||||||
self.actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
self.actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
}
|
}
|
||||||
case .viewInRoomTimeline(let itemID):
|
case .viewInRoomTimeline(let itemID):
|
||||||
guard let eventID = itemID.eventID else {
|
guard let eventID = itemID.eventID else {
|
||||||
|
|||||||
+52
-20
@@ -13,6 +13,10 @@ struct PinnedEventsTimelineScreen: View {
|
|||||||
@ObservedObject var context: PinnedEventsTimelineScreenViewModel.Context
|
@ObservedObject var context: PinnedEventsTimelineScreenViewModel.Context
|
||||||
@ObservedObject var timelineContext: TimelineViewModel.Context
|
@ObservedObject var timelineContext: TimelineViewModel.Context
|
||||||
|
|
||||||
|
private var isMessageSelectionActive: Bool {
|
||||||
|
timelineContext.viewState.messageSelection.isActive
|
||||||
|
}
|
||||||
|
|
||||||
private var title: String {
|
private var title: String {
|
||||||
let pinnedEventIDs = timelineContext.viewState.pinnedEventIDs
|
let pinnedEventIDs = timelineContext.viewState.pinnedEventIDs
|
||||||
guard !pinnedEventIDs.isEmpty else {
|
guard !pinnedEventIDs.isEmpty else {
|
||||||
@@ -26,6 +30,11 @@ struct PinnedEventsTimelineScreen: View {
|
|||||||
.navigationTitle(title)
|
.navigationTitle(title)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar { toolbar }
|
.toolbar { toolbar }
|
||||||
|
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||||
|
if isMessageSelectionActive {
|
||||||
|
TimelineMessageSelectionActionBar(context: timelineContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
.background(.compound.bgCanvasDefault)
|
.background(.compound.bgCanvasDefault)
|
||||||
.interactiveDismissDisabled()
|
.interactiveDismissDisabled()
|
||||||
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
|
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
|
||||||
@@ -55,9 +64,15 @@ struct PinnedEventsTimelineScreen: View {
|
|||||||
|
|
||||||
@ToolbarContentBuilder
|
@ToolbarContentBuilder
|
||||||
private var toolbar: some ToolbarContent {
|
private var toolbar: some ToolbarContent {
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
if isMessageSelectionActive {
|
||||||
Button(L10n.actionClose) {
|
TimelineMessageSelectionToolbar {
|
||||||
context.send(viewAction: .close)
|
timelineContext.send(viewAction: .clearMessageSelection)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ToolbarItem(placement: .confirmationAction) {
|
||||||
|
Button(L10n.actionClose) {
|
||||||
|
context.send(viewAction: .close)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,28 +86,45 @@ struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
appSettings: .volatile(),
|
appSettings: .volatile(),
|
||||||
analyticsService: AnalyticsServiceMock(.init()))
|
analyticsService: AnalyticsServiceMock(.init()))
|
||||||
|
|
||||||
static let emptyTimelineViewModel: TimelineViewModel = {
|
static let emptyTimelineViewModel = makeTimelineViewModel(timelineItems: [])
|
||||||
let timelineController = TimelineControllerMock(.init(timelineKind: .pinned, timelineItems: []))
|
static let selectingTimelineViewModel = makeTimelineViewModel(timelineItems: TimelineFixtures.default, isSelecting: true)
|
||||||
|
|
||||||
let appSettings = AppSettings.volatile()
|
|
||||||
|
|
||||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")),
|
|
||||||
timelineController: timelineController,
|
|
||||||
userSession: UserSessionMock(.init()),
|
|
||||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
|
||||||
userIndicatorController: UserIndicatorControllerMock(),
|
|
||||||
appMediator: AppMediatorMock(.init()),
|
|
||||||
appSettings: appSettings,
|
|
||||||
analyticsService: AnalyticsServiceMock(.init()),
|
|
||||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
|
||||||
linkMetadataProvider: LinkMetadataProvider(),
|
|
||||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
|
||||||
}()
|
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ElementNavigationStack {
|
ElementNavigationStack {
|
||||||
PinnedEventsTimelineScreen(context: viewModel.context, timelineContext: emptyTimelineViewModel.context)
|
PinnedEventsTimelineScreen(context: viewModel.context, timelineContext: emptyTimelineViewModel.context)
|
||||||
}
|
}
|
||||||
.previewDisplayName("Empty")
|
.previewDisplayName("Empty")
|
||||||
|
|
||||||
|
ElementNavigationStack {
|
||||||
|
PinnedEventsTimelineScreen(context: viewModel.context, timelineContext: selectingTimelineViewModel.context)
|
||||||
|
}
|
||||||
|
.previewDisplayName("Selecting")
|
||||||
|
.snapshotPreferences(expect: selectingTimelineViewModel.context.$viewState.map(\.messageSelection.isActive))
|
||||||
|
}
|
||||||
|
|
||||||
|
static func makeTimelineViewModel(timelineItems: [RoomTimelineItemProtocol], isSelecting: Bool = false) -> TimelineViewModel {
|
||||||
|
let eventIDs = timelineItems.compactMap { ($0 as? EventBasedTimelineItemProtocol)?.id.eventID }
|
||||||
|
let timelineController = TimelineControllerMock(.init(timelineKind: .pinned, timelineItems: timelineItems))
|
||||||
|
|
||||||
|
let appSettings = AppSettings.volatile()
|
||||||
|
appSettings.messageMultiSelectEnabled = isSelecting
|
||||||
|
|
||||||
|
let timelineViewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room", pinnedEventIDs: Set(eventIDs))),
|
||||||
|
timelineController: timelineController,
|
||||||
|
userSession: UserSessionMock(.init()),
|
||||||
|
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||||
|
userIndicatorController: UserIndicatorControllerMock(),
|
||||||
|
appMediator: AppMediatorMock(.init()),
|
||||||
|
appSettings: appSettings,
|
||||||
|
analyticsService: AnalyticsServiceMock(.init()),
|
||||||
|
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||||
|
linkMetadataProvider: LinkMetadataProvider(),
|
||||||
|
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||||
|
|
||||||
|
if isSelecting {
|
||||||
|
timelineViewModel.state.messageSelection.selectedEventIDs = Set(eventIDs.prefix(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
return timelineViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ enum RoomScreenCoordinatorAction {
|
|||||||
case presentLiveLocationViewer(sender: TimelineItemSender?, initialLiveLocationShare: LiveLocationShare?)
|
case presentLiveLocationViewer(sender: TimelineItemSender?, initialLiveLocationShare: LiveLocationShare?)
|
||||||
case presentEmojiPicker(selectedEmojis: Set<String>, continuation: EmojiPickerScreenContinuation)
|
case presentEmojiPicker(selectedEmojis: Set<String>, continuation: EmojiPickerScreenContinuation)
|
||||||
case presentRoomMemberDetails(userID: String)
|
case presentRoomMemberDetails(userID: String)
|
||||||
case presentMessageForwarding(forwardingItem: MessageForwardingItem)
|
case presentMessageForwarding(forwardingPayload: MessageForwardingPayload)
|
||||||
case presentCallScreen(isVoiceCall: Bool)
|
case presentCallScreen(isVoiceCall: Bool)
|
||||||
case presentPinnedEventsTimeline
|
case presentPinnedEventsTimeline
|
||||||
case presentResolveSendFailure(failure: TimelineItemSendFailure.VerifiedUser, sendHandle: SendHandleProxy)
|
case presentResolveSendFailure(failure: TimelineItemSendFailure.VerifiedUser, sendHandle: SendHandleProxy)
|
||||||
@@ -146,8 +146,8 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
|||||||
caption: composerViewModel.context.plainComposerText))
|
caption: composerViewModel.context.plainComposerText))
|
||||||
case .displaySenderDetails(userID: let userID):
|
case .displaySenderDetails(userID: let userID):
|
||||||
actionsSubject.send(.presentRoomMemberDetails(userID: userID))
|
actionsSubject.send(.presentRoomMemberDetails(userID: userID))
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.presentMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .displayLocation(let location):
|
case .displayLocation(let location):
|
||||||
actionsSubject.send(.presentLocationViewer(location))
|
actionsSubject.send(.presentLocationViewer(location))
|
||||||
case .displayLiveLocation(let sender, let initialLiveLocationShare):
|
case .displayLiveLocation(let sender, let initialLiveLocationShare):
|
||||||
@@ -200,8 +200,8 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
|||||||
actionsSubject.send(.presentKnockRequestsList)
|
actionsSubject.send(.presentKnockRequestsList)
|
||||||
case .displayRoom(let roomID, let via):
|
case .displayRoom(let roomID, let via):
|
||||||
actionsSubject.send(.presentRoom(roomID: roomID, via: via))
|
actionsSubject.send(.presentRoom(roomID: roomID, via: via))
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.presentMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .displayThreadList:
|
case .displayThreadList:
|
||||||
actionsSubject.send(.presentThreadList)
|
actionsSubject.send(.presentThreadList)
|
||||||
case .displayThread(let threadRootEventID, let focussedEventID):
|
case .displayThread(let threadRootEventID, let focussedEventID):
|
||||||
@@ -238,6 +238,10 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
|||||||
composerViewModel.process(timelineAction: .setFocus)
|
composerViewModel.process(timelineAction: .setFocus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearMessageSelection() {
|
||||||
|
timelineViewModel.clearMessageSelection()
|
||||||
|
}
|
||||||
|
|
||||||
func stop() {
|
func stop() {
|
||||||
composerViewModel.stop()
|
composerViewModel.stop()
|
||||||
roomViewModel.stop()
|
roomViewModel.stop()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ enum RoomScreenViewModelAction: Equatable {
|
|||||||
case removeComposerFocus
|
case removeComposerFocus
|
||||||
case displayKnockRequests
|
case displayKnockRequests
|
||||||
case displayRoom(roomID: String, via: [String])
|
case displayRoom(roomID: String, via: [String])
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
case stopLiveLocationSharing
|
case stopLiveLocationSharing
|
||||||
case displayLiveLocation
|
case displayLiveLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,11 +149,11 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
switch action {
|
switch action {
|
||||||
case .dismiss:
|
case .dismiss:
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
||||||
self.actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
self.actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
}
|
}
|
||||||
case .viewInRoomTimeline:
|
case .viewInRoomTimeline:
|
||||||
fatalError("\(action) should not be visible on a room preview.")
|
fatalError("\(action) should not be visible on a room preview.")
|
||||||
|
|||||||
@@ -110,10 +110,14 @@ struct RoomScreen: View {
|
|||||||
.environment(\.timelineContext, timelineContext)
|
.environment(\.timelineContext, timelineContext)
|
||||||
// Make sure the reply header honours the hideTimelineMedia setting too.
|
// Make sure the reply header honours the hideTimelineMedia setting too.
|
||||||
.environment(\.shouldAutomaticallyLoadImages, !timelineContext.viewState.hideTimelineMedia)
|
.environment(\.shouldAutomaticallyLoadImages, !timelineContext.viewState.hideTimelineMedia)
|
||||||
.collapsedInPlace(isSelectionActive)
|
.collapsedInPlace(isMessageSelectionActive)
|
||||||
|
|
||||||
|
if isMessageSelectionActive {
|
||||||
|
TimelineMessageSelectionActionBar(context: timelineContext)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationBarBackButtonHidden(isSelectionActive)
|
.navigationBarBackButtonHidden(isMessageSelectionActive)
|
||||||
.toolbarRole(RoomHeaderView.toolbarRole)
|
.toolbarRole(RoomHeaderView.toolbarRole)
|
||||||
.navigationTitle(L10n.screenRoomTitle) // Hidden but used for back button text.
|
.navigationTitle(L10n.screenRoomTitle) // Hidden but used for back button text.
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
@@ -287,23 +291,12 @@ struct RoomScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isSelectionActive: Bool {
|
private var isMessageSelectionActive: Bool {
|
||||||
timelineContext.viewState.selection.isActive
|
timelineContext.viewState.messageSelection.isActive
|
||||||
}
|
}
|
||||||
|
|
||||||
@ToolbarContentBuilder
|
@ToolbarContentBuilder
|
||||||
private var toolbar: some ToolbarContent {
|
private var toolbar: some ToolbarContent {
|
||||||
if isSelectionActive {
|
|
||||||
TimelineSelectionToolbar(count: timelineContext.viewState.selection.count) {
|
|
||||||
timelineContext.send(viewAction: .clearSelection)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
roomToolbar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ToolbarContentBuilder
|
|
||||||
private var roomToolbar: some ToolbarContent {
|
|
||||||
// .principal + .primaryAction works better than .navigation leading + trailing
|
// .principal + .primaryAction works better than .navigation leading + trailing
|
||||||
// as the latter disables interaction in the action button for rooms with long names
|
// as the latter disables interaction in the action button for rooms with long names
|
||||||
ToolbarItem(placement: .principal) {
|
ToolbarItem(placement: .principal) {
|
||||||
@@ -314,8 +307,20 @@ struct RoomScreen: View {
|
|||||||
mediaProvider: context.mediaProvider) {
|
mediaProvider: context.mediaProvider) {
|
||||||
context.send(viewAction: .displayRoomDetails)
|
context.send(viewAction: .displayRoomDetails)
|
||||||
}
|
}
|
||||||
|
.disabled(isMessageSelectionActive) // The room details would cover the selection.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isMessageSelectionActive {
|
||||||
|
TimelineMessageSelectionToolbar {
|
||||||
|
timelineContext.send(viewAction: .clearMessageSelection)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
roomActions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ToolbarContentBuilder
|
||||||
|
private var roomActions: some ToolbarContent {
|
||||||
if !ProcessInfo.processInfo.isiOSAppOnMac || context.viewState.isNativeCallingEnabled {
|
if !ProcessInfo.processInfo.isiOSAppOnMac || context.viewState.isNativeCallingEnabled {
|
||||||
if context.viewState.shouldShowCallButton {
|
if context.viewState.shouldShowCallButton {
|
||||||
RoomCallControlsToolbar(viewState: context.viewState) { isVoiceCall in
|
RoomCallControlsToolbar(viewState: context.viewState) { isVoiceCall in
|
||||||
@@ -379,7 +384,7 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
composerToolbar: ComposerToolbar(context: composerViewModel.context))
|
composerToolbar: ComposerToolbar(context: composerViewModel.context))
|
||||||
}
|
}
|
||||||
.previewDisplayName("Selecting")
|
.previewDisplayName("Selecting")
|
||||||
.snapshotPreferences(expect: selectingViewModels.timeline.context.$viewState.map(\.selection.isActive))
|
.snapshotPreferences(expect: selectingViewModels.timeline.context.$viewState.map(\.messageSelection.isActive))
|
||||||
}
|
}
|
||||||
|
|
||||||
static func makeViewModels(canSendMessage: Bool = true, hasSuccessor: Bool = false, isSelecting: Bool = false) -> ViewModels {
|
static func makeViewModels(canSendMessage: Bool = true, hasSuccessor: Bool = false, isSelecting: Bool = false) -> ViewModels {
|
||||||
@@ -408,7 +413,7 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
|
|
||||||
if isSelecting {
|
if isSelecting {
|
||||||
let eventIDs = timelineController.timelineItems.compactMap { ($0 as? EventBasedTimelineItemProtocol)?.id.eventID }
|
let eventIDs = timelineController.timelineItems.compactMap { ($0 as? EventBasedTimelineItemProtocol)?.id.eventID }
|
||||||
timelineViewModel.state.selection.selectedEventIDs = Set(eventIDs.prefix(2))
|
timelineViewModel.state.messageSelection.selectedEventIDs = Set(eventIDs.prefix(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
return .init(room: roomViewModel, timeline: timelineViewModel)
|
return .init(room: roomViewModel, timeline: timelineViewModel)
|
||||||
|
|||||||
+1
-1
@@ -88,7 +88,7 @@ struct DeveloperOptionsScreen: View {
|
|||||||
|
|
||||||
Toggle(isOn: $context.messageMultiSelectEnabled) {
|
Toggle(isOn: $context.messageMultiSelectEnabled) {
|
||||||
Text("Multi-select messages")
|
Text("Multi-select messages")
|
||||||
Text("Adds a Select action to the message menu to pick several messages at once.")
|
Text("Forward starts a selection so several messages can be forwarded at once.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ enum ThreadTimelineScreenCoordinatorAction {
|
|||||||
case presentPollForm(mode: PollFormMode)
|
case presentPollForm(mode: PollFormMode)
|
||||||
case presentEmojiPicker(selectedEmojis: Set<String>, continuation: EmojiPickerScreenContinuation)
|
case presentEmojiPicker(selectedEmojis: Set<String>, continuation: EmojiPickerScreenContinuation)
|
||||||
case presentRoomMemberDetails(userID: String)
|
case presentRoomMemberDetails(userID: String)
|
||||||
case presentMessageForwarding(forwardingItem: MessageForwardingItem)
|
case presentMessageForwarding(forwardingPayload: MessageForwardingPayload)
|
||||||
case presentResolveSendFailure(failure: TimelineItemSendFailure.VerifiedUser, sendHandle: SendHandleProxy)
|
case presentResolveSendFailure(failure: TimelineItemSendFailure.VerifiedUser, sendHandle: SendHandleProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
.sink { [weak self] action in
|
.sink { [weak self] action in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
switch action {
|
switch action {
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.presentMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
@@ -135,8 +135,8 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
caption: composerViewModel.context.plainComposerText))
|
caption: composerViewModel.context.plainComposerText))
|
||||||
case .displaySenderDetails(userID: let userID):
|
case .displaySenderDetails(userID: let userID):
|
||||||
actionsSubject.send(.presentRoomMemberDetails(userID: userID))
|
actionsSubject.send(.presentRoomMemberDetails(userID: userID))
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
actionsSubject.send(.presentMessageForwarding(forwardingItem: forwardingItem))
|
actionsSubject.send(.presentMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
case .displayResolveSendFailure(let failure, let sendHandle):
|
case .displayResolveSendFailure(let failure, let sendHandle):
|
||||||
actionsSubject.send(.presentResolveSendFailure(failure: failure,
|
actionsSubject.send(.presentResolveSendFailure(failure: failure,
|
||||||
sendHandle: sendHandle))
|
sendHandle: sendHandle))
|
||||||
@@ -179,4 +179,8 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
|||||||
func focusOnEvent(eventID: String) {
|
func focusOnEvent(eventID: String) {
|
||||||
Task { await timelineViewModel.focusOnEvent(eventID: eventID) }
|
Task { await timelineViewModel.focusOnEvent(eventID: eventID) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearMessageSelection() {
|
||||||
|
timelineViewModel.clearMessageSelection()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum ThreadTimelineScreenViewModelAction {
|
enum ThreadTimelineScreenViewModelAction {
|
||||||
case displayMessageForwarding(MessageForwardingItem)
|
case displayMessageForwarding(MessageForwardingPayload)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ThreadTimelineScreenViewState: BindableState {
|
struct ThreadTimelineScreenViewState: BindableState {
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ class ThreadTimelineScreenViewModel: ThreadTimelineScreenViewModelType, ThreadTi
|
|||||||
switch action {
|
switch action {
|
||||||
case .viewInRoomTimeline:
|
case .viewInRoomTimeline:
|
||||||
fatalError("\(action) should not be visible on a thread preview.")
|
fatalError("\(action) should not be visible on a thread preview.")
|
||||||
case .displayMessageForwarding(let forwardingItem):
|
case .displayMessageForwarding(let forwardingPayload):
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
// We need a small delay because we need to wait for the media preview to be fully dismissed.
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + TimelineMediaPreviewViewModel.displayMessageForwardingDelay) {
|
||||||
self.actionsSubject.send(.displayMessageForwarding(forwardingItem))
|
self.actionsSubject.send(.displayMessageForwarding(forwardingPayload))
|
||||||
}
|
}
|
||||||
case .dismiss:
|
case .dismiss:
|
||||||
state.bindings.mediaPreviewViewModel = nil
|
state.bindings.mediaPreviewViewModel = nil
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ struct ThreadTimelineScreen: View {
|
|||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar { toolbar }
|
.toolbar { toolbar }
|
||||||
.toolbarBackground(.visible, for: .navigationBar) // Fix the toolbar's background.
|
.toolbarBackground(.visible, for: .navigationBar) // Fix the toolbar's background.
|
||||||
.navigationBarBackButtonHidden(isSelectionActive)
|
.navigationBarBackButtonHidden(isMessageSelectionActive)
|
||||||
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
|
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
|
||||||
.overlay(alignment: .top) {
|
.overlay(alignment: .top) {
|
||||||
FloatingDateBadge(dateText: timelineContext.floatingDate?.formattedDateSeparator()) {
|
FloatingDateBadge(dateText: timelineContext.floatingDate?.formattedDateSeparator()) {
|
||||||
@@ -44,19 +44,25 @@ struct ThreadTimelineScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.safeAreaInset(edge: .bottom, spacing: 0) {
|
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||||
composer
|
VStack(spacing: 0) {
|
||||||
.padding(.top, 8)
|
composer
|
||||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
.padding(.top, 8)
|
||||||
.environmentObject(timelineContext)
|
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||||
.environment(\.timelineContext, timelineContext)
|
.environmentObject(timelineContext)
|
||||||
// Make sure the reply header honours the hideTimelineMedia setting too.
|
.environment(\.timelineContext, timelineContext)
|
||||||
.environment(\.shouldAutomaticallyLoadImages, !timelineContext.viewState.hideTimelineMedia)
|
// Make sure the reply header honours the hideTimelineMedia setting too.
|
||||||
.collapsedInPlace(isSelectionActive)
|
.environment(\.shouldAutomaticallyLoadImages, !timelineContext.viewState.hideTimelineMedia)
|
||||||
|
.collapsedInPlace(isMessageSelectionActive)
|
||||||
|
|
||||||
|
if isMessageSelectionActive {
|
||||||
|
TimelineMessageSelectionActionBar(context: timelineContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isSelectionActive: Bool {
|
private var isMessageSelectionActive: Bool {
|
||||||
timelineContext.viewState.selection.isActive
|
timelineContext.viewState.messageSelection.isActive
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@@ -70,22 +76,22 @@ struct ThreadTimelineScreen: View {
|
|||||||
|
|
||||||
@ToolbarContentBuilder
|
@ToolbarContentBuilder
|
||||||
private var toolbar: some ToolbarContent {
|
private var toolbar: some ToolbarContent {
|
||||||
if isSelectionActive {
|
// .principal + .primaryAction works better than .navigation leading + trailing
|
||||||
TimelineSelectionToolbar(count: timelineContext.viewState.selection.count) {
|
// as the latter disables interaction in the action button for rooms with long names
|
||||||
timelineContext.send(viewAction: .clearSelection)
|
ToolbarItem(placement: .principal) {
|
||||||
|
RoomHeaderView(roomName: L10n.commonThread,
|
||||||
|
roomSubtitle: context.viewState.roomTitle,
|
||||||
|
roomAvatar: context.viewState.roomAvatar,
|
||||||
|
dmRecipientDetails: context.viewState.dmRecipientDetails,
|
||||||
|
roomHistorySharingState: context.viewState.roomHistorySharingState,
|
||||||
|
mediaProvider: context.mediaProvider) {
|
||||||
|
// There is no action but the iOS 26 designs have it looking like a button.
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
// .principal + .primaryAction works better than .navigation leading + trailing
|
|
||||||
// as the latter disables interaction in the action button for rooms with long names
|
if isMessageSelectionActive {
|
||||||
ToolbarItem(placement: .principal) {
|
TimelineMessageSelectionToolbar {
|
||||||
RoomHeaderView(roomName: L10n.commonThread,
|
timelineContext.send(viewAction: .clearMessageSelection)
|
||||||
roomSubtitle: context.viewState.roomTitle,
|
|
||||||
roomAvatar: context.viewState.roomAvatar,
|
|
||||||
dmRecipientDetails: context.viewState.dmRecipientDetails,
|
|
||||||
roomHistorySharingState: context.viewState.roomHistorySharingState,
|
|
||||||
mediaProvider: context.mediaProvider) {
|
|
||||||
// There is no action but the iOS 26 designs have it looking like a button.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,8 +224,8 @@ class TimelineInteractionHandler {
|
|||||||
analyticsService.trackInteraction(name: .PinnedMessageListViewTimeline)
|
analyticsService.trackInteraction(name: .PinnedMessageListViewTimeline)
|
||||||
guard let eventID = itemID.eventID else { return }
|
guard let eventID = itemID.eventID else { return }
|
||||||
actionsSubject.send(.viewInRoomTimeline(eventID: eventID))
|
actionsSubject.send(.viewInRoomTimeline(eventID: eventID))
|
||||||
case .downloadMedia, .selectMessages:
|
case .downloadMedia:
|
||||||
break // Handled by the media preview screen and the TimelineViewModel respectively.
|
break // Handled inline in the media preview screen.
|
||||||
case .translate:
|
case .translate:
|
||||||
guard let messageTimelineItem = timelineItem as? EventBasedMessageTimelineItemProtocol else { return }
|
guard let messageTimelineItem = timelineItem as? EventBasedMessageTimelineItemProtocol else { return }
|
||||||
actionsSubject.send(.showTranslation(text: messageTimelineItem.body))
|
actionsSubject.send(.showTranslation(text: messageTimelineItem.body))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ enum TimelineViewModelAction {
|
|||||||
case displayEditPollForm(eventID: String, poll: Poll)
|
case displayEditPollForm(eventID: String, poll: Poll)
|
||||||
case displayMediaUploadPreviewScreen(mediaURLs: [URL])
|
case displayMediaUploadPreviewScreen(mediaURLs: [URL])
|
||||||
case displaySenderDetails(userID: String)
|
case displaySenderDetails(userID: String)
|
||||||
case displayMessageForwarding(forwardingItem: MessageForwardingItem)
|
case displayMessageForwarding(forwardingPayload: MessageForwardingPayload)
|
||||||
case displayMediaPreview(TimelineMediaPreviewViewModel)
|
case displayMediaPreview(TimelineMediaPreviewViewModel)
|
||||||
case displayLocation(StaticLocationData)
|
case displayLocation(StaticLocationData)
|
||||||
case displayLiveLocation(sender: TimelineItemSender, initialLiveLocationShare: LiveLocationShare)
|
case displayLiveLocation(sender: TimelineItemSender, initialLiveLocationShare: LiveLocationShare)
|
||||||
@@ -69,11 +69,11 @@ enum TimelineViewAction {
|
|||||||
/// The user has confirmed the removal of an item, optionally giving a reason.
|
/// The user has confirmed the removal of an item, optionally giving a reason.
|
||||||
case redactConfirmed(itemID: TimelineItemIdentifier, reason: String?)
|
case redactConfirmed(itemID: TimelineItemIdentifier, reason: String?)
|
||||||
|
|
||||||
/// Start a multi-selection with the specified item.
|
|
||||||
case startSelection(itemID: TimelineItemIdentifier)
|
|
||||||
/// Add or remove an item from the active multi-selection.
|
/// Add or remove an item from the active multi-selection.
|
||||||
case toggleSelection(itemID: TimelineItemIdentifier)
|
case toggleMessageSelection(itemID: TimelineItemIdentifier)
|
||||||
case clearSelection
|
case clearMessageSelection
|
||||||
|
/// Forward the selected messages, in timeline order.
|
||||||
|
case forwardMessageSelection
|
||||||
|
|
||||||
case tappedOnSenderDetails(sender: TimelineItemSender)
|
case tappedOnSenderDetails(sender: TimelineItemSender)
|
||||||
case displayReactionSummary(itemID: TimelineItemIdentifier, key: String)
|
case displayReactionSummary(itemID: TimelineItemIdentifier, key: String)
|
||||||
@@ -137,7 +137,7 @@ struct TimelineViewState: BindableState {
|
|||||||
var linkPreviewsEnabled: Bool
|
var linkPreviewsEnabled: Bool
|
||||||
var jumpToReadMarkerEnabled: Bool
|
var jumpToReadMarkerEnabled: Bool
|
||||||
|
|
||||||
var selection: TimelineSelectionState
|
var messageSelection: TimelineMessageSelectionState
|
||||||
|
|
||||||
let hasPredecessor: Bool
|
let hasPredecessor: Bool
|
||||||
|
|
||||||
@@ -206,12 +206,10 @@ struct TimelineViewStateBindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The state of the multi-selection of messages, active as soon as an item is selected.
|
/// The state of the multi-selection of messages, active as soon as an item is selected.
|
||||||
struct TimelineSelectionState: Equatable {
|
struct TimelineMessageSelectionState: Equatable {
|
||||||
static let limit = 30
|
static let limit = 10
|
||||||
|
|
||||||
/// Mirrors the `messageMultiSelectEnabled` feature flag.
|
|
||||||
var isEnabled = false
|
var isEnabled = false
|
||||||
/// The event IDs of the selected items. Only remote messages can be selected.
|
|
||||||
var selectedEventIDs: Set<String> = []
|
var selectedEventIDs: Set<String> = []
|
||||||
|
|
||||||
var isActive: Bool {
|
var isActive: Bool {
|
||||||
@@ -354,12 +352,12 @@ enum ScrollDirection: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension TimelineViewState {
|
extension TimelineViewState {
|
||||||
/// Multi-selection is only offered in the room and thread timelines.
|
/// Multi-selection is offered everywhere but the media timelines.
|
||||||
var canSelectMessages: Bool {
|
var canSelectMessages: Bool {
|
||||||
guard selection.isEnabled else { return false }
|
guard messageSelection.isEnabled else { return false }
|
||||||
return switch timelineKind {
|
return switch timelineKind {
|
||||||
case .live, .detached, .thread: true
|
case .live, .detached, .thread, .pinned: true
|
||||||
case .pinned, .media: false
|
case .media: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
areThreadsEnabled: appSettings.threadsEnabled,
|
areThreadsEnabled: appSettings.threadsEnabled,
|
||||||
linkPreviewsEnabled: appSettings.linkPreviewsEnabled,
|
linkPreviewsEnabled: appSettings.linkPreviewsEnabled,
|
||||||
jumpToReadMarkerEnabled: appSettings.jumpToReadMarkerEnabled,
|
jumpToReadMarkerEnabled: appSettings.jumpToReadMarkerEnabled,
|
||||||
selection: .init(isEnabled: appSettings.messageMultiSelectEnabled),
|
messageSelection: .init(isEnabled: appSettings.messageMultiSelectEnabled),
|
||||||
hasPredecessor: roomProxy.predecessorRoom != nil,
|
hasPredecessor: roomProxy.predecessorRoom != nil,
|
||||||
pinnedEventIDs: roomProxy.infoPublisher.value.pinnedEventIDs,
|
pinnedEventIDs: roomProxy.infoPublisher.value.pinnedEventIDs,
|
||||||
emojiProvider: emojiProvider,
|
emojiProvider: emojiProvider,
|
||||||
@@ -198,7 +198,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
}
|
}
|
||||||
case .displayTimelineItemMenu(let itemID):
|
case .displayTimelineItemMenu(let itemID):
|
||||||
timelineInteractionHandler.displayTimelineItemActionMenu(for: itemID)
|
timelineInteractionHandler.displayTimelineItemActionMenu(for: itemID)
|
||||||
case .handleTimelineItemMenuAction(let itemID, .selectMessages):
|
case .handleTimelineItemMenuAction(let itemID, .forward) where state.canSelectMessages:
|
||||||
startSelection(itemID: itemID)
|
startSelection(itemID: itemID)
|
||||||
case .handleTimelineItemMenuAction(let itemID, let action):
|
case .handleTimelineItemMenuAction(let itemID, let action):
|
||||||
timelineInteractionHandler.handleTimelineItemMenuAction(action, itemID: itemID)
|
timelineInteractionHandler.handleTimelineItemMenuAction(action, itemID: itemID)
|
||||||
@@ -206,12 +206,12 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
state.bindings.redactConfirmationInfo = nil
|
state.bindings.redactConfirmationInfo = nil
|
||||||
// A blank reason is no reason at all, so don't send one.
|
// A blank reason is no reason at all, so don't send one.
|
||||||
timelineInteractionHandler.redact(itemID, reason: reason?.isBlank == false ? reason : nil)
|
timelineInteractionHandler.redact(itemID, reason: reason?.isBlank == false ? reason : nil)
|
||||||
case .startSelection(let itemID):
|
case .toggleMessageSelection(let itemID):
|
||||||
startSelection(itemID: itemID)
|
|
||||||
case .toggleSelection(let itemID):
|
|
||||||
toggleSelection(itemID: itemID)
|
toggleSelection(itemID: itemID)
|
||||||
case .clearSelection:
|
case .clearMessageSelection:
|
||||||
state.selection.selectedEventIDs.removeAll()
|
clearMessageSelection()
|
||||||
|
case .forwardMessageSelection:
|
||||||
|
forwardSelection()
|
||||||
case .tappedOnSenderDetails(let sender):
|
case .tappedOnSenderDetails(let sender):
|
||||||
handleTappedOnSenderDetails(sender: sender)
|
handleTappedOnSenderDetails(sender: sender)
|
||||||
case .displayEmojiPicker(let itemID):
|
case .displayEmojiPicker(let itemID):
|
||||||
@@ -313,11 +313,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
await userSession.liveLocationManager.stopLiveLocation(roomID: roomProxy.id)
|
await userSession.liveLocationManager.stopLiveLocation(roomID: roomProxy.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeForwardingItem(for itemID: TimelineItemIdentifier) async -> MessageForwardingItem? {
|
|
||||||
guard let content = await timelineController.messageEventContent(for: itemID) else { return nil }
|
|
||||||
return .init(id: itemID, roomID: roomProxy.id, content: content)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func handleTappedOnSenderDetails(sender: TimelineItemSender) {
|
private func handleTappedOnSenderDetails(sender: TimelineItemSender) {
|
||||||
@@ -1059,13 +1054,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
state.bindings.readReceiptsSummaryInfo = .init(orderedReceipts: eventTimelineItem.properties.orderedReadReceipts, id: eventTimelineItem.id)
|
state.bindings.readReceiptsSummaryInfo = .init(orderedReceipts: eventTimelineItem.properties.orderedReadReceipts, id: eventTimelineItem.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Message forwarding
|
|
||||||
|
|
||||||
private func forwardMessage(itemID: TimelineItemIdentifier) async {
|
|
||||||
guard let forwardingItem = await makeForwardingItem(for: itemID) else { return }
|
|
||||||
actionsSubject.send(.displayMessageForwarding(forwardingItem: forwardingItem))
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Pills
|
// MARK: Pills
|
||||||
|
|
||||||
private func pillContextUpdater(_ pillContext: PillContext) {
|
private func pillContextUpdater(_ pillContext: PillContext) {
|
||||||
@@ -1185,68 +1173,106 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Message forwarding
|
||||||
|
|
||||||
|
extension TimelineViewModel {
|
||||||
|
func makeForwardingPayload(for itemIDs: [TimelineItemIdentifier]) async -> MessageForwardingPayload? {
|
||||||
|
var ids = [TimelineItemIdentifier]()
|
||||||
|
var contents = [RoomMessageEventContentWithoutRelation]()
|
||||||
|
for itemID in itemIDs {
|
||||||
|
guard let content = await timelineController.messageEventContent(for: itemID) else { continue }
|
||||||
|
ids.append(itemID)
|
||||||
|
contents.append(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
guard !contents.isEmpty else { return nil }
|
||||||
|
return .init(ids: ids, roomID: roomProxy.id, contents: contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func forwardMessage(itemID: TimelineItemIdentifier) async {
|
||||||
|
guard let forwardingPayload = await makeForwardingPayload(for: [itemID]) else { return }
|
||||||
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Selection
|
// MARK: - Selection
|
||||||
|
|
||||||
extension TimelineViewModel {
|
extension TimelineViewModel {
|
||||||
private func setupSelectionSubscriptions() {
|
private func setupSelectionSubscriptions() {
|
||||||
appSettings.messageMultiSelectEnabledPublisher
|
appSettings.messageMultiSelectEnabledPublisher
|
||||||
.sink { [weak self] isEnabled in
|
.sink { [weak self] isEnabled in
|
||||||
self?.state.selection.isEnabled = isEnabled
|
self?.state.messageSelection.isEnabled = isEnabled
|
||||||
if !isEnabled {
|
if !isEnabled {
|
||||||
self?.state.selection.selectedEventIDs.removeAll()
|
self?.state.messageSelection.selectedEventIDs.removeAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startSelection(itemID: TimelineItemIdentifier) {
|
private func startSelection(itemID: TimelineItemIdentifier) {
|
||||||
guard state.canSelectMessages, let eventID = selectableEventID(for: itemID) else { return }
|
guard let eventID = selectableEventID(for: itemID) else { return }
|
||||||
|
|
||||||
// The composer is collapsed while selecting, so don't leave the microphone open behind it.
|
// The composer is collapsed while selecting, so don't leave the microphone open behind it.
|
||||||
Task { await timelineInteractionHandler.stopRecordingVoiceMessageIfNeeded() }
|
Task { await timelineInteractionHandler.stopRecordingVoiceMessageIfNeeded() }
|
||||||
actionsSubject.send(.composer(action: .removeFocus))
|
actionsSubject.send(.composer(action: .removeFocus))
|
||||||
|
|
||||||
guard !state.selection.isAtLimit || state.selection.selectedEventIDs.contains(eventID) else {
|
guard !state.messageSelection.isAtLimit || state.messageSelection.selectedEventIDs.contains(eventID) else {
|
||||||
showSelectionLimitToast()
|
showSelectionLimitToast()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state.selection.selectedEventIDs.insert(eventID)
|
state.messageSelection.selectedEventIDs.insert(eventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func toggleSelection(itemID: TimelineItemIdentifier) {
|
private func toggleSelection(itemID: TimelineItemIdentifier) {
|
||||||
guard state.selection.isActive, let eventID = selectableEventID(for: itemID) else { return }
|
guard state.messageSelection.isActive, let eventID = selectableEventID(for: itemID) else { return }
|
||||||
|
|
||||||
if state.selection.selectedEventIDs.contains(eventID) {
|
if state.messageSelection.selectedEventIDs.contains(eventID) {
|
||||||
state.selection.selectedEventIDs.remove(eventID)
|
state.messageSelection.selectedEventIDs.remove(eventID)
|
||||||
} else if state.selection.isAtLimit {
|
} else if state.messageSelection.isAtLimit {
|
||||||
showSelectionLimitToast()
|
showSelectionLimitToast()
|
||||||
} else {
|
} else {
|
||||||
state.selection.selectedEventIDs.insert(eventID)
|
state.messageSelection.selectedEventIDs.insert(eventID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drops selected items that are no longer selectable (e.g. redacted), or the whole selection
|
/// Drops selected items that are no longer selectable (e.g. redacted), or the whole selection
|
||||||
/// when the timeline is swapped, so the selection always refers to items that are on screen.
|
/// when the timeline is swapped, so the selection always refers to items that are on screen.
|
||||||
private func reconcileSelection(with timelineItems: [RoomTimelineItemProtocol], isSwitchingTimelines: Bool) {
|
private func reconcileSelection(with timelineItems: [RoomTimelineItemProtocol], isSwitchingTimelines: Bool) {
|
||||||
guard state.selection.isActive else { return }
|
guard state.messageSelection.isActive else { return }
|
||||||
|
|
||||||
if isSwitchingTimelines {
|
if isSwitchingTimelines {
|
||||||
state.selection.selectedEventIDs.removeAll()
|
state.messageSelection.selectedEventIDs.removeAll()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectableEventIDs = timelineItems.compactMap { item -> String? in
|
let forwardableEventIDs = timelineItems.forwardableItems.compactMap(\.id.eventID)
|
||||||
guard let item = item as? EventBasedTimelineItemProtocol, item.isBulkSelectable else { return nil }
|
state.messageSelection.selectedEventIDs.formIntersection(forwardableEventIDs)
|
||||||
return item.id.eventID
|
|
||||||
}
|
|
||||||
state.selection.selectedEventIDs.formIntersection(selectableEventIDs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The event ID of the item, when it is part of this timeline and can be bulk selected.
|
/// Ends the selection, either from the close button or once the selected messages have been forwarded.
|
||||||
|
func clearMessageSelection() {
|
||||||
|
state.messageSelection.selectedEventIDs.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Forwards the selection in timeline order, which is unrelated to the order the messages were selected in.
|
||||||
|
/// The selection is kept until the forwarding completes, so cancelling the picker returns to it.
|
||||||
|
private func forwardSelection() {
|
||||||
|
let itemIDs = timelineController.timelineItems.selectedItems(state.messageSelection.selectedEventIDs).map(\.id)
|
||||||
|
|
||||||
|
Task {
|
||||||
|
guard let forwardingPayload = await makeForwardingPayload(for: itemIDs) else {
|
||||||
|
displayErrorToast(L10n.errorUnknown)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
actionsSubject.send(.displayMessageForwarding(forwardingPayload: forwardingPayload))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The event ID of the item, when it is part of this timeline and can be forwarded.
|
||||||
private func selectableEventID(for itemID: TimelineItemIdentifier) -> String? {
|
private func selectableEventID(for itemID: TimelineItemIdentifier) -> String? {
|
||||||
guard let item = timelineController.timelineItems.firstUsingStableID(itemID) as? EventBasedTimelineItemProtocol,
|
guard let item = timelineController.timelineItems.firstUsingStableID(itemID) as? EventBasedTimelineItemProtocol,
|
||||||
item.isBulkSelectable else {
|
item.isForwardable else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return item.id.eventID
|
return item.id.eventID
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ protocol TimelineViewModelProtocol {
|
|||||||
func focusOnEvent(eventID: String) async
|
func focusOnEvent(eventID: String) async
|
||||||
/// Stops the current live location sharing
|
/// Stops the current live location sharing
|
||||||
func stopLiveLocationSharing() async
|
func stopLiveLocationSharing() async
|
||||||
/// Handles getting the content to forward an item given its item ID.
|
/// Handles getting the contents to forward the given items, keeping the order of the given IDs.
|
||||||
func makeForwardingItem(for itemID: TimelineItemIdentifier) async -> MessageForwardingItem?
|
func makeForwardingPayload(for itemIDs: [TimelineItemIdentifier]) async -> MessageForwardingPayload?
|
||||||
|
/// Ends the message selection, e.g. once the selected messages have been forwarded.
|
||||||
|
func clearMessageSelection()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,7 +339,6 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview {
|
|||||||
pinnedEventIDs: [],
|
pinnedEventIDs: [],
|
||||||
isViewSourceEnabled: true,
|
isViewSourceEnabled: true,
|
||||||
areThreadsEnabled: true,
|
areThreadsEnabled: true,
|
||||||
isMultiSelectEnabled: false,
|
|
||||||
timelineKind: .live,
|
timelineKind: .live,
|
||||||
emojiProvider: EmojiProvider(appSettings: .volatile()))
|
emojiProvider: EmojiProvider(appSettings: .volatile()))
|
||||||
guard let actions = provider.makeActions() else { return nil }
|
guard let actions = provider.makeActions() else { return nil }
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
|||||||
case reply(isThread: Bool)
|
case reply(isThread: Bool)
|
||||||
case replyInThread
|
case replyInThread
|
||||||
case forward(itemID: TimelineItemIdentifier)
|
case forward(itemID: TimelineItemIdentifier)
|
||||||
case selectMessages
|
|
||||||
case viewSource
|
case viewSource
|
||||||
case report
|
case report
|
||||||
case react
|
case react
|
||||||
@@ -170,8 +169,6 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
|||||||
Label(L10n.actionReplyInThread, icon: \.threads)
|
Label(L10n.actionReplyInThread, icon: \.threads)
|
||||||
case .forward:
|
case .forward:
|
||||||
Label(L10n.actionForward, icon: \.forward)
|
Label(L10n.actionForward, icon: \.forward)
|
||||||
case .selectMessages:
|
|
||||||
Label(L10n.actionSelect, icon: \.check)
|
|
||||||
case .redact(let isMedia):
|
case .redact(let isMedia):
|
||||||
Label(isMedia ? L10n.actionDeleteFile : L10n.actionRemoveMessage, icon: \.delete)
|
Label(isMedia ? L10n.actionDeleteFile : L10n.actionRemoveMessage, icon: \.delete)
|
||||||
case .viewSource:
|
case .viewSource:
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ struct TimelineItemMenuActionProvider {
|
|||||||
let pinnedEventIDs: Set<String>
|
let pinnedEventIDs: Set<String>
|
||||||
let isViewSourceEnabled: Bool
|
let isViewSourceEnabled: Bool
|
||||||
let areThreadsEnabled: Bool
|
let areThreadsEnabled: Bool
|
||||||
let isMultiSelectEnabled: Bool
|
|
||||||
let timelineKind: TimelineKind
|
let timelineKind: TimelineKind
|
||||||
let emojiProvider: EmojiProviderProtocol
|
let emojiProvider: EmojiProviderProtocol
|
||||||
|
|
||||||
@@ -66,10 +65,6 @@ struct TimelineItemMenuActionProvider {
|
|||||||
actions.append(.forward(itemID: item.id))
|
actions.append(.forward(itemID: item.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
if isMultiSelectEnabled, item.isBulkSelectable {
|
|
||||||
actions.append(.selectMessages)
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.isEditable, canCurrentUserSendMessage {
|
if item.isEditable, canCurrentUserSendMessage {
|
||||||
if item.supportsMediaCaption {
|
if item.supportsMediaCaption {
|
||||||
if item.hasMediaCaption {
|
if item.hasMediaCaption {
|
||||||
|
|||||||
+4
-4
@@ -9,7 +9,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// How a timeline item takes part in an active multi-selection, for accessibility purposes.
|
/// How a timeline item takes part in an active multi-selection, for accessibility purposes.
|
||||||
enum TimelineItemAccessibilitySelection {
|
enum TimelineItemAccessibilityMessageSelection {
|
||||||
/// No selection is active, the item offers its regular message actions.
|
/// No selection is active, the item offers its regular message actions.
|
||||||
case none
|
case none
|
||||||
/// A selection is active, the item acts as a toggle when it can be selected.
|
/// A selection is active, the item acts as a toggle when it can be selected.
|
||||||
@@ -18,7 +18,7 @@ enum TimelineItemAccessibilitySelection {
|
|||||||
|
|
||||||
private struct TimelineItemAccessibilityModifier: ViewModifier {
|
private struct TimelineItemAccessibilityModifier: ViewModifier {
|
||||||
let timelineItem: RoomTimelineItemProtocol
|
let timelineItem: RoomTimelineItemProtocol
|
||||||
let selection: TimelineItemAccessibilitySelection
|
let selection: TimelineItemAccessibilityMessageSelection
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
||||||
private var isSelecting: Bool {
|
private var isSelecting: Bool {
|
||||||
@@ -77,7 +77,7 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .selecting(let isSelected):
|
case .selecting(let isSelected):
|
||||||
if let item = timelineItem as? EventBasedTimelineItemProtocol, item.isBulkSelectable {
|
if let item = timelineItem as? EventBasedTimelineItemProtocol, item.isForwardable {
|
||||||
view
|
view
|
||||||
.accessibilityAddTraits(isSelected ? [.isButton, .isSelected] : .isButton)
|
.accessibilityAddTraits(isSelected ? [.isButton, .isSelected] : .isButton)
|
||||||
.accessibilityAction(.default, action)
|
.accessibilityAction(.default, action)
|
||||||
@@ -91,7 +91,7 @@ private struct TimelineItemAccessibilityModifier: ViewModifier {
|
|||||||
|
|
||||||
extension View {
|
extension View {
|
||||||
func timelineItemAccessibility(_ timelineItem: RoomTimelineItemProtocol,
|
func timelineItemAccessibility(_ timelineItem: RoomTimelineItemProtocol,
|
||||||
selection: TimelineItemAccessibilitySelection = .none,
|
selection: TimelineItemAccessibilityMessageSelection = .none,
|
||||||
action: @escaping () -> Void) -> some View {
|
action: @escaping () -> Void) -> some View {
|
||||||
modifier(TimelineItemAccessibilityModifier(timelineItem: timelineItem, selection: selection, action: action))
|
modifier(TimelineItemAccessibilityModifier(timelineItem: timelineItem, selection: selection, action: action))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
return context.viewState.pinnedEventIDs.contains(eventID)
|
return context.viewState.pinnedEventIDs.contains(eventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isSelectionActive: Bool {
|
private var isMessageSelectionActive: Bool {
|
||||||
context.viewState.selection.isActive
|
context.viewState.messageSelection.isActive
|
||||||
}
|
}
|
||||||
|
|
||||||
private var isSelected: Bool {
|
private var isSelected: Bool {
|
||||||
context.viewState.selection.contains(timelineItem.id.eventID)
|
context.viewState.messageSelection.contains(timelineItem.id.eventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The base padding applied to bubbles on either side.
|
/// The base padding applied to bubbles on either side.
|
||||||
@@ -61,18 +61,17 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 10) {
|
||||||
if isSelectionActive {
|
if isMessageSelectionActive {
|
||||||
selectionIndicator
|
selectionIndicator
|
||||||
}
|
}
|
||||||
|
|
||||||
bubble
|
bubble
|
||||||
}
|
}
|
||||||
.padding(EdgeInsets(top: 1, leading: 8, bottom: 1, trailing: 8))
|
.padding(EdgeInsets(top: 1, leading: 8, bottom: 1, trailing: 8))
|
||||||
.background(isSelected ? Color.compound.bgAccentSelected : .clear)
|
|
||||||
.highlightedTimelineItem(isFocussed)
|
.highlightedTimelineItem(isFocussed)
|
||||||
.overlay { selectionOverlay }
|
.overlay { selectionOverlay }
|
||||||
.animation(.elementDefault.disabledDuringTests(), value: isSelectionActive)
|
.animation(.elementDefault.disabledDuringTests(), value: isMessageSelectionActive)
|
||||||
.onPreferenceChange(ContentScanningFailurePreferenceKey.self) { contentScanningFailure = $0 }
|
.onPreferenceChange(ContentScanningFailurePreferenceKey.self) { contentScanningFailure = $0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
// The ZStack keeps the transition on the indicator's appearance rather than its checked state.
|
// The ZStack keeps the transition on the indicator's appearance rather than its checked state.
|
||||||
ZStack {
|
ZStack {
|
||||||
ListRowAccessory.multiSelection(isSelected)
|
ListRowAccessory.multiSelection(isSelected)
|
||||||
.opacity(timelineItem.isBulkSelectable ? 1 : 0) // Keeps the bubbles aligned.
|
.opacity(timelineItem.isForwardable ? 1 : 0) // Keeps the bubbles aligned.
|
||||||
}
|
}
|
||||||
.padding(.leading, 8)
|
.padding(.leading, 8)
|
||||||
.transition(.move(edge: .leading).combined(with: .opacity))
|
.transition(.move(edge: .leading).combined(with: .opacity))
|
||||||
@@ -90,7 +89,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
/// Captures every touch while selecting so the content's own gestures can't fire.
|
/// Captures every touch while selecting so the content's own gestures can't fire.
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var selectionOverlay: some View {
|
private var selectionOverlay: some View {
|
||||||
if isSelectionActive {
|
if isMessageSelectionActive {
|
||||||
Color.clear
|
Color.clear
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onTapGesture { toggleSelection() }
|
.onTapGesture { toggleSelection() }
|
||||||
@@ -172,8 +171,8 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
// Figma overlaps reactions by 3
|
// Figma overlaps reactions by 3
|
||||||
VStack(alignment: alignment, spacing: -3) {
|
VStack(alignment: alignment, spacing: -3) {
|
||||||
messageBubbleWithActions
|
messageBubbleWithActions
|
||||||
.timelineItemAccessibility(timelineItem, selection: isSelectionActive ? .selecting(isSelected: isSelected) : .none) {
|
.timelineItemAccessibility(timelineItem, selection: isMessageSelectionActive ? .selecting(isSelected: isSelected) : .none) {
|
||||||
if isSelectionActive {
|
if isMessageSelectionActive {
|
||||||
toggleSelection()
|
toggleSelection()
|
||||||
} else {
|
} else {
|
||||||
context.send(viewAction: .displayTimelineItemMenu(itemID: timelineItem.id))
|
context.send(viewAction: .displayTimelineItemMenu(itemID: timelineItem.id))
|
||||||
@@ -189,7 +188,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
isLayoutRTL: timelineItem.isOutgoing)
|
isLayoutRTL: timelineItem.isOutgoing)
|
||||||
// Workaround to stop the message long press stealing the touch from the reaction buttons
|
// Workaround to stop the message long press stealing the touch from the reaction buttons
|
||||||
.onTapGesture { }
|
.onTapGesture { }
|
||||||
.accessibilityHidden(isSelectionActive)
|
.accessibilityHidden(isMessageSelectionActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
if context.viewState.areThreadsEnabled,
|
if context.viewState.areThreadsEnabled,
|
||||||
@@ -199,7 +198,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
context.send(viewAction: .displayThread(itemID: timelineItem.id))
|
context.send(viewAction: .displayThread(itemID: timelineItem.id))
|
||||||
}
|
}
|
||||||
.padding(5)
|
.padding(5)
|
||||||
.accessibilityHidden(isSelectionActive)
|
.accessibilityHidden(isMessageSelectionActive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,7 +212,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
// specific taps within the timeline views themselves.
|
// specific taps within the timeline views themselves.
|
||||||
}
|
}
|
||||||
// The UIKit recogniser would still receive touches through the selection overlay.
|
// The UIKit recogniser would still receive touches through the selection overlay.
|
||||||
.longPressWithFeedback(isEnabled: !isSelectionActive) {
|
.longPressWithFeedback(isEnabled: !isMessageSelectionActive) {
|
||||||
context.send(viewAction: .displayTimelineItemMenu(itemID: timelineItem.id))
|
context.send(viewAction: .displayTimelineItemMenu(itemID: timelineItem.id))
|
||||||
}
|
}
|
||||||
.swipeRightAction {
|
.swipeRightAction {
|
||||||
@@ -221,13 +220,13 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
.foregroundColor(.compound.iconPrimary)
|
.foregroundColor(.compound.iconPrimary)
|
||||||
.accessibilityHidden(true)
|
.accessibilityHidden(true)
|
||||||
} shouldStartAction: {
|
} shouldStartAction: {
|
||||||
!isSelectionActive && timelineItem.canBeRepliedTo
|
!isMessageSelectionActive && timelineItem.canBeRepliedTo
|
||||||
} action: {
|
} action: {
|
||||||
context.send(viewAction: .handleTimelineItemMenuAction(itemID: timelineItem.id,
|
context.send(viewAction: .handleTimelineItemMenuAction(itemID: timelineItem.id,
|
||||||
action: .reply(isThread: timelineItem.properties.isThreaded)))
|
action: .reply(isThread: timelineItem.properties.isThreaded)))
|
||||||
}
|
}
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
if !isSelectionActive {
|
if !isMessageSelectionActive {
|
||||||
macContextMenu
|
macContextMenu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,7 +244,6 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
pinnedEventIDs: context.viewState.pinnedEventIDs,
|
pinnedEventIDs: context.viewState.pinnedEventIDs,
|
||||||
isViewSourceEnabled: context.viewState.isViewSourceEnabled,
|
isViewSourceEnabled: context.viewState.isViewSourceEnabled,
|
||||||
areThreadsEnabled: context.viewState.areThreadsEnabled,
|
areThreadsEnabled: context.viewState.areThreadsEnabled,
|
||||||
isMultiSelectEnabled: context.viewState.canSelectMessages,
|
|
||||||
timelineKind: context.viewState.timelineKind,
|
timelineKind: context.viewState.timelineKind,
|
||||||
emojiProvider: context.viewState.emojiProvider)
|
emojiProvider: context.viewState.emojiProvider)
|
||||||
TimelineItemMacContextMenu(item: timelineItem, actionProvider: provider) { action in
|
TimelineItemMacContextMenu(item: timelineItem, actionProvider: provider) { action in
|
||||||
@@ -298,8 +296,8 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func toggleSelection() {
|
private func toggleSelection() {
|
||||||
guard timelineItem.isBulkSelectable else { return }
|
guard timelineItem.isForwardable else { return }
|
||||||
context.send(viewAction: .toggleSelection(itemID: timelineItem.id))
|
context.send(viewAction: .toggleMessageSelection(itemID: timelineItem.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
private var messageBubbleTopPadding: CGFloat {
|
private var messageBubbleTopPadding: CGFloat {
|
||||||
@@ -478,7 +476,7 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
|||||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||||
linkMetadataProvider: LinkMetadataProvider(),
|
linkMetadataProvider: LinkMetadataProvider(),
|
||||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||||
viewModel.state.selection.selectedEventIDs = ["selected"]
|
viewModel.state.messageSelection.selectedEventIDs = ["selected"]
|
||||||
return viewModel
|
return viewModel
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 Element Creations Ltd.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||||
|
// Please see LICENSE files in the repository root for full details.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Compound
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// Replaces the composer while messages are being selected, offering the action to take on them.
|
||||||
|
struct TimelineMessageSelectionActionBar: View {
|
||||||
|
@ObservedObject var context: TimelineViewModelType.Context
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Button {
|
||||||
|
context.send(viewAction: .forwardMessageSelection)
|
||||||
|
} label: {
|
||||||
|
Label(L10n.actionForwardMessages(context.viewState.messageSelection.count), icon: \.forward)
|
||||||
|
}
|
||||||
|
.buttonStyle(.compound(.primary))
|
||||||
|
.padding(16)
|
||||||
|
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Previews
|
||||||
|
|
||||||
|
struct TimelineMessageSelectionActionBar_Previews: PreviewProvider, TestablePreview {
|
||||||
|
static let viewModel: TimelineViewModel = {
|
||||||
|
let viewModel = TimelineViewModel.mock() // A fresh instance so the shared mock isn't left selecting.
|
||||||
|
viewModel.state.messageSelection.selectedEventIDs = ["$1", "$2", "$3"]
|
||||||
|
return viewModel
|
||||||
|
}()
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
TimelineMessageSelectionActionBar(context: viewModel.context)
|
||||||
|
.previewLayout(.sizeThatFits)
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 Element Creations Ltd.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||||
|
// Please see LICENSE files in the repository root for full details.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// The trailing navigation bar item that cancels the selection of messages in a timeline.
|
||||||
|
struct TimelineMessageSelectionToolbar: ToolbarContent {
|
||||||
|
let onCancel: () -> Void
|
||||||
|
|
||||||
|
var body: some ToolbarContent {
|
||||||
|
ToolbarItem(placement: .primaryAction) {
|
||||||
|
ToolbarButton(role: .cancel, action: onCancel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright 2026 Element Creations Ltd.
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
||||||
// Please see LICENSE files in the repository root for full details.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Compound
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
/// The navigation bar content shown while messages are being selected in a timeline.
|
|
||||||
struct TimelineSelectionToolbar: ToolbarContent {
|
|
||||||
let count: Int
|
|
||||||
let onCancel: () -> Void
|
|
||||||
|
|
||||||
var body: some ToolbarContent {
|
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
|
||||||
Button(L10n.actionCancel, role: .cancel, action: onCancel)
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolbarItem(placement: .principal) {
|
|
||||||
Text(L10n.screenRoomSelectionCount(count))
|
|
||||||
.font(.compound.bodyLGSemibold)
|
|
||||||
.foregroundStyle(.compound.textPrimary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,6 @@ struct TimelineView: View {
|
|||||||
pinnedEventIDs: timelineContext.viewState.pinnedEventIDs,
|
pinnedEventIDs: timelineContext.viewState.pinnedEventIDs,
|
||||||
isViewSourceEnabled: timelineContext.viewState.isViewSourceEnabled,
|
isViewSourceEnabled: timelineContext.viewState.isViewSourceEnabled,
|
||||||
areThreadsEnabled: timelineContext.viewState.areThreadsEnabled,
|
areThreadsEnabled: timelineContext.viewState.areThreadsEnabled,
|
||||||
isMultiSelectEnabled: timelineContext.viewState.canSelectMessages,
|
|
||||||
timelineKind: timelineContext.viewState.timelineKind,
|
timelineKind: timelineContext.viewState.timelineKind,
|
||||||
emojiProvider: timelineContext.viewState.emojiProvider)
|
emojiProvider: timelineContext.viewState.emojiProvider)
|
||||||
.makeActions()
|
.makeActions()
|
||||||
|
|||||||
+2
-5
@@ -28,17 +28,14 @@ nonisolated extension EventBasedTimelineItemProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isForwardable: Bool {
|
var isForwardable: Bool {
|
||||||
isRemoteMessage && !(self is PollRoomTimelineItem) && !(self is LiveLocationRoomTimelineItem)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether the item can be part of a multi-selection of messages.
|
|
||||||
var isBulkSelectable: Bool {
|
|
||||||
isRemoteMessage
|
isRemoteMessage
|
||||||
&& !isRedacted
|
&& !isRedacted
|
||||||
&& !hasFailedDecryption
|
&& !hasFailedDecryption
|
||||||
&& !(self is StateRoomTimelineItem)
|
&& !(self is StateRoomTimelineItem)
|
||||||
&& !(self is UnsupportedRoomTimelineItem)
|
&& !(self is UnsupportedRoomTimelineItem)
|
||||||
|
&& !(self is PollRoomTimelineItem)
|
||||||
&& !(self is LiveLocationRoomTimelineItem)
|
&& !(self is LiveLocationRoomTimelineItem)
|
||||||
|
&& !(self is StickerRoomTimelineItem) // The SDK can only forward m.room.message content and stickers are m.sticker events.
|
||||||
}
|
}
|
||||||
|
|
||||||
var isRemoteMessage: Bool {
|
var isRemoteMessage: Bool {
|
||||||
|
|||||||
@@ -1404,6 +1404,13 @@ extension PreviewTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func timelineMessageSelectionActionBar() async throws {
|
||||||
|
for (index, preview) in TimelineMessageSelectionActionBar_Previews._allPreviews.enumerated() {
|
||||||
|
try await assertSnapshots(matching: preview, step: index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func timelineReactionView() async throws {
|
func timelineReactionView() async throws {
|
||||||
for (index, preview) in TimelineReactionView_Previews._allPreviews.enumerated() {
|
for (index, preview) in TimelineReactionView_Previews._allPreviews.enumerated() {
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:2113272aba349068ef746f57f993aa8f1cced5ce3be84acd7dcb83522dd34df7
|
||||||
|
size 229720
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:0cb91f8da5aec4cfcf57682d55fab5dbf55b602e8ab03bc4c5e2cb7607cd26fe
|
||||||
|
size 236621
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:38711b2757b8cbf0e8e03449fd76e932e841e54a84d810ab138fc5329e42d28e
|
||||||
|
size 168069
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:0459720ea7376e5c62a7e29f0c69d06fa50e4f67a5c2d0c70abd008913370dc2
|
||||||
|
size 160328
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a8c4d7de9bde6e8b8ed405139ef0b1a93c526efc0495dc9e060f7746e3851a27
|
oid sha256:c71750ad42a0bf4ba7000886933a7b469b66f0a2e83ad2d9af3cdb93cc6d78bb
|
||||||
size 307560
|
size 296680
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:b736b917580ffb895f52e571f7ec6b88fa79618ef7d967af4be7a1dc1297d74a
|
oid sha256:e590117b3cef004295b78b851a8bab6a847e032d81a6a733165aa3d671fc8d39
|
||||||
size 314629
|
size 302175
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:70802dcebe90358926b889013d49f094111426817c4a3c5739e5bf6c56a7f755
|
oid sha256:4a5286947f95971372a4e5cc146df21821dc18374462b80da063c7b014189de6
|
||||||
size 185662
|
size 173954
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:3cf29299b5003b889898629a533303496911b212b42e9e8dc10912ec7ac5e519
|
oid sha256:2821e658003cb2d10e89c35a212ce44f2b543d030d8d2f698b660929f1fd8fa0
|
||||||
size 179793
|
size 166352
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f4ba074e3d13bc6ecfefe9e91e0515d0fa0a793908ae38fe400c845c389d79fd
|
oid sha256:4f1d033633be525d00add117f22cbd644738f557566652105e5bad06fa93f550
|
||||||
size 103633
|
size 100876
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:1d1e836cbb773ab61e7c5470fec38a51dce0572b5a779eabdcd86a0171b7aa04
|
oid sha256:453b6c26d0af9fc4f52acd6878eb521ea391803d859ca8d22ff6537b43af443a
|
||||||
size 106075
|
size 103386
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:aed3e91bdd708c6738cc2e82e8271988761adc46c8192e491cb5e7bcf4f33031
|
oid sha256:0a39d152d8c2325e6600a335916be5af29a7d195df61ae33c7c2da138c3a225d
|
||||||
size 59392
|
size 59166
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ecafd3c5f7ca87afbc5b88211205b0a5b8e950595fdc5f526456628b3f1c32d3
|
oid sha256:0e86d354c76d520c1d45d263b5d25851d3db42b2767440876a322525c849479c
|
||||||
size 61305
|
size 60994
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:acf13cf6aa2414522d9de6d68d631e1334072d72231be8ec552dbc1ebf02efb4
|
||||||
|
size 17224
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:31a3a51a1f5756e5b25ede739f05d33586c1e459d4fb5c147d69324a539f21ff
|
||||||
|
size 17343
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:8b6d05bd21a076f815bfcd766317e4ca1860c54a91f86faf30dbdbd503d2329f
|
||||||
|
size 11595
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:b945f049c4f2325bb6da028586a901c7b5144cce57ff49d55678c34e123a20e7
|
||||||
|
size 11653
|
||||||
@@ -13,9 +13,11 @@ import Testing
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
struct MessageForwardingScreenViewModelTests {
|
struct MessageForwardingScreenViewModelTests {
|
||||||
let forwardingItem = MessageForwardingItem(id: .event(uniqueID: .init("t1"), eventOrTransactionID: .eventID("t1")),
|
let forwardingPayload = MessageForwardingPayload(ids: [.event(uniqueID: .init("t1"), eventOrTransactionID: .eventID("t1")),
|
||||||
roomID: "1",
|
.event(uniqueID: .init("t2"), eventOrTransactionID: .eventID("t2"))],
|
||||||
content: RoomMessageEventContentWithoutRelationSDKMock())
|
roomID: "1",
|
||||||
|
contents: [RoomMessageEventContentWithoutRelationSDKMock(),
|
||||||
|
RoomMessageEventContentWithoutRelationSDKMock()])
|
||||||
var viewModel: MessageForwardingScreenViewModelProtocol!
|
var viewModel: MessageForwardingScreenViewModelProtocol!
|
||||||
var context: MessageForwardingScreenViewModelType.Context!
|
var context: MessageForwardingScreenViewModelType.Context!
|
||||||
|
|
||||||
@@ -23,7 +25,7 @@ struct MessageForwardingScreenViewModelTests {
|
|||||||
let clientProxy = ClientProxyMock(.init())
|
let clientProxy = ClientProxyMock(.init())
|
||||||
clientProxy.roomForIdentifierClosure = { .joined(JoinedRoomProxyMock(.init(id: $0))) }
|
clientProxy.roomForIdentifierClosure = { .joined(JoinedRoomProxyMock(.init(id: $0))) }
|
||||||
|
|
||||||
viewModel = MessageForwardingScreenViewModel(forwardingItem: forwardingItem,
|
viewModel = MessageForwardingScreenViewModel(forwardingPayload: forwardingPayload,
|
||||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||||
userIndicatorController: UserIndicatorControllerMock())
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
@@ -32,7 +34,7 @@ struct MessageForwardingScreenViewModelTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
func initialState() {
|
func initialState() {
|
||||||
#expect(!context.viewState.rooms.contains { $0.id == forwardingItem.roomID }, "The source room ID shouldn't be shown")
|
#expect(!context.viewState.rooms.contains { $0.id == forwardingPayload.roomID }, "The source room ID shouldn't be shown")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -70,4 +72,122 @@ struct MessageForwardingScreenViewModelTests {
|
|||||||
|
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
mutating func forwardingSendsEveryMessageToEveryRoomInOrder() async throws {
|
||||||
|
let clientProxy = ClientProxyMock(.init())
|
||||||
|
var roomProxies = [String: JoinedRoomProxyMock]()
|
||||||
|
clientProxy.roomForIdentifierClosure = { roomID in
|
||||||
|
let roomProxy = JoinedRoomProxyMock(.init(id: roomID))
|
||||||
|
roomProxies[roomID] = roomProxy
|
||||||
|
return .joined(roomProxy)
|
||||||
|
}
|
||||||
|
viewModel = MessageForwardingScreenViewModel(forwardingPayload: forwardingPayload,
|
||||||
|
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||||
|
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||||
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
|
context = viewModel.context
|
||||||
|
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "3"))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .sent(let roomIDs) = action {
|
||||||
|
return Set(roomIDs) == ["2", "3"]
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
context.send(viewAction: .send)
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
let expectedContents = forwardingPayload.contents.map { ObjectIdentifier($0) }
|
||||||
|
for roomID in ["2", "3"] {
|
||||||
|
let timeline = try #require(roomProxies[roomID]?.timeline as? TimelineProxyMock)
|
||||||
|
let sentContents = timeline.sendMessageEventContentReceivedInvocations.map { ObjectIdentifier($0) }
|
||||||
|
#expect(sentContents == expectedContents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
mutating func forwardingToSeveralRoomsShowsAToast() async throws {
|
||||||
|
let userIndicatorController = UserIndicatorControllerMock()
|
||||||
|
viewModel = makeViewModel(userIndicatorController: userIndicatorController)
|
||||||
|
context = viewModel.context
|
||||||
|
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "3"))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .sent = action {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
context.send(viewAction: .send)
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
let titles = userIndicatorController.submitIndicatorDelayReceivedInvocations.map(\.indicator.title)
|
||||||
|
#expect(titles == [L10n.screenRoomMessagesForwarded(2)])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
mutating func forwardingToOneRoomDoesNotShowAToast() async throws {
|
||||||
|
let userIndicatorController = UserIndicatorControllerMock()
|
||||||
|
viewModel = makeViewModel(userIndicatorController: userIndicatorController)
|
||||||
|
context = viewModel.context
|
||||||
|
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .sent = action {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
context.send(viewAction: .send)
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
// The flow opens the room instead.
|
||||||
|
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
mutating func forwardingReportsRoomsThatCouldNotBeReached() async throws {
|
||||||
|
let clientProxy = ClientProxyMock(.init())
|
||||||
|
clientProxy.roomForIdentifierClosure = { roomID in
|
||||||
|
roomID == "3" ? nil : .joined(JoinedRoomProxyMock(.init(id: roomID)))
|
||||||
|
}
|
||||||
|
let userIndicatorController = UserIndicatorControllerMock()
|
||||||
|
viewModel = MessageForwardingScreenViewModel(forwardingPayload: forwardingPayload,
|
||||||
|
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||||
|
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||||
|
userIndicatorController: userIndicatorController)
|
||||||
|
context = viewModel.context
|
||||||
|
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||||
|
context.send(viewAction: .selectRoom(roomID: "3"))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .sent(let roomIDs) = action {
|
||||||
|
return roomIDs == ["2"]
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
context.send(viewAction: .send)
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
private func makeViewModel(userIndicatorController: UserIndicatorControllerProtocol) -> MessageForwardingScreenViewModelProtocol {
|
||||||
|
let clientProxy = ClientProxyMock(.init())
|
||||||
|
clientProxy.roomForIdentifierClosure = { .joined(JoinedRoomProxyMock(.init(id: $0))) }
|
||||||
|
|
||||||
|
return MessageForwardingScreenViewModel(forwardingPayload: forwardingPayload,
|
||||||
|
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||||
|
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||||
|
userIndicatorController: userIndicatorController)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,41 +51,23 @@ struct TimelineItemMenuActionProviderTests {
|
|||||||
#expect(hasForward)
|
#expect(hasForward)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Select
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func selectIsShownForRemoteMessageWhenEnabled() throws {
|
func redactedMessageIsNotForwardable() throws {
|
||||||
let actions = try #require(makeActions(for: makeTextItem(), isMultiSelectEnabled: true))
|
let item = RedactedRoomTimelineItem(id: .randomEvent,
|
||||||
#expect(actions.actions.contains(.selectMessages))
|
body: "Message removed",
|
||||||
|
timestamp: .mock,
|
||||||
|
isOutgoing: false,
|
||||||
|
isEditable: false,
|
||||||
|
canBeRepliedTo: false,
|
||||||
|
sender: .init(id: "@alice:matrix.org"))
|
||||||
|
let actions = try #require(makeActions(for: item))
|
||||||
|
|
||||||
|
let hasForward = actions.actions.contains(where: \.isForward)
|
||||||
|
#expect(!hasForward)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func selectIsHiddenWhenDisabled() throws {
|
func encryptedMessageIsNotForwardable() throws {
|
||||||
let actions = try #require(makeActions(for: makeTextItem()))
|
|
||||||
#expect(!actions.actions.contains(.selectMessages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
func selectIsHiddenInPinnedTimeline() throws {
|
|
||||||
let actions = try #require(makeActions(for: makeTextItem(), isMultiSelectEnabled: true, timelineKind: .pinned))
|
|
||||||
#expect(!actions.actions.contains(.selectMessages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
func selectIsHiddenForLocalEcho() throws {
|
|
||||||
let item = makeTextItem(id: .event(uniqueID: .init("local"), eventOrTransactionID: .transactionID("txn")))
|
|
||||||
let actions = try #require(makeActions(for: item, isMultiSelectEnabled: true))
|
|
||||||
#expect(!actions.actions.contains(.selectMessages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
func selectIsHiddenForLiveLocationShare() throws {
|
|
||||||
let actions = try #require(makeActions(for: makeLiveLocationItem(isLive: true), isMultiSelectEnabled: true))
|
|
||||||
#expect(!actions.actions.contains(.selectMessages))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
func selectIsHiddenForEncryptedItem() throws {
|
|
||||||
let item = EncryptedRoomTimelineItem(id: .randomEvent,
|
let item = EncryptedRoomTimelineItem(id: .randomEvent,
|
||||||
body: "",
|
body: "",
|
||||||
encryptionType: .unknown,
|
encryptionType: .unknown,
|
||||||
@@ -94,8 +76,19 @@ struct TimelineItemMenuActionProviderTests {
|
|||||||
isEditable: false,
|
isEditable: false,
|
||||||
canBeRepliedTo: false,
|
canBeRepliedTo: false,
|
||||||
sender: .init(id: "@alice:matrix.org"))
|
sender: .init(id: "@alice:matrix.org"))
|
||||||
let actions = try #require(makeActions(for: item, isMultiSelectEnabled: true))
|
let actions = try #require(makeActions(for: item))
|
||||||
#expect(!actions.actions.contains(.selectMessages))
|
|
||||||
|
let hasForward = actions.actions.contains(where: \.isForward)
|
||||||
|
#expect(!hasForward)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func localEchoIsNotForwardable() throws {
|
||||||
|
let item = makeTextItem(id: .event(uniqueID: .init("local"), eventOrTransactionID: .transactionID("txn")))
|
||||||
|
let actions = try #require(makeActions(for: item))
|
||||||
|
|
||||||
|
let hasForward = actions.actions.contains(where: \.isForward)
|
||||||
|
#expect(!hasForward)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
@@ -120,9 +113,7 @@ struct TimelineItemMenuActionProviderTests {
|
|||||||
content: .init(isLive: isLive, timeoutDate: .mock, lastGeoURI: nil))
|
content: .init(isLive: isLive, timeoutDate: .mock, lastGeoURI: nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeActions(for item: RoomTimelineItemProtocol,
|
private func makeActions(for item: RoomTimelineItemProtocol, timelineKind: TimelineKind = .live) -> TimelineItemMenuActions? {
|
||||||
isMultiSelectEnabled: Bool = false,
|
|
||||||
timelineKind: TimelineKind = .live) -> TimelineItemMenuActions? {
|
|
||||||
TimelineItemMenuActionProvider(timelineItem: item,
|
TimelineItemMenuActionProvider(timelineItem: item,
|
||||||
canCurrentUserSendMessage: true,
|
canCurrentUserSendMessage: true,
|
||||||
canCurrentUserRedactSelf: true,
|
canCurrentUserRedactSelf: true,
|
||||||
@@ -131,7 +122,6 @@ struct TimelineItemMenuActionProviderTests {
|
|||||||
pinnedEventIDs: [],
|
pinnedEventIDs: [],
|
||||||
isViewSourceEnabled: true,
|
isViewSourceEnabled: true,
|
||||||
areThreadsEnabled: true,
|
areThreadsEnabled: true,
|
||||||
isMultiSelectEnabled: isMultiSelectEnabled,
|
|
||||||
timelineKind: timelineKind,
|
timelineKind: timelineKind,
|
||||||
emojiProvider: EmojiProvider(appSettings: .volatile()))
|
emojiProvider: EmojiProvider(appSettings: .volatile()))
|
||||||
.makeActions()
|
.makeActions()
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 Element Creations Ltd.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||||
|
// Please see LICENSE files in the repository root for full details.
|
||||||
|
//
|
||||||
|
|
||||||
|
@testable import ElementX
|
||||||
|
import Testing
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
struct TimelineItemsSelectionTests {
|
||||||
|
@Test
|
||||||
|
func selectedItemsFollowTheTimelineNotTheSelection() {
|
||||||
|
let items: [RoomTimelineItemProtocol] = (1...5).map { makeTextItem(eventID: "$\($0)") }
|
||||||
|
|
||||||
|
let ordered = items.selectedItems(["$5", "$1", "$3"])
|
||||||
|
|
||||||
|
#expect(ordered.map(\.id) == [items[0].id, items[2].id, items[4].id])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func selectedItemsSkipUnforwardableAndUnknownEvents() {
|
||||||
|
let text = makeTextItem(eventID: "$1")
|
||||||
|
let redacted = RedactedRoomTimelineItem(id: .event(uniqueID: .init("2"), eventOrTransactionID: .eventID("$2")),
|
||||||
|
body: "Message removed",
|
||||||
|
timestamp: .mock,
|
||||||
|
isOutgoing: false,
|
||||||
|
isEditable: false,
|
||||||
|
canBeRepliedTo: false,
|
||||||
|
sender: .init(id: "@alice:matrix.org"))
|
||||||
|
let separator = SeparatorRoomTimelineItem(id: .virtual(uniqueID: .init("separator")), timestamp: .mock)
|
||||||
|
|
||||||
|
let items: [RoomTimelineItemProtocol] = [separator, redacted, text]
|
||||||
|
|
||||||
|
let ordered = items.selectedItems(["$1", "$2", "$missing"])
|
||||||
|
|
||||||
|
#expect(ordered.map(\.id) == [text.id])
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
private func makeTextItem(eventID: String) -> TextRoomTimelineItem {
|
||||||
|
.init(id: .event(uniqueID: .init(eventID), eventOrTransactionID: .eventID(eventID)),
|
||||||
|
timestamp: .mock,
|
||||||
|
isOutgoing: false,
|
||||||
|
isEditable: false,
|
||||||
|
canBeRepliedTo: true,
|
||||||
|
sender: .init(id: "@alice:matrix.org"),
|
||||||
|
content: .init(body: eventID))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -690,7 +690,7 @@ final class TimelineViewModelTests {
|
|||||||
// MARK: - Selection
|
// MARK: - Selection
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func selectMenuActionEntersSelection() async throws {
|
func forwardMenuActionStartsSelection() async throws {
|
||||||
let items = [TextRoomTimelineItem(eventID: "$1"), TextRoomTimelineItem(eventID: "$2")]
|
let items = [TextRoomTimelineItem(eventID: "$1"), TextRoomTimelineItem(eventID: "$2")]
|
||||||
let viewModel = makeSelectionViewModel(items: items)
|
let viewModel = makeSelectionViewModel(items: items)
|
||||||
|
|
||||||
@@ -700,22 +700,89 @@ final class TimelineViewModelTests {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .selectMessages))
|
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .forward(itemID: items[0].id)))
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
|
|
||||||
#expect(viewModel.state.selection.isActive)
|
#expect(viewModel.state.messageSelection.isActive)
|
||||||
#expect(viewModel.state.selection.selectedEventIDs == ["$1"])
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func selectIsIgnoredWhenFlagIsOff() {
|
func forwardMenuActionForwardsTheMessageWhenFlagIsOff() async throws {
|
||||||
let items = [TextRoomTimelineItem(eventID: "$1")]
|
let items = [TextRoomTimelineItem(eventID: "$1")]
|
||||||
let viewModel = makeViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)))
|
let viewModel = makeViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)))
|
||||||
|
|
||||||
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .selectMessages))
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
if case .displayMessageForwarding(let forwardingPayload) = action {
|
||||||
|
return forwardingPayload.ids == [items[0].id] && forwardingPayload.contents.count == 1
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .forward(itemID: items[0].id)))
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
#expect(!viewModel.state.selection.isActive)
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func forwardMenuActionStartsSelectionInThePinnedTimeline() {
|
||||||
|
let items = [TextRoomTimelineItem(eventID: "$1")]
|
||||||
|
let viewModel = makeSelectionViewModel(timelineController: TimelineControllerMock(.init(timelineKind: .pinned, timelineItems: items)))
|
||||||
|
|
||||||
|
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .forward(itemID: items[0].id)))
|
||||||
|
|
||||||
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$1"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func forwardMenuActionForwardsTheMessageInTheMediaTimeline() async throws {
|
||||||
|
let items = [TextRoomTimelineItem(eventID: "$1")]
|
||||||
|
let viewModel = makeSelectionViewModel(timelineController: TimelineControllerMock(.init(timelineKind: .media(.mediaFilesScreen), timelineItems: items)))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .displayMessageForwarding(let forwardingPayload) = action {
|
||||||
|
return forwardingPayload.ids == [items[0].id]
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: items[0].id, action: .forward(itemID: items[0].id)))
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func forwardSelectionUsesTimelineOrder() async throws {
|
||||||
|
let items = (1...4).map { TextRoomTimelineItem(eventID: "$\($0)") }
|
||||||
|
let viewModel = makeSelectionViewModel(items: items)
|
||||||
|
|
||||||
|
// Select the last message first, then the second one.
|
||||||
|
startSelection(items[3].id, in: viewModel)
|
||||||
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
|
|
||||||
|
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||||
|
if case .displayMessageForwarding(let forwardingPayload) = action {
|
||||||
|
return forwardingPayload.ids == [items[1].id, items[3].id] && forwardingPayload.contents.count == 2
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
viewModel.process(viewAction: .forwardMessageSelection)
|
||||||
|
try await deferred.fulfill()
|
||||||
|
|
||||||
|
// The selection is kept until the forwarding completes, so cancelling the picker returns to it.
|
||||||
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$2", "$4"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
func forwardingCompletionClearsTheSelection() {
|
||||||
|
let items = [TextRoomTimelineItem(eventID: "$1"), TextRoomTimelineItem(eventID: "$2")]
|
||||||
|
let viewModel = makeSelectionViewModel(items: items)
|
||||||
|
|
||||||
|
startSelection(items[0].id, in: viewModel)
|
||||||
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
|
viewModel.clearMessageSelection()
|
||||||
|
|
||||||
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -724,33 +791,33 @@ final class TimelineViewModelTests {
|
|||||||
let viewModel = makeSelectionViewModel(items: items)
|
let viewModel = makeSelectionViewModel(items: items)
|
||||||
|
|
||||||
// Toggling before entering the selection does nothing.
|
// Toggling before entering the selection does nothing.
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[0].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[0].id))
|
||||||
#expect(!viewModel.state.selection.isActive)
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[1].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
#expect(viewModel.state.selection.selectedEventIDs == ["$1", "$2"])
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$1", "$2"])
|
||||||
#expect(viewModel.state.selection.count == 2)
|
#expect(viewModel.state.messageSelection.count == 2)
|
||||||
|
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[0].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[0].id))
|
||||||
#expect(viewModel.state.selection.selectedEventIDs == ["$2"])
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$2"])
|
||||||
|
|
||||||
// Deselecting the last item ends the selection.
|
// Deselecting the last item ends the selection.
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[1].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
#expect(!viewModel.state.selection.isActive)
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func clearSelectionEndsTheSelection() {
|
func clearMessageSelectionEndsTheSelection() {
|
||||||
let items = [TextRoomTimelineItem(eventID: "$1"), TextRoomTimelineItem(eventID: "$2")]
|
let items = [TextRoomTimelineItem(eventID: "$1"), TextRoomTimelineItem(eventID: "$2")]
|
||||||
let viewModel = makeSelectionViewModel(items: items)
|
let viewModel = makeSelectionViewModel(items: items)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[1].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
viewModel.process(viewAction: .clearSelection)
|
viewModel.process(viewAction: .clearMessageSelection)
|
||||||
|
|
||||||
#expect(!viewModel.state.selection.isActive)
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
#expect(viewModel.state.selection.selectedEventIDs.isEmpty)
|
#expect(viewModel.state.messageSelection.selectedEventIDs.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -777,33 +844,34 @@ final class TimelineViewModelTests {
|
|||||||
canBeRepliedTo: true,
|
canBeRepliedTo: true,
|
||||||
sender: .init(id: "@bob:matrix.org"),
|
sender: .init(id: "@bob:matrix.org"),
|
||||||
content: .init(body: "Sending"))
|
content: .init(body: "Sending"))
|
||||||
let nonSelectableItems: [RoomTimelineItemProtocol] = [state, redacted, localEcho]
|
let poll = PollRoomTimelineItem.mock(poll: .emptyDisclosed)
|
||||||
|
let nonSelectableItems: [RoomTimelineItemProtocol] = [state, redacted, localEcho, poll]
|
||||||
let viewModel = makeSelectionViewModel(items: [text] + nonSelectableItems)
|
let viewModel = makeSelectionViewModel(items: [text] + nonSelectableItems)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: state.id))
|
startSelection(state.id, in: viewModel)
|
||||||
#expect(!viewModel.state.selection.isActive)
|
#expect(!viewModel.state.messageSelection.isActive)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: text.id))
|
startSelection(text.id, in: viewModel)
|
||||||
for item in nonSelectableItems {
|
for item in nonSelectableItems {
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: item.id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: item.id))
|
||||||
}
|
}
|
||||||
#expect(viewModel.state.selection.selectedEventIDs == ["$1"])
|
#expect(viewModel.state.messageSelection.selectedEventIDs == ["$1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
func selectionIsLimited() {
|
func selectionIsLimited() {
|
||||||
let items = (0...TimelineSelectionState.limit).map { TextRoomTimelineItem(eventID: "$\($0)") }
|
let items = (0...TimelineMessageSelectionState.limit).map { TextRoomTimelineItem(eventID: "$\($0)") }
|
||||||
let userIndicatorController = UserIndicatorControllerMock()
|
let userIndicatorController = UserIndicatorControllerMock()
|
||||||
let viewModel = makeSelectionViewModel(items: items, userIndicatorController: userIndicatorController)
|
let viewModel = makeSelectionViewModel(items: items, userIndicatorController: userIndicatorController)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
for item in items.dropFirst() {
|
for item in items.dropFirst() {
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: item.id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: item.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#expect(viewModel.state.selection.count == TimelineSelectionState.limit)
|
#expect(viewModel.state.messageSelection.count == TimelineMessageSelectionState.limit)
|
||||||
#expect(viewModel.state.selection.isAtLimit)
|
#expect(viewModel.state.messageSelection.isAtLimit)
|
||||||
#expect(!viewModel.state.selection.contains(items.last?.id.eventID))
|
#expect(!viewModel.state.messageSelection.contains(items.last?.id.eventID))
|
||||||
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 1)
|
#expect(userIndicatorController.submitIndicatorDelayCallsCount == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,9 +881,9 @@ final class TimelineViewModelTests {
|
|||||||
let timelineController = TimelineControllerMock(.init(timelineItems: items))
|
let timelineController = TimelineControllerMock(.init(timelineItems: items))
|
||||||
let viewModel = makeSelectionViewModel(timelineController: timelineController)
|
let viewModel = makeSelectionViewModel(timelineController: timelineController)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
viewModel.process(viewAction: .toggleSelection(itemID: items[1].id))
|
viewModel.process(viewAction: .toggleMessageSelection(itemID: items[1].id))
|
||||||
#expect(viewModel.state.selection.count == 2)
|
#expect(viewModel.state.messageSelection.count == 2)
|
||||||
|
|
||||||
// The first message gets redacted by someone else.
|
// The first message gets redacted by someone else.
|
||||||
let redacted = RedactedRoomTimelineItem(id: items[0].id,
|
let redacted = RedactedRoomTimelineItem(id: items[0].id,
|
||||||
@@ -825,7 +893,7 @@ final class TimelineViewModelTests {
|
|||||||
isEditable: false,
|
isEditable: false,
|
||||||
canBeRepliedTo: false,
|
canBeRepliedTo: false,
|
||||||
sender: .init(id: "@alice:matrix.org"))
|
sender: .init(id: "@alice:matrix.org"))
|
||||||
let deferred = deferFulfillment(viewModel.context.$viewState) { $0.selection.selectedEventIDs == ["$2"] }
|
let deferred = deferFulfillment(viewModel.context.$viewState) { $0.messageSelection.selectedEventIDs == ["$2"] }
|
||||||
timelineController.callbacks.send(.updatedTimelineItems(timelineItems: [redacted, items[1]], isSwitchingTimelines: false))
|
timelineController.callbacks.send(.updatedTimelineItems(timelineItems: [redacted, items[1]], isSwitchingTimelines: false))
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
@@ -836,10 +904,10 @@ final class TimelineViewModelTests {
|
|||||||
let timelineController = TimelineControllerMock(.init(timelineItems: items))
|
let timelineController = TimelineControllerMock(.init(timelineItems: items))
|
||||||
let viewModel = makeSelectionViewModel(timelineController: timelineController)
|
let viewModel = makeSelectionViewModel(timelineController: timelineController)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
#expect(viewModel.state.selection.isActive)
|
#expect(viewModel.state.messageSelection.isActive)
|
||||||
|
|
||||||
let deferred = deferFulfillment(viewModel.context.$viewState) { !$0.selection.isActive }
|
let deferred = deferFulfillment(viewModel.context.$viewState) { !$0.messageSelection.isActive }
|
||||||
timelineController.callbacks.send(.updatedTimelineItems(timelineItems: items, isSwitchingTimelines: true))
|
timelineController.callbacks.send(.updatedTimelineItems(timelineItems: items, isSwitchingTimelines: true))
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
@@ -851,10 +919,10 @@ final class TimelineViewModelTests {
|
|||||||
appSettings.messageMultiSelectEnabled = true
|
appSettings.messageMultiSelectEnabled = true
|
||||||
let viewModel = makeViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)), appSettings: appSettings)
|
let viewModel = makeViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)), appSettings: appSettings)
|
||||||
|
|
||||||
viewModel.process(viewAction: .startSelection(itemID: items[0].id))
|
startSelection(items[0].id, in: viewModel)
|
||||||
#expect(viewModel.state.selection.isActive)
|
#expect(viewModel.state.messageSelection.isActive)
|
||||||
|
|
||||||
let deferred = deferFulfillment(viewModel.context.$viewState) { !$0.selection.isEnabled && !$0.selection.isActive }
|
let deferred = deferFulfillment(viewModel.context.$viewState) { !$0.messageSelection.isEnabled && !$0.messageSelection.isActive }
|
||||||
appSettings.messageMultiSelectEnabled = false
|
appSettings.messageMultiSelectEnabled = false
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
@@ -880,6 +948,11 @@ final class TimelineViewModelTests {
|
|||||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Starts a selection the way the app does, by choosing Forward on the item.
|
||||||
|
private func startSelection(_ itemID: TimelineItemIdentifier, in viewModel: TimelineViewModel) {
|
||||||
|
viewModel.process(viewAction: .handleTimelineItemMenuAction(itemID: itemID, action: .forward(itemID: itemID)))
|
||||||
|
}
|
||||||
|
|
||||||
private func makeSelectionViewModel(items: [RoomTimelineItemProtocol],
|
private func makeSelectionViewModel(items: [RoomTimelineItemProtocol],
|
||||||
userIndicatorController: UserIndicatorControllerProtocol = UserIndicatorControllerMock()) -> TimelineViewModel {
|
userIndicatorController: UserIndicatorControllerProtocol = UserIndicatorControllerMock()) -> TimelineViewModel {
|
||||||
makeSelectionViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)),
|
makeSelectionViewModel(timelineController: TimelineControllerMock(.init(timelineItems: items)),
|
||||||
|
|||||||
Reference in New Issue
Block a user