diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index db486a6bc..be00b9bf5 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 071A017E415AD378F2961B11 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 227AC5D71A4CE43512062243 /* URL.swift */; }; 0728314DD51AC3819F818EA8 /* LogLevel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2711E5996016ABD6EAAEB58A /* LogLevel.swift */; }; 07376A5274822EB45CC320C7 /* InvitedRoomProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A21027F05874B1BCC3E452B /* InvitedRoomProxyMock.swift */; }; + 0743CF689EBDAAF1CC0B4283 /* DeclineAndBlockScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011AFA4990C585D157829679 /* DeclineAndBlockScreenViewModel.swift */; }; 07756D532EFE33DD1FA258E5 /* GeoURITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A7ED2EF5BDBAD2A7DBC4636 /* GeoURITests.swift */; }; 077CB230153E072C94B1E6C3 /* AppAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D65BCC659FD9087E49B3C25 /* AppAppearance.swift */; }; 07CC13C5729C24255348CBBD /* ElementCallWidgetDriver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 309AD8BAE6437C31BA7157BF /* ElementCallWidgetDriver.swift */; }; @@ -267,6 +268,7 @@ 33F1FB19F222BA9930AB1A00 /* RoomListFiltersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6372DD10DED30E7AD7BCE21 /* RoomListFiltersView.swift */; }; 340D39DB87F3800D53A6A621 /* EmojiPickerScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00245D40CD90FD71D6A05239 /* EmojiPickerScreen.swift */; }; 34357B287357BC0B9715DD51 /* UserAgentBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2529D434C750ED78ADF1ED /* UserAgentBuilder.swift */; }; + 34390DAE0C574DAD30CCA7D9 /* DeclineAndBlockScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ADF12A50186B75C68017B61 /* DeclineAndBlockScreenViewModelTests.swift */; }; 34433A509DFEC93579B3B35B /* AdvancedSettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18CC37B97E77838609CFFE7 /* AdvancedSettingsScreen.swift */; }; 3467FEE8210D301FF1B77001 /* UserIndicatorControllerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7893780A1FD6E3F38B3E9049 /* UserIndicatorControllerMock.swift */; }; 34C752A73717C691582DC6C7 /* UnsupportedRoomTimelineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1B8500C152BC59445647DA8 /* UnsupportedRoomTimelineItem.swift */; }; @@ -331,6 +333,7 @@ 414F50CFCFEEE2611127DCFB /* RestorationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3558A15CFB934F9229301527 /* RestorationToken.swift */; }; 41C5DA0C06F30311A221E85B /* ClientSDKMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EAF4A49F3ACD8BB8B0D2371 /* ClientSDKMock.swift */; }; 41CE5E1289C8768FC5B6490C /* RoomTimelineItemViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C2D52E36AD614B3C003EF6 /* RoomTimelineItemViewState.swift */; }; + 41D03E23B5DC6D633632E4D8 /* DeclineAndBlockScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA38C9B58693A49A3032552 /* DeclineAndBlockScreenCoordinator.swift */; }; 41DFDD212D1BE57CA50D783B /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 0DD568A494247444A4B56031 /* Kingfisher */; }; 41F553349AF44567184822D8 /* APNSPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94D670124FC3E84F23A62CCF /* APNSPayload.swift */; }; 4219391CD2351E410554B3E8 /* AggregratedReaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B858A61F2A570DFB8DE570A7 /* AggregratedReaction.swift */; }; @@ -538,6 +541,7 @@ 68184EF36396424FE19A727D /* MediaLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFCE895ECFFA53FEE64D62B /* MediaLoader.swift */; }; 6832733838C57A7D3FE8FEB5 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 78A5A8DE1E2B09C978C7F3B0 /* KeychainAccess */; }; 6851B077B4C913CC12DB6E77 /* AppLockFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCE93F0CBF0D96B77111C413 /* AppLockFlowCoordinator.swift */; }; + 68B2DD307C57ECFABBB05323 /* DeclineAndBlockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 127D1947BA9C6CA62E3D03EC /* DeclineAndBlockScreen.swift */; }; 695825D20A761C678809345D /* MessageForwardingScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52135BD9E0E7A091688F627A /* MessageForwardingScreenModels.swift */; }; 69A9B430397C15075D86193F /* UserPropertiesExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66AFD800AF033D8B0D11191A /* UserPropertiesExt.swift */; }; 69B3C6010B42010F591FC3CB /* RoomRolesAndPermissionsScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C1AF829F12FDC99717082D9 /* RoomRolesAndPermissionsScreenViewModel.swift */; }; @@ -971,6 +975,7 @@ C0090506A52A1991BAF4BA68 /* NotificationSettingsChatType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07579F9C29001E40715F3014 /* NotificationSettingsChatType.swift */; }; C022284E2774A5E1EF683B4D /* FileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04DF593C3F7AF4B2FBAEB05D /* FileManager.swift */; }; C02DE5F62C81FB9E173C3D2F /* TimelineMediaPreviewDataSourceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0AD0C652385F69FA90FAF5 /* TimelineMediaPreviewDataSourceTests.swift */; }; + C02E295B34725A1688FCF5F0 /* DeclineAndBlockScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = B68B31232312AFC844440BFE /* DeclineAndBlockScreenModels.swift */; }; C051475DFF4C8EBDDF4DC8E4 /* StartChatScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = B99E13633862847D8B7E2815 /* StartChatScreenModels.swift */; }; C08AAE7563E0722C9383F51C /* RoomMembersListScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B8E176484A89BAC389D4076 /* RoomMembersListScreen.swift */; }; C097D5453640E27D397943CB /* TargetConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D829FD8958376614504B18 /* TargetConfiguration.swift */; }; @@ -1240,6 +1245,7 @@ F7932A3F075B0D3F24DEECB5 /* VoiceMessagePreviewComposer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE807361805463F5AEDD1CA /* VoiceMessagePreviewComposer.swift */; }; F7BC744FFA7FE248FAE7F570 /* UserIndicatorToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F57C8022B8A871A1DCD1750A /* UserIndicatorToastView.swift */; }; F7D709D7ECABE46641BB8B6B /* PHGPostHogProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CEEAE1BFAACD6C96B6DB731 /* PHGPostHogProtocol.swift */; }; + F7DA19B5122AD8FA8F91B753 /* DeclineAndBlockScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951F277E0585E50AC91987C8 /* DeclineAndBlockScreenViewModelProtocol.swift */; }; F833D5B5BE6707F961FA88DB /* SecureBackupController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1119E9C63AE530252640D2 /* SecureBackupController.swift */; }; F86102DC2C68BBBB0521BAAE /* SoftLogoutScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BB385E148DE55C85C0A02D6 /* SoftLogoutScreenModels.swift */; }; F8B2F5CBCF2A0E0798E8D646 /* TimelineViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB5B00A014307CE37B2812CD /* TimelineViewModelProtocol.swift */; }; @@ -1356,6 +1362,7 @@ 00245D40CD90FD71D6A05239 /* EmojiPickerScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPickerScreen.swift; sourceTree = ""; }; 00AFC5F08734C2EA4EE79C59 /* IdentityConfirmationScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityConfirmationScreen.swift; sourceTree = ""; }; 00E5B2CBEF8F96424F095508 /* RoomDetailsEditScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetailsEditScreenViewModelTests.swift; sourceTree = ""; }; + 011AFA4990C585D157829679 /* DeclineAndBlockScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenViewModel.swift; sourceTree = ""; }; 012A284622B32052015F1F89 /* ReadMarkerRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadMarkerRoomTimelineView.swift; sourceTree = ""; }; 018194CAFBE80720FECCEDEE /* ZoomTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZoomTransition.swift; sourceTree = ""; }; 01B795AAAB7B8747FE2FF311 /* LogViewerScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogViewerScreenModels.swift; sourceTree = ""; }; @@ -1445,6 +1452,7 @@ 1222DB76B917EB8A55365BA5 /* target.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = target.yml; sourceTree = ""; }; 127A57D053CE8C87B5EFB089 /* Consumable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Consumable.swift; sourceTree = ""; }; 127C8472672A5BA09EF1ACF8 /* CurrentValuePublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentValuePublisher.swift; sourceTree = ""; }; + 127D1947BA9C6CA62E3D03EC /* DeclineAndBlockScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreen.swift; sourceTree = ""; }; 128501375217576AF0FE3E92 /* RoomAttachmentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomAttachmentPicker.swift; sourceTree = ""; }; 12B09A94C519227264A41208 /* RoomMembershipDetailsProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomMembershipDetailsProxy.swift; sourceTree = ""; }; 12FD5280AF55AB7F50F8E47D /* preview_avatar_room.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = preview_avatar_room.jpg; sourceTree = ""; }; @@ -1576,6 +1584,7 @@ 2A5C6FBF97B6EED3D4FA5EFF /* AttributedStringBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedStringBuilder.swift; sourceTree = ""; }; 2AB2C848BB9A7A9B618B7B89 /* TextBasedRoomTimelineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBasedRoomTimelineTests.swift; sourceTree = ""; }; 2AC3FDB58F57386741A4FC7F /* DeactivateAccountScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeactivateAccountScreenViewModel.swift; sourceTree = ""; }; + 2ADF12A50186B75C68017B61 /* DeclineAndBlockScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenViewModelTests.swift; sourceTree = ""; }; 2AE807361805463F5AEDD1CA /* VoiceMessagePreviewComposer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessagePreviewComposer.swift; sourceTree = ""; }; 2AE83A3DD63BCFBB956FE5CB /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = nl; path = nl.lproj/Localizable.stringsdict; sourceTree = ""; }; 2AF715D4FD4710EBB637D661 /* SettingsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreenViewModelProtocol.swift; sourceTree = ""; }; @@ -2071,6 +2080,7 @@ 94028A227645FA880B966211 /* WaveformSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaveformSource.swift; sourceTree = ""; }; 94D670124FC3E84F23A62CCF /* APNSPayload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APNSPayload.swift; sourceTree = ""; }; 9501D11B4258DFA33BA3B40F /* ServerSelectionScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreenModels.swift; sourceTree = ""; }; + 951F277E0585E50AC91987C8 /* DeclineAndBlockScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenViewModelProtocol.swift; sourceTree = ""; }; 955336CBD5ED73C792D1F580 /* EncryptionAuthenticity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionAuthenticity.swift; sourceTree = ""; }; 95A2E4BD7C0CAD25EF924A4C /* GeneratedPreviewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedPreviewTests.swift; sourceTree = ""; }; 95BAC0F6C9644336E9567EE6 /* NSRegularExpresion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSRegularExpresion.swift; sourceTree = ""; }; @@ -2236,6 +2246,7 @@ B63B69F9A2BC74DD40DC75C8 /* AdvancedSettingsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsScreenViewModel.swift; sourceTree = ""; }; B6404166CBF5CC88673FF9E2 /* RoomDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetails.swift; sourceTree = ""; }; B655A536341D2695158C6664 /* AuthenticationClientBuilderFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationClientBuilderFactory.swift; sourceTree = ""; }; + B68B31232312AFC844440BFE /* DeclineAndBlockScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenModels.swift; sourceTree = ""; }; B6A293D06BAB2B7A17D9314B /* VoiceMessageRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageRoomTimelineView.swift; sourceTree = ""; }; B6C585CE1F721A2770C70D47 /* TimelineControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineControllerProtocol.swift; sourceTree = ""; }; B6E4AB573FAEBB7B853DD04C /* AppHooks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppHooks.swift; sourceTree = ""; }; @@ -2351,6 +2362,7 @@ CCF71646898A2F720C5BFDF5 /* RoomDirectorySearchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchScreenViewModel.swift; sourceTree = ""; }; CD469F7513574341181F7EAA /* ServerSelectionScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionScreen.swift; sourceTree = ""; }; CD6613DE16AD26B3A74DA1F5 /* LocationRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineItemContent.swift; sourceTree = ""; }; + CDA38C9B58693A49A3032552 /* DeclineAndBlockScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclineAndBlockScreenCoordinator.swift; sourceTree = ""; }; CDB3227C7A74B734924942E9 /* RoomSummaryProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryProvider.swift; sourceTree = ""; }; CDE3F3911FF7CC639BDE5844 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; CEE20623EB4A9B88FB29F2BA /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/SAS.strings; sourceTree = ""; }; @@ -3478,6 +3490,18 @@ path = QRCodeLoginScreen; sourceTree = ""; }; + 3E1CCC4B607946CE90B4A827 /* DeclineAndBlockScreen */ = { + isa = PBXGroup; + children = ( + CDA38C9B58693A49A3032552 /* DeclineAndBlockScreenCoordinator.swift */, + B68B31232312AFC844440BFE /* DeclineAndBlockScreenModels.swift */, + 011AFA4990C585D157829679 /* DeclineAndBlockScreenViewModel.swift */, + 951F277E0585E50AC91987C8 /* DeclineAndBlockScreenViewModelProtocol.swift */, + BC8F2F197AFDABE63B2E2CA7 /* View */, + ); + path = DeclineAndBlockScreen; + sourceTree = ""; + }; 3E535010B850B53DDD3CFF2A /* PinnedEventsTimelineScreen */ = { isa = PBXGroup; children = ( @@ -4246,6 +4270,7 @@ 69D42EE0102D2857933625DD /* CreateRoomViewModelTests.swift */, 3B5E97E9615A158C76B2AB77 /* DateTests.swift */, D77F75B3E9F99864048A422A /* DeactivateAccountScreenViewModelTests.swift */, + 2ADF12A50186B75C68017B61 /* DeclineAndBlockScreenViewModelTests.swift */, 6D0A27607AB09784C8501B5C /* DeveloperOptionsScreenViewModelTests.swift */, 906451FB8CF27C628152BF7A /* EditRoomAddressScreenViewModelTests.swift */, 099F2D36C141D845A445B1E6 /* EmojiProviderTests.swift */, @@ -5284,6 +5309,14 @@ path = ServerConfirmationScreen; sourceTree = ""; }; + BC8F2F197AFDABE63B2E2CA7 /* View */ = { + isa = PBXGroup; + children = ( + 127D1947BA9C6CA62E3D03EC /* DeclineAndBlockScreen.swift */, + ); + path = View; + sourceTree = ""; + }; BDCEF7C3BF6D09F5611CFC8B /* SecureBackup */ = { isa = PBXGroup; children = ( @@ -5731,6 +5764,7 @@ 90DC2E28718955ED87AD1456 /* CreatePollScreen */, C18958141C8ED6D778F779A4 /* CreateRoom */, 6C708A9F46EDE1105C640335 /* DeactivateAccountScreen */, + 3E1CCC4B607946CE90B4A827 /* DeclineAndBlockScreen */, 45F2BCFD6E9A6F040CC20582 /* EditRoomAddressScreen */, F5A65D1D3B83593598DC278D /* EmojiPickerScreen */, 8656AFF06650360A5D0695FF /* EncryptionReset */, @@ -6723,6 +6757,7 @@ D3FD96913D2B1AAA3149DAC7 /* CreateRoomViewModelTests.swift in Sources */, CD0088B763CD970CF1CBF8CB /* DateTests.swift in Sources */, 80F6C8EFCA4564B67F0D34B0 /* DeactivateAccountScreenViewModelTests.swift in Sources */, + 34390DAE0C574DAD30CCA7D9 /* DeclineAndBlockScreenViewModelTests.swift in Sources */, 864C69CF951BF36D25BE0C03 /* DeveloperOptionsScreenViewModelTests.swift in Sources */, EDB6915EC953BB2A44AA608E /* EditRoomAddressScreenViewModelTests.swift in Sources */, 25618589E0DE0F1E95FC7B5C /* EmojiProviderTests.swift in Sources */, @@ -7049,6 +7084,11 @@ 07F6382E29845D235BFA3308 /* DeactivateAccountScreenModels.swift in Sources */, C9ABF75A43F2D26F1D9A1F27 /* DeactivateAccountScreenViewModel.swift in Sources */, 4AD2B5426DBED97196AA4783 /* DeactivateAccountScreenViewModelProtocol.swift in Sources */, + 68B2DD307C57ECFABBB05323 /* DeclineAndBlockScreen.swift in Sources */, + 41D03E23B5DC6D633632E4D8 /* DeclineAndBlockScreenCoordinator.swift in Sources */, + C02E295B34725A1688FCF5F0 /* DeclineAndBlockScreenModels.swift in Sources */, + 0743CF689EBDAAF1CC0B4283 /* DeclineAndBlockScreenViewModel.swift in Sources */, + F7DA19B5122AD8FA8F91B753 /* DeclineAndBlockScreenViewModelProtocol.swift in Sources */, EE8491AD81F47DF3C192497B /* DecorationTimelineItemProtocol.swift in Sources */, 5780E444F405AA1304E1C23E /* DeveloperOptionsScreen.swift in Sources */, 5DD85A0FE3D85AEC3C7EFE36 /* DeveloperOptionsScreenCoordinator.swift in Sources */, diff --git a/ElementX/Sources/Application/AppSettings.swift b/ElementX/Sources/Application/AppSettings.swift index 659b6fb46..47e0df3c9 100644 --- a/ElementX/Sources/Application/AppSettings.swift +++ b/ElementX/Sources/Application/AppSettings.swift @@ -57,6 +57,7 @@ final class AppSettings { case enableOnlySignedDeviceIsolationMode case knockingEnabled case reportRoomEnabled + case reportInviteEnabled } private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier @@ -333,6 +334,9 @@ final class AppSettings { @UserPreference(key: UserDefaultsKeys.reportRoomEnabled, defaultValue: false, storageType: .userDefaults(store)) var reportRoomEnabled + @UserPreference(key: UserDefaultsKeys.reportInviteEnabled, defaultValue: false, storageType: .userDefaults(store)) + var reportInviteEnabled + #endif // MARK: - Shared diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 810a9ad96..1bf5fcba8 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -419,6 +419,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { return .reportRoom(previousState: fromState) case (.reportRoom(let previousState), .dismissReportRoomScreen): return previousState + + case (.joinRoomScreen, .presentDeclineAndBlockScreen): + return .declineAndBlockScreen + case (.declineAndBlockScreen, .dismissDeclineAndBlockScreen): + return .joinRoomScreen default: return nil @@ -595,6 +600,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { presentReportRoom() case (.reportRoom, .dismissReportRoomScreen, .roomDetails): break + + case (.joinRoomScreen, .presentDeclineAndBlockScreen(let userID), .declineAndBlockScreen): + presentDeclineAndBlockScreen(userID: userID) + case (.declineAndBlockScreen, .dismissDeclineAndBlockScreen, .joinRoomScreen): + break // Child flow case (_, .startChildFlow(let roomID, let via, let entryPoint), .presentingChild): @@ -799,6 +809,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { } case .cancelled: stateMachine.tryEvent(.dismissJoinRoomScreen) + case .presentDeclineAndBlock(let userID): + stateMachine.tryEvent(.presentDeclineAndBlockScreen(userID: userID)) } } .store(in: &cancellables) @@ -1551,6 +1563,30 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { } } + private func presentDeclineAndBlockScreen(userID: String) { + let stackCoordinator = NavigationStackCoordinator() + let coordinator = DeclineAndBlockScreenCoordinator(parameters: .init(userID: userID, + roomID: roomID, + clientProxy: userSession.clientProxy, + userIndicatorController: userIndicatorController)) + coordinator.actionsPublisher.sink { [weak self] action in + guard let self else { return } + switch action { + case .dismiss(let hasDeclined): + if hasDeclined { + stateMachine.tryEvent(.dismissFlow) + } + navigationStackCoordinator.setSheetCoordinator(nil) + } + } + .store(in: &cancellables) + + stackCoordinator.setRootCoordinator(coordinator) + navigationStackCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in + self?.stateMachine.tryEvent(.dismissDeclineAndBlockScreen) + } + } + // MARK: - Other flows private func startChildFlow(for roomID: String, via: [String], entryPoint: RoomFlowCoordinatorEntryPoint) async { @@ -1722,6 +1758,7 @@ private extension RoomFlowCoordinator { case mediaEventsTimeline(previousState: State) case securityAndPrivacy(previousState: State) case reportRoom(previousState: State) + case declineAndBlockScreen /// A child flow is in progress. case presentingChild(childRoomID: String, previousState: State) @@ -1811,5 +1848,8 @@ private extension RoomFlowCoordinator { case presentReportRoomScreen case dismissReportRoomScreen + + case presentDeclineAndBlockScreen(userID: String) + case dismissDeclineAndBlockScreen } } diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 243c442f0..e62879dbf 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -312,6 +312,11 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { case (.reportRoomScreen, .dismissedReportRoomScreen, .roomList): break + case (.roomList, .presentDeclineAndBlockScreen(let userID, let roomID), .declineAndBlockUserScreen): + presentDeclineAndBlockScreen(userID: userID, roomID: roomID) + case (.declineAndBlockUserScreen, .dismissedDeclineAndBlockScreen, .roomList): + break + case (.roomList(let roomListSelectedRoomID), .showShareExtensionRoomList, .shareExtensionRoomList(let sharePayload)): Task { if roomListSelectedRoomID != nil { @@ -526,6 +531,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { self.actionsSubject.send(.logout) case .logout: Task { await self.runLogoutFlow() } + case .presentDeclineAndBlock(let userID, let roomID): + stateMachine.processEvent(.presentDeclineAndBlockScreen(userID: userID, roomID: roomID)) } } .store(in: &cancellables) @@ -564,6 +571,28 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { } } + private func presentDeclineAndBlockScreen(userID: String, roomID: String) { + let stackCoordinator = NavigationStackCoordinator() + let coordinator = DeclineAndBlockScreenCoordinator(parameters: .init(userID: userID, + roomID: roomID, + clientProxy: userSession.clientProxy, + userIndicatorController: ServiceLocator.shared.userIndicatorController)) + coordinator.actionsPublisher.sink { [weak self] action in + guard let self else { return } + + switch action { + case .dismiss: + navigationSplitCoordinator.setSheetCoordinator(nil) + } + } + .store(in: &cancellables) + + stackCoordinator.setRootCoordinator(coordinator) + navigationSplitCoordinator.setSheetCoordinator(stackCoordinator) { [weak self] in + self?.stateMachine.processEvent(.dismissedDeclineAndBlockScreen) + } + } + private func runLogoutFlow() async { let secureBackupController = userSession.clientProxy.secureBackupController diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinatorStateMachine.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinatorStateMachine.swift index d8db947fa..818164012 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinatorStateMachine.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinatorStateMachine.swift @@ -47,6 +47,8 @@ class UserSessionFlowCoordinatorStateMachine { case shareExtensionRoomList(sharePayload: ShareExtensionPayload) + case declineAndBlockUserScreen(roomListSelectedRoomID: String?) + /// The selected room ID from the state if available. var roomListSelectedRoomID: String? { switch self { @@ -60,7 +62,8 @@ class UserSessionFlowCoordinatorStateMachine { .startChatScreen(let roomListSelectedRoomID), .logoutConfirmationScreen(let roomListSelectedRoomID), .roomDirectorySearchScreen(let roomListSelectedRoomID), - .reportRoomScreen(let roomListSelectedRoomID): + .reportRoomScreen(let roomListSelectedRoomID), + .declineAndBlockUserScreen(let roomListSelectedRoomID): roomListSelectedRoomID } } @@ -128,6 +131,9 @@ class UserSessionFlowCoordinatorStateMachine { case presentReportRoomScreen(roomID: String) case dismissedReportRoomScreen + + case presentDeclineAndBlockScreen(userID: String, roomID: String) + case dismissedDeclineAndBlockScreen } private let stateMachine: StateMachine @@ -206,6 +212,11 @@ class UserSessionFlowCoordinatorStateMachine { case (.reportRoomScreen(let roomListSelectedRoomID), .dismissedReportRoomScreen): return .roomList(roomListSelectedRoomID: roomListSelectedRoomID) + case(.roomList(let roomListSelectedRoomID), .presentDeclineAndBlockScreen): + return .declineAndBlockUserScreen(roomListSelectedRoomID: roomListSelectedRoomID) + case (.declineAndBlockUserScreen(let roomListSelectedRoomID), .dismissedDeclineAndBlockScreen): + return .roomList(roomListSelectedRoomID: roomListSelectedRoomID) + default: return nil } diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index a61d5c986..3cf60c159 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -3383,6 +3383,76 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable { return roomSummaryForAliasReturnValue } } + //MARK: - reportRoomForIdentifier + + var reportRoomForIdentifierReasonUnderlyingCallsCount = 0 + var reportRoomForIdentifierReasonCallsCount: Int { + get { + if Thread.isMainThread { + return reportRoomForIdentifierReasonUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = reportRoomForIdentifierReasonUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + reportRoomForIdentifierReasonUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + reportRoomForIdentifierReasonUnderlyingCallsCount = newValue + } + } + } + } + var reportRoomForIdentifierReasonCalled: Bool { + return reportRoomForIdentifierReasonCallsCount > 0 + } + var reportRoomForIdentifierReasonReceivedArguments: (identifier: String, reason: String?)? + var reportRoomForIdentifierReasonReceivedInvocations: [(identifier: String, reason: String?)] = [] + + var reportRoomForIdentifierReasonUnderlyingReturnValue: Result! + var reportRoomForIdentifierReasonReturnValue: Result! { + get { + if Thread.isMainThread { + return reportRoomForIdentifierReasonUnderlyingReturnValue + } else { + var returnValue: Result? = nil + DispatchQueue.main.sync { + returnValue = reportRoomForIdentifierReasonUnderlyingReturnValue + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + reportRoomForIdentifierReasonUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + reportRoomForIdentifierReasonUnderlyingReturnValue = newValue + } + } + } + } + var reportRoomForIdentifierReasonClosure: ((String, String?) async -> Result)? + + func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result { + reportRoomForIdentifierReasonCallsCount += 1 + reportRoomForIdentifierReasonReceivedArguments = (identifier: identifier, reason: reason) + DispatchQueue.main.async { + self.reportRoomForIdentifierReasonReceivedInvocations.append((identifier: identifier, reason: reason)) + } + if let reportRoomForIdentifierReasonClosure = reportRoomForIdentifierReasonClosure { + return await reportRoomForIdentifierReasonClosure(identifier, reason) + } else { + return reportRoomForIdentifierReasonReturnValue + } + } //MARK: - loadUserDisplayName var loadUserDisplayNameUnderlyingCallsCount = 0 diff --git a/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenCoordinator.swift b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenCoordinator.swift new file mode 100644 index 000000000..a92997f7d --- /dev/null +++ b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenCoordinator.swift @@ -0,0 +1,60 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +// periphery:ignore:all - this is just a reportInvite remove this comment once generating the final file + +import Combine +import SwiftUI + +struct DeclineAndBlockScreenCoordinatorParameters { + let userID: String + let roomID: String + let clientProxy: ClientProxyProtocol + let userIndicatorController: UserIndicatorControllerProtocol +} + +enum DeclineAndBlockScreenCoordinatorAction { + case dismiss(hasDeclined: Bool) +} + +final class DeclineAndBlockScreenCoordinator: CoordinatorProtocol { + private let parameters: DeclineAndBlockScreenCoordinatorParameters + private let viewModel: DeclineAndBlockScreenViewModelProtocol + + private var cancellables = Set() + + private let actionsSubject: PassthroughSubject = .init() + var actionsPublisher: AnyPublisher { + actionsSubject.eraseToAnyPublisher() + } + + init(parameters: DeclineAndBlockScreenCoordinatorParameters) { + self.parameters = parameters + + viewModel = DeclineAndBlockScreenViewModel(userID: parameters.userID, + roomID: parameters.roomID, + clientProxy: parameters.clientProxy, + userIndicatorController: parameters.userIndicatorController) + } + + func start() { + viewModel.actionsPublisher.sink { [weak self] action in + MXLog.info("Coordinator: received view model action: \(action)") + + guard let self else { return } + switch action { + case .dismiss(let hasDeclined): + actionsSubject.send(.dismiss(hasDeclined: hasDeclined)) + } + } + .store(in: &cancellables) + } + + func toPresentable() -> AnyView { + AnyView(DeclineAndBlockScreen(context: viewModel.context)) + } +} diff --git a/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenModels.swift b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenModels.swift new file mode 100644 index 000000000..32dbab116 --- /dev/null +++ b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenModels.swift @@ -0,0 +1,31 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Foundation + +enum DeclineAndBlockScreenViewModelAction { + case dismiss(hasDeclined: Bool) +} + +struct DeclineAndBlockScreenViewState: BindableState { + var bindings = DeclineAndBlockScreenViewStateBindings() + + var isDeclineDisabled: Bool { + !bindings.shouldBlockUser && !bindings.shouldReport + } +} + +struct DeclineAndBlockScreenViewStateBindings { + var shouldBlockUser = true + var shouldReport = false + var reportReason = "" +} + +enum DeclineAndBlockScreenViewAction { + case decline + case dismiss +} diff --git a/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModel.swift b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModel.swift new file mode 100644 index 000000000..142f2d469 --- /dev/null +++ b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModel.swift @@ -0,0 +1,99 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Combine +import SwiftUI + +typealias DeclineAndBlockScreenViewModelType = StateStoreViewModel + +class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, DeclineAndBlockScreenViewModelProtocol { + let userID: String + let roomID: String + let clientProxy: ClientProxyProtocol + let userIndicatorController: UserIndicatorControllerProtocol + + private let actionsSubject: PassthroughSubject = .init() + var actionsPublisher: AnyPublisher { + actionsSubject.eraseToAnyPublisher() + } + + init(userID: String, + roomID: String, + clientProxy: ClientProxyProtocol, + userIndicatorController: UserIndicatorControllerProtocol) { + self.userID = userID + self.roomID = roomID + self.clientProxy = clientProxy + self.userIndicatorController = userIndicatorController + super.init(initialViewState: DeclineAndBlockScreenViewState()) + } + + // MARK: - Public + + override func process(viewAction: DeclineAndBlockScreenViewAction) { + MXLog.info("View model: received view action: \(viewAction)") + + switch viewAction { + case .dismiss: + actionsSubject.send(.dismiss(hasDeclined: false)) + case .decline: + Task { await decline() } + } + } + + private func decline() async { + showLoadingIndicator() + guard case let .invited(roomProxy) = await clientProxy.roomForIdentifier(roomID) else { + MXLog.error("DeclineAndBlockScreenViewModel: Unable to find an invited room for identifier \(roomID)") + hideLoadingIndicator() + showError() + return + } + + let result = await roomProxy.rejectInvitation() + hideLoadingIndicator() + + // TODO: Check with design how to handle the error cases and what message to present for success and error + switch result { + case .success: + if state.bindings.shouldReport { + Task { + await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isBlank ? nil : state.bindings.reportReason) + } + } + + if state.bindings.shouldBlockUser { + Task { + await clientProxy.ignoreUser(userID) + } + } + + actionsSubject.send(.dismiss(hasDeclined: true)) + case .failure: + userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown)) + } + } + + private static let loadingIndicator = "\(DeclineAndBlockScreenViewModel.self).loadingIndicator" + + private func showLoadingIndicator() { + userIndicatorController.submitIndicator(.init(id: Self.loadingIndicator, + type: .modal(progress: .indeterminate, + interactiveDismissDisabled: true, + allowsInteraction: false), + title: L10n.commonLoading, + persistent: true)) + } + + private func hideLoadingIndicator() { + userIndicatorController.retractIndicatorWithId(Self.loadingIndicator) + } + + private func showError() { + userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown)) + } +} diff --git a/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModelProtocol.swift b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModelProtocol.swift new file mode 100644 index 000000000..7b91f889b --- /dev/null +++ b/ElementX/Sources/Screens/DeclineAndBlockScreen/DeclineAndBlockScreenViewModelProtocol.swift @@ -0,0 +1,14 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Combine + +@MainActor +protocol DeclineAndBlockScreenViewModelProtocol { + var actionsPublisher: AnyPublisher { get } + var context: DeclineAndBlockScreenViewModelType.Context { get } +} diff --git a/ElementX/Sources/Screens/DeclineAndBlockScreen/View/DeclineAndBlockScreen.swift b/ElementX/Sources/Screens/DeclineAndBlockScreen/View/DeclineAndBlockScreen.swift new file mode 100644 index 000000000..f4009619e --- /dev/null +++ b/ElementX/Sources/Screens/DeclineAndBlockScreen/View/DeclineAndBlockScreen.swift @@ -0,0 +1,89 @@ +// +// Copyright 2022-2024 New Vector 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 + +struct DeclineAndBlockScreen: View { + @ObservedObject var context: DeclineAndBlockScreenViewModel.Context + + var body: some View { + Form { + blockUserSection + reportSection + if context.shouldReport { + reportReasonSection + } + } + .compoundList() + .navigationTitle(L10n.screenDeclineAndBlockTitle) + .navigationBarTitleDisplayMode(.inline) + .toolbar { toolbar } + .animation(.elementDefault, value: context.shouldReport) + } + + private var blockUserSection: some View { + Section { + ListRow(label: .plain(title: L10n.screenDeclineAndBlockBlockUserOptionTitle), + kind: .toggle($context.shouldBlockUser)) + } + } + + private var reportSection: some View { + Section { + ListRow(label: .plain(title: L10n.actionReportRoom), + kind: .toggle($context.shouldReport)) + } + } + + private var reportReasonSection: some View { + Section { + ListRow(label: .plain(title: ""), + kind: .textField(text: $context.reportReason, axis: .vertical)) + .lineLimit(4, reservesSpace: true) + } + } + + @ToolbarContentBuilder + private var toolbar: some ToolbarContent { + ToolbarItem(placement: .cancellationAction) { + Button(L10n.actionCancel) { + context.send(viewAction: .dismiss) + } + } + + ToolbarItem(placement: .confirmationAction) { + Button(L10n.actionDecline) { + context.send(viewAction: .decline) + } + .disabled(context.viewState.isDeclineDisabled) + } + } +} + +// MARK: - Previews + +struct DeclineAndBlockScreen_Previews: PreviewProvider, TestablePreview { + static let viewModel = DeclineAndBlockScreenViewModel(userID: "@alice:matrix.org", + roomID: "!room:matrix.org", + clientProxy: ClientProxyMock(.init()), + userIndicatorController: UserIndicatorControllerMock()) + + static var previews: some View { + NavigationStack { + DeclineAndBlockScreen(context: viewModel.context) + } + .previewDisplayName("Default") + NavigationStack { + DeclineAndBlockScreen(context: viewModel.context) + .onAppear { + viewModel.context.shouldReport = true + } + } + .previewDisplayName("Report room selected") + } +} diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift index 2e36b54ac..a528626ed 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenCoordinator.swift @@ -18,6 +18,7 @@ enum HomeScreenCoordinatorAction { case presentRoom(roomIdentifier: String) case presentRoomDetails(roomIdentifier: String) case presentReportRoom(roomIdentifier: String) + case presentDeclineAndBlock(userID: String, roomID: String) case roomLeft(roomIdentifier: String) case presentSettingsScreen case presentFeedbackScreen @@ -81,6 +82,8 @@ final class HomeScreenCoordinator: CoordinatorProtocol { actionsSubject.send(.logoutWithoutConfirmation) case .logout: actionsSubject.send(.logout) + case .presentDeclineAndBlock(let userID, let roomID): + actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID)) } } .store(in: &cancellables) diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift index 69c9bbeb4..23b64d746 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift @@ -13,6 +13,7 @@ enum HomeScreenViewModelAction: Equatable { case presentRoom(roomIdentifier: String) case presentRoomDetails(roomIdentifier: String) case presentReportRoom(roomIdentifier: String) + case presentDeclineAndBlock(userID: String, roomID: String) case roomLeft(roomIdentifier: String) case presentSecureBackupSettings case presentRecoveryKeyScreen diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift index de252dd59..390cc7b63 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift @@ -426,11 +426,24 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol let title = room.isDirect ? L10n.screenInvitesDeclineDirectChatTitle : L10n.screenInvitesDeclineChatTitle let message = room.isDirect ? L10n.screenInvitesDeclineDirectChatMessage(roomPlaceholder) : L10n.screenInvitesDeclineChatMessage(roomPlaceholder) - state.bindings.alertInfo = .init(id: UUID(), - title: title, - message: message, - primaryButton: .init(title: L10n.actionDecline, role: .destructive) { Task { await self.declineInvite(roomID: room.id) } }, - secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil)) + if appSettings.reportInviteEnabled, let userID = room.inviter?.id { + state.bindings.alertInfo = .init(id: UUID(), + title: title, + message: message, + primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), + secondaryButton: .init(title: L10n.actionDeclineAndBlock, role: .destructive) { [weak self] in self?.declineAndBlockInvite(userID: userID, roomID: roomID) }, + verticalButtons: [.init(title: L10n.actionDecline) { [weak self] in Task { await self?.declineInvite(roomID: room.id) } }]) + } else { + state.bindings.alertInfo = .init(id: UUID(), + title: title, + message: message, + primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), + secondaryButton: .init(title: L10n.actionDecline, role: .destructive) { [weak self] in Task { await self?.declineInvite(roomID: room.id) } }) + } + } + + private func declineAndBlockInvite(userID: String, roomID: String) { + actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID)) } private func declineInvite(roomID: String) async { diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift index d6fa2421f..bae7dfb46 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenCoordinator.swift @@ -20,6 +20,7 @@ struct JoinRoomScreenCoordinatorParameters { enum JoinRoomScreenCoordinatorAction { case joined case cancelled + case presentDeclineAndBlock(userID: String) } final class JoinRoomScreenCoordinator: CoordinatorProtocol { @@ -51,6 +52,8 @@ final class JoinRoomScreenCoordinator: CoordinatorProtocol { actionsSubject.send(.joined) case .dismiss: actionsSubject.send(.cancelled) + case .presentDeclineAndBlock(let userID): + actionsSubject.send(.presentDeclineAndBlock(userID: userID)) } } .store(in: &cancellables) diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenModels.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenModels.swift index f5c608410..4d1a587ce 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenModels.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenModels.swift @@ -7,9 +7,10 @@ import Foundation -enum JoinRoomScreenViewModelAction { +enum JoinRoomScreenViewModelAction: Equatable { case joined case dismiss + case presentDeclineAndBlock(userID: String) } enum JoinRoomScreenMode: Equatable { diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift index 3e958e200..caf401169 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift @@ -323,11 +323,15 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo } private func showDeclineAndBlockConfirmationAlert(userID: String) { - state.bindings.alertInfo = .init(id: .declineInviteAndBlock, - title: L10n.screenJoinRoomDeclineAndBlockAlertTitle, - message: L10n.screenJoinRoomDeclineAndBlockAlertMessage(userID), - primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), - secondaryButton: .init(title: L10n.screenJoinRoomDeclineAndBlockAlertConfirmation, role: .destructive) { Task { await self.declineAndBlock(userID: userID) } }) + if appSettings.reportInviteEnabled { + actionsSubject.send(.presentDeclineAndBlock(userID: userID)) + } else { + state.bindings.alertInfo = .init(id: .declineInviteAndBlock, + title: L10n.screenJoinRoomDeclineAndBlockAlertTitle, + message: L10n.screenJoinRoomDeclineAndBlockAlertMessage(userID), + primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil), + secondaryButton: .init(title: L10n.screenJoinRoomDeclineAndBlockAlertConfirmation, role: .destructive) { Task { await self.declineAndBlock(userID: userID) } }) + } } private func declineAndBlock(userID: String) async { diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift index bcd92a627..210dd6938 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/DeveloperOptionsScreenModels.swift @@ -45,6 +45,7 @@ protocol DeveloperOptionsProtocol: AnyObject { var elementCallBaseURLOverride: URL? { get set } var knockingEnabled: Bool { get set } var reportRoomEnabled: Bool { get set } + var reportInviteEnabled: Bool { get set } } extension AppSettings: DeveloperOptionsProtocol { } diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index c15eb60c8..32bca9660 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -68,6 +68,10 @@ struct DeveloperOptionsScreen: View { Text("Report rooms") Text("Report API might not work properly") } + Toggle(isOn: $context.reportInviteEnabled) { + Text("Report invites") + Text("Report API might not work properly") + } } Section { diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 4379e3dcf..618a8bdd0 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -529,6 +529,20 @@ class ClientProxy: ClientProxyProtocol { func roomSummaryForAlias(_ alias: String) -> RoomSummary? { staticRoomSummaryProvider.roomListPublisher.value.first { $0.canonicalAlias == alias || $0.alternativeAliases.contains(alias) } } + + func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result { + do { + guard let room = try client.getRoom(roomId: identifier) else { + MXLog.error("Failed reporting room with identifier: \(identifier), room not in local store") + return .failure(.roomNotInLocalStore) + } + try await room.reportRoom(reason: reason) + return .success(()) + } catch { + MXLog.error("Failed reporting room with identifier: \(identifier), with error: \(error)") + return .failure(.sdkError(error)) + } + } func loadUserDisplayName() async -> Result { do { diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 4c66f64b5..980127fdd 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -38,6 +38,7 @@ enum ClientProxyError: Error { case roomPreviewIsPrivate case failedRetrievingUserIdentity case failedResolvingRoomAlias + case roomNotInLocalStore } enum SlidingSyncConstants { @@ -152,6 +153,9 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func roomSummaryForAlias(_ alias: String) -> RoomSummary? + /// Will only work for rooms that are in our room list/local store + func reportRoomForIdentifier(_ identifier: String, reason: String?) async -> Result + @discardableResult func loadUserDisplayName() async -> Result func setUserDisplayName(_ name: String) async -> Result diff --git a/PreviewTests/Sources/GeneratedPreviewTests.swift b/PreviewTests/Sources/GeneratedPreviewTests.swift index f0a897054..537e3136d 100644 --- a/PreviewTests/Sources/GeneratedPreviewTests.swift +++ b/PreviewTests/Sources/GeneratedPreviewTests.swift @@ -143,6 +143,12 @@ extension PreviewTests { } } + func testDeclineAndBlockScreen() async throws { + for (index, preview) in DeclineAndBlockScreen_Previews._allPreviews.enumerated() { + try await assertSnapshots(matching: preview, step: index) + } + } + func testEditRoomAddressScreen() async throws { for (index, preview) in EditRoomAddressScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-en-GB.png new file mode 100644 index 000000000..dce779b28 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:331907bdf035f86c3d347dee7b9ed185ed5017166ed9e8b461350a3b42568d96 +size 99116 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-pseudo.png new file mode 100644 index 000000000..cae6e9a11 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a7a6b83541d8118cb2f6ef72ede4ad7da26e143f3fff128162f8a86cc79d1f4 +size 101990 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-en-GB.png new file mode 100644 index 000000000..e6ecd5b70 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7afb522b666d6ee0053565805eeecfa2de03931c84e0fa3a8881d987c3289873 +size 50827 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-pseudo.png new file mode 100644 index 000000000..6be2c4ea6 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Default-iPhone-16-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ecf718f65e63626ece27b13bfaf90eb1a4a66aefcaebf38bd9290f6e9bda3fa +size 52405 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-en-GB.png new file mode 100644 index 000000000..a23a4b12f --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:60c89d39f8c797146967f6419b4b778daf1a23e96887135f94bd05b748d5f5b8 +size 99560 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-pseudo.png new file mode 100644 index 000000000..0a5b67e6b --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPad-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bb8474771644359632424dabb6f9b2062044bcb9f4d6c1721d01267cb28cecb +size 102525 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-en-GB.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-en-GB.png new file mode 100644 index 000000000..e438a7716 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-en-GB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f4043f23a826059c0e5c8ab412e302d3316ea01bc2ea0f6821240c214d1479a +size 52656 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-pseudo.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-pseudo.png new file mode 100644 index 000000000..cee6627f0 --- /dev/null +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/declineAndBlockScreen.Report-room-selected-iPhone-16-pseudo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05925f7f9857ea05c41cf73e085a9f9cc14cf99a86bfbbb190c394a9ab01cb4b +size 54307 diff --git a/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift b/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift new file mode 100644 index 000000000..2441b9911 --- /dev/null +++ b/UnitTests/Sources/DeclineAndBlockScreenViewModelTests.swift @@ -0,0 +1,19 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import XCTest + +@testable import ElementX + +@MainActor +class DeclineAndBlockScreenViewModelTests: XCTestCase { + var viewModel: DeclineAndBlockScreenViewModelProtocol! + + var context: DeclineAndBlockScreenViewModelType.Context { + viewModel.context + } +} diff --git a/UnitTests/Sources/HomeScreenViewModelTests.swift b/UnitTests/Sources/HomeScreenViewModelTests.swift index b9741f09a..bc32e8d0a 100644 --- a/UnitTests/Sources/HomeScreenViewModelTests.swift +++ b/UnitTests/Sources/HomeScreenViewModelTests.swift @@ -321,7 +321,7 @@ class HomeScreenViewModelTests: XCTestCase { return .invited(roomProxy) } - context.viewState.bindings.alertInfo?.primaryButton.action?() + context.viewState.bindings.alertInfo?.secondaryButton?.action?() await fulfillment(of: [rejectExpectation], timeout: 1.0) XCTAssertEqual(appSettings.seenInvites, [invitedRoomIDs[1]])