From a11b5496c3bffe25c6343feb7c279365e7d7975a Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 20 Aug 2024 16:13:27 +0300 Subject: [PATCH] Introduce a new RoomProxyType and treat rooms differently based on their membership state --- ElementX.xcodeproj/project.pbxproj | 20 +- .../Sources/Application/AppCoordinator.swift | 13 +- .../RoomFlowCoordinator.swift | 26 +- ...omRolesAndPermissionsFlowCoordinator.swift | 4 +- .../UserSessionFlowCoordinator.swift | 4 +- ElementX/Sources/Mocks/ClientProxyMock.swift | 2 +- .../Mocks/Generated/GeneratedMocks.swift | 5753 +++++++++-------- .../Mocks/Generated/SDKGeneratedMocks.swift | 76 + ...xyMock.swift => JoinedRoomProxyMock.swift} | 17 +- .../Screens/CallScreen/View/CallScreen.swift | 2 +- .../HomeScreen/HomeScreenViewModel.swift | 66 +- .../InviteUsersScreenModels.swift | 2 +- .../JoinRoomScreenViewModel.swift | 35 +- .../MediaUploadPreviewScreenCoordinator.swift | 2 +- .../MediaUploadPreviewScreenViewModel.swift | 4 +- .../View/MediaUploadPreviewScreen.swift | 2 +- .../MessageForwardingScreenViewModel.swift | 2 +- ...innedEventsTimelineScreenCoordinator.swift | 2 +- .../View/PinnedEventsTimelineScreen.swift | 2 +- .../ReportContentScreenCoordinator.swift | 2 +- .../ReportContentScreenViewModel.swift | 4 +- .../View/ReportContentScreen.swift | 2 +- ...omChangePermissionsScreenCoordinator.swift | 2 +- ...RoomChangePermissionsScreenViewModel.swift | 4 +- .../View/RoomChangePermissionsScreen.swift | 2 +- .../RoomChangeRolesScreenCoordinator.swift | 2 +- .../RoomChangeRolesScreenViewModel.swift | 4 +- .../View/RoomChangeRolesScreen.swift | 2 +- .../RoomDetailsEditScreenCoordinator.swift | 2 +- .../RoomDetailsEditScreenViewModel.swift | 4 +- .../View/RoomDetailsEditScreen.swift | 12 +- .../RoomDetailsScreenCoordinator.swift | 2 +- .../RoomDetailsScreenViewModel.swift | 4 +- .../View/RoomDetailsScreen.swift | 52 +- .../RoomMemberDetailsScreenCoordinator.swift | 2 +- .../RoomMemberDetailsScreenViewModel.swift | 4 +- .../View/RoomMemberDetailsScreen.swift | 2 +- .../RoomMembersListScreenCoordinator.swift | 2 +- .../RoomMembersListScreenViewModel.swift | 4 +- .../RoomMembersListManageMemberSheet.swift | 2 +- .../View/RoomMembersListScreen.swift | 8 +- .../RoomMembersListScreenMemberCell.swift | 4 +- ...otificationSettingsScreenCoordinator.swift | 2 +- ...mNotificationSettingsScreenViewModel.swift | 4 +- ...otificationSettingsCustomSectionView.swift | 4 +- .../View/RoomNotificationSettingsScreen.swift | 4 +- ...otificationSettingsUserDefinedScreen.swift | 4 +- .../View/RoomPollsHistoryScreen.swift | 4 +- ...RolesAndPermissionsScreenCoordinator.swift | 2 +- ...omRolesAndPermissionsScreenViewModel.swift | 4 +- .../View/RoomRolesAndPermissionsScreen.swift | 2 +- .../CompletionSuggestionService.swift | 4 +- .../RoomScreen/RoomScreenCoordinator.swift | 2 +- .../RoomScreen/RoomScreenViewModel.swift | 6 +- .../Screens/RoomScreen/View/RoomScreen.swift | 6 +- ...icationSettingsEditScreenCoordinator.swift | 2 +- ...ificationSettingsEditScreenViewModel.swift | 2 +- .../Timeline/TimelineInteractionHandler.swift | 4 +- .../Screens/Timeline/TimelineViewModel.swift | 6 +- .../ReadReceiptsSummaryView.swift | 2 +- .../TimelineReadReceiptsView.swift | 2 +- .../HighlightedTimelineItemModifier.swift | 2 +- .../Screens/Timeline/View/TimelineView.swift | 4 +- .../Sources/Services/Client/ClientProxy.swift | 87 +- .../Services/Client/ClientProxyProtocol.swift | 2 +- .../ComposerDraft/ComposerDraftService.swift | 4 +- .../ElementCallConfiguration.swift | 4 +- .../ElementCall/ElementCallService.swift | 2 +- .../Polls/PollInteractionHandler.swift | 4 +- .../Services/Room/InvitedRoomProxy.swift | 111 + ...{RoomProxy.swift => JoinedRoomProxy.swift} | 83 +- .../Services/Room/RoomProxyProtocol.swift | 60 +- .../MockRoomTimelineController.swift | 2 +- .../RoomTimelineController.swift | 4 +- .../RoomTimelineControllerFactory.swift | 4 +- ...oomTimelineControllerFactoryProtocol.swift | 4 +- .../VoiceMessage/VoiceMessageRecorder.swift | 2 +- .../VoiceMessageRecorderProtocol.swift | 2 +- .../UITests/UITestsAppCoordinator.swift | 34 +- .../CompletionSuggestionServiceTests.swift | 6 +- .../Sources/HomeScreenViewModelTests.swift | 10 +- .../Sources/InviteUsersViewModelTests.swift | 2 +- ...essageForwardingScreenViewModelTests.swift | 2 +- UnitTests/Sources/PillContextTests.swift | 6 +- .../Sources/ReportContentViewModelTests.swift | 4 +- ...hangePermissionsScreenViewModelTests.swift | 4 +- .../RoomChangeRolesScreenViewModelTests.swift | 4 +- .../RoomDetailsEditScreenViewModelTests.swift | 4 +- .../Sources/RoomDetailsViewModelTests.swift | 40 +- .../Sources/RoomFlowCoordinatorTests.swift | 4 +- .../RoomMemberDetailsViewModelTests.swift | 4 +- .../RoomMembersListScreenViewModelTests.swift | 4 +- ...ficationSettingsScreenViewModelTests.swift | 10 +- ...esAndPermissionsScreenViewModelTests.swift | 4 +- .../Sources/RoomScreenViewModelTests.swift | 8 +- .../Sources/TimelineViewModelTests.swift | 20 +- .../Sources/VoiceMessageRecorderTests.swift | 12 +- 97 files changed, 3536 insertions(+), 3255 deletions(-) rename ElementX/Sources/Mocks/{RoomProxyMock.swift => JoinedRoomProxyMock.swift} (96%) create mode 100644 ElementX/Sources/Services/Room/InvitedRoomProxy.swift rename ElementX/Sources/Services/Room/{RoomProxy.swift => JoinedRoomProxy.swift} (96%) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 7492aaf173..b58403f003 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -169,6 +169,7 @@ 256D76972BA3254F7CB7F88B /* LocationAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAD8234D0E9C9B12BF9F240B /* LocationAnnotation.swift */; }; 25C4C1100B6EA79F5CC7CBB5 /* AppLockSetupPINScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 989D7380D9C86B3A10D30B13 /* AppLockSetupPINScreenViewModelTests.swift */; }; 260FFC1475EE94F641C3F3F9 /* PollFormScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A40F1985065500F0E7F61A27 /* PollFormScreenViewModelProtocol.swift */; }; + 261261778DEFAEFC042B875E /* JoinedRoomProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07C6B0B087FE6601C3F77816 /* JoinedRoomProxy.swift */; }; 2689D22EF1D10D22B0A4DAEA /* NotificationContentBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BB243B26D54EF1A0C422C0 /* NotificationContentBuilder.swift */; }; 273AB64B9A26B61C51858867 /* AsyncSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73A07BAEDD74C48795A996A /* AsyncSequence.swift */; }; 274CE3C986841D15FD530BF5 /* ShimmerModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97CE98208321C4D66E363612 /* ShimmerModifier.swift */; }; @@ -352,7 +353,6 @@ 4EAC427267424192964B16B3 /* AppSettingsHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13BE9781699FB510E9263192 /* AppSettingsHook.swift */; }; 4F2DF6138E87A4B8C2488CA3 /* VoiceMessageCacheProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A84EE187D0C772E18A4E39 /* VoiceMessageCacheProtocol.swift */; }; 4FC085B1E5D1EB804495E2F4 /* MockMediaProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD6E621CC5E6D4830D96D2D /* MockMediaProvider.swift */; }; - 4FC1EFE4968A259CBBACFAFB /* RoomProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = A65F140F9FE5E8D4DAEFF354 /* RoomProxy.swift */; }; 4FDC8A9764CFDA90CE035725 /* Duration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FB2253D36E81E045E1CB432 /* Duration.swift */; }; 4FE688FE9375B2FBF424146A /* TextBasedRoomTimelineViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6EA0D8B0BBD8805F7D5A133 /* TextBasedRoomTimelineViewProtocol.swift */; }; 4FF90E2242DBD596E1ED2E27 /* AppCoordinatorStateMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 077D7C3BE199B6E5DDEC07EC /* AppCoordinatorStateMachine.swift */; }; @@ -552,6 +552,7 @@ 7C384A8E54A4B60A14CDE8E5 /* WaitlistScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F1E7F9C2BE8BB751037826 /* WaitlistScreenCoordinator.swift */; }; 7C6376192F578E0BA801BFEC /* AnalyticsSettingsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42C64A14EE89928207E3B42B /* AnalyticsSettingsScreenModels.swift */; }; 7CD16990BA843BE9ED639129 /* ImageRoomTimelineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DFE4453AB0B34C203447162 /* ImageRoomTimelineItem.swift */; }; + 7D249465ED00988EEEC14E05 /* JoinedRoomProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 867DC9530C42F7B5176BE465 /* JoinedRoomProxyMock.swift */; }; 7D261B5119E78CC8E771CA15 /* GlobalSearchScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74653BE903970C0E36867D46 /* GlobalSearchScreenCoordinator.swift */; }; 7D58B4F46CAA9A7C3E4C6A30 /* UserDetailsEditScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88410BD213FDF9B28E8B671F /* UserDetailsEditScreen.swift */; }; 7D6DC832DE7A3DE874E2E9BC /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 7B6BC3219ADD8AA0311D2B86 /* SnapshotTesting */; }; @@ -610,6 +611,7 @@ 89658A44C9FC19B58FD1C226 /* ServerConfirmationScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F08776C48FFB47CACF64ED10 /* ServerConfirmationScreenViewModelTests.swift */; }; 899359A4D1147601F6C4E364 /* PillConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8D34E94AB07128DB73D6C7 /* PillConstants.swift */; }; 899793EFC63DF93C3E0141E7 /* RoomMemberDetailsScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FA60F848D1C14F873F9621A /* RoomMemberDetailsScreenCoordinator.swift */; }; + 89B909AC66B96FA054EF3C14 /* InvitedRoomProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E95B3BDB80531C85CD50AE6 /* InvitedRoomProxy.swift */; }; 8A0BD60CA4A6004DB06B5403 /* MediaUploadingPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669F35C505ACE1110589F875 /* MediaUploadingPreprocessor.swift */; }; 8A5064CAC8E5F3B18645621D /* CallNotificationRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD6E082B0507FB28F966516A /* CallNotificationRoomTimelineView.swift */; }; 8A83D715940378B9BA9F739E /* RoomInviterLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EB58E4E8D6D634C246AD5C2 /* RoomInviterLabel.swift */; }; @@ -833,7 +835,6 @@ BCC864190651B3A3CF51E4DF /* MediaFileHandleProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC1D382565A4E9CAC2F14EA /* MediaFileHandleProxy.swift */; }; BD0BE20DBCE31253AE4490A1 /* RoomListFiltersEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC1DDB2293A51EA4C2739351 /* RoomListFiltersEmptyStateView.swift */; }; BD11E639CF566A9DA8FCA717 /* RoundedLabelItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE7C80EF77AD102053D3646E /* RoundedLabelItem.swift */; }; - BD203FC6A7AE7637EA003643 /* RoomProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ABDE6F66532CBEB0E016F94 /* RoomProxyMock.swift */; }; BD6685592716CA957D7BAAC4 /* RoomChangeRolesScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9B45D584D232CB9E5C7734 /* RoomChangeRolesScreenSelectedItem.swift */; }; BD782053BE4C3D2F0BDE5699 /* ServiceLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F95CADD0A5DBD76B990FCB /* ServiceLocator.swift */; }; BDA68E8D95B2B24B28825B8B /* LoginScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C368CAB3063EF275357ECD4 /* LoginScreenViewModel.swift */; }; @@ -1210,6 +1211,7 @@ 06FAE373A7F20780BA84B59C /* MessageForwardingScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageForwardingScreenCoordinator.swift; sourceTree = ""; }; 07579F9C29001E40715F3014 /* NotificationSettingsChatType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingsChatType.swift; sourceTree = ""; }; 077D7C3BE199B6E5DDEC07EC /* AppCoordinatorStateMachine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCoordinatorStateMachine.swift; sourceTree = ""; }; + 07C6B0B087FE6601C3F77816 /* JoinedRoomProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinedRoomProxy.swift; sourceTree = ""; }; 08283301736A6FE9D558B2CB /* AppLockScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockScreenViewModelProtocol.swift; sourceTree = ""; }; 0833F51229E166BCA141D004 /* RoomRolesAndPermissionsFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomRolesAndPermissionsFlowCoordinator.swift; sourceTree = ""; }; 086B997409328F091EBA43CE /* RoomScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomScreenUITests.swift; sourceTree = ""; }; @@ -1235,6 +1237,7 @@ 0DBB08A95EFA668F2CF27211 /* AppLockSetupFlowCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockSetupFlowCoordinator.swift; sourceTree = ""; }; 0DF5CBAF69BDF5DF31C661E1 /* IntentionalMentions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntentionalMentions.swift; sourceTree = ""; }; 0E8BDC092D817B68CD9040C5 /* UserSessionStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSessionStore.swift; sourceTree = ""; }; + 0E95B3BDB80531C85CD50AE6 /* InvitedRoomProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvitedRoomProxy.swift; sourceTree = ""; }; 0EE9EAF0309A2A1D67D8FAF5 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = sv; path = sv.lproj/Localizable.stringsdict; sourceTree = ""; }; 0F5567A7EF6F2AB9473236F6 /* DocumentPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentPicker.swift; sourceTree = ""; }; 0F64447FF544298A6A3BEF85 /* NotificationSettingsScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingsScreenModels.swift; sourceTree = ""; }; @@ -1280,7 +1283,6 @@ 1A4D29F2683F5772AC72406F /* MapTilerStaticMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTilerStaticMap.swift; sourceTree = ""; }; 1A7ED2EF5BDBAD2A7DBC4636 /* GeoURITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeoURITests.swift; sourceTree = ""; }; 1AB58EF0176D4CFB1040DA22 /* WaitlistScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitlistScreenViewModel.swift; sourceTree = ""; }; - 1ABDE6F66532CBEB0E016F94 /* RoomProxyMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomProxyMock.swift; sourceTree = ""; }; 1B2AC540DE619B36832A5DB5 /* LocationRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineItem.swift; sourceTree = ""; }; 1B53D6C5C0D14B04D3AB3F6E /* PillAttachmentViewProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillAttachmentViewProvider.swift; sourceTree = ""; }; 1B564D748B67A156F413CD97 /* NotificationSettingsEditScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingsEditScreenModels.swift; sourceTree = ""; }; @@ -1746,6 +1748,7 @@ 8610C1D21565C950BCA6A454 /* AppLockSetupSettingsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockSetupSettingsScreenViewModelProtocol.swift; sourceTree = ""; }; 86376BEE425704AEE197CA54 /* PillContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PillContext.swift; sourceTree = ""; }; 8642512079EEFD622E3AA66B /* BlockedUsersScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedUsersScreenModels.swift; sourceTree = ""; }; + 867DC9530C42F7B5176BE465 /* JoinedRoomProxyMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinedRoomProxyMock.swift; sourceTree = ""; }; 869A8A4632E511351BFE2EC4 /* JoinRoomScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinRoomScreen.swift; sourceTree = ""; }; 86A6F283BC574FDB96ABBB07 /* DeveloperOptionsScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperOptionsScreenViewModel.swift; sourceTree = ""; }; 86C8CE2630F54D5FE1591786 /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -1865,7 +1868,6 @@ A443FAE2EE820A5790C35C8D /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = et.lproj/Localizable.strings; sourceTree = ""; }; A4A1003A0F7A1DFB47F4E2D0 /* TimelineItemMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemMock.swift; sourceTree = ""; }; A58E93D91DE3288010390DEE /* EmojiDetectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiDetectionTests.swift; sourceTree = ""; }; - A65F140F9FE5E8D4DAEFF354 /* RoomProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomProxy.swift; sourceTree = ""; }; A69869844D2B6F5BD9AABF85 /* OIDCConfigurationProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OIDCConfigurationProxy.swift; sourceTree = ""; }; A6B19D10B102956066AF117B /* PollOptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollOptionView.swift; sourceTree = ""; }; A6B891A6DA826E2461DBB40F /* PHGPostHogConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHGPostHogConfiguration.swift; sourceTree = ""; }; @@ -2828,6 +2830,7 @@ 4E600B315B920B9687F8EE1B /* ComposerDraftServiceMock.swift */, E321E840DCC63790049984F4 /* ElementCallServiceMock.swift */, 1C7A6BBC686B1F840FA807FB /* EventTimelineItemSDKMock.swift */, + 867DC9530C42F7B5176BE465 /* JoinedRoomProxyMock.swift */, 8DA1E8F287680C8ED25EDBAC /* NetworkMonitorMock.swift */, 382B50F7E379B3DBBD174364 /* NotificationSettingsProxyMock.swift */, B2AD8A56CD37E23071A2F4BF /* PHGPostHogMock.swift */, @@ -2835,7 +2838,6 @@ 894EE8F5B399A165BA2A6634 /* RoomDirectorySearchMock.swift */, 36FD673E24FBFCFDF398716A /* RoomMemberProxyMock.swift */, F5D1BAA90F3A073D91B4F16B /* RoomNotificationSettingsProxyMock.swift */, - 1ABDE6F66532CBEB0E016F94 /* RoomProxyMock.swift */, FC83F47D2173B7538AA72E0E /* RoomSummaryProviderMock.swift */, D479DF730528153665E5782E /* RoomTimelineControllerFactoryMock.swift */, F74532E01B317C56C1BE8FA8 /* RoomTimelineProviderMock.swift */, @@ -3114,9 +3116,10 @@ 40E6246F03D1FE377BC5D963 /* Room */ = { isa = PBXGroup; children = ( + 0E95B3BDB80531C85CD50AE6 /* InvitedRoomProxy.swift */, + 07C6B0B087FE6601C3F77816 /* JoinedRoomProxy.swift */, B6404166CBF5CC88673FF9E2 /* RoomDetails.swift */, 974AEAF3FE0C577A6C04AD6E /* RoomPermissions.swift */, - A65F140F9FE5E8D4DAEFF354 /* RoomProxy.swift */, 47111410B6E659A697D472B5 /* RoomProxyProtocol.swift */, 2C0F49BD446849654C0D24E0 /* RoomMember */, 70DABA39C844CA931B829395 /* RoomSummary */, @@ -6354,11 +6357,14 @@ 61941DEE5F3834765770BE01 /* InviteUsersScreenSelectedItem.swift in Sources */, F519DE17A3A0F760307B2E6D /* InviteUsersScreenViewModel.swift in Sources */, A17FAD2EBC53E17B5FD384DB /* InviteUsersScreenViewModelProtocol.swift in Sources */, + 89B909AC66B96FA054EF3C14 /* InvitedRoomProxy.swift in Sources */, 6A54F52443EC52AC5CD772C0 /* JoinRoomScreen.swift in Sources */, AFE2AB612A1460E49578D746 /* JoinRoomScreenCoordinator.swift in Sources */, DEDBD3E9CFCC9F20CAC79881 /* JoinRoomScreenModels.swift in Sources */, EF47D802A404A53F15D5D4B6 /* JoinRoomScreenViewModel.swift in Sources */, 7B66DA4E7E5FE4D1A0FCEAA4 /* JoinRoomScreenViewModelProtocol.swift in Sources */, + 261261778DEFAEFC042B875E /* JoinedRoomProxy.swift in Sources */, + 7D249465ED00988EEEC14E05 /* JoinedRoomProxyMock.swift in Sources */, E3CA565A4B9704F191B191F0 /* JoinedRoomSize+MemberCount.swift in Sources */, 1FE593ECEC40A43789105D80 /* KeychainController.swift in Sources */, FD29471C72872F8B7580E3E1 /* KeychainControllerMock.swift in Sources */, @@ -6625,8 +6631,6 @@ 51B3B19FA5F91B455C807BA7 /* RoomPollsHistoryScreenModels.swift in Sources */, 79741C1953269FF1A211D246 /* RoomPollsHistoryScreenViewModel.swift in Sources */, F103924DED414ADFE398CE99 /* RoomPollsHistoryScreenViewModelProtocol.swift in Sources */, - 4FC1EFE4968A259CBBACFAFB /* RoomProxy.swift in Sources */, - BD203FC6A7AE7637EA003643 /* RoomProxyMock.swift in Sources */, FA9C427FFB11B1AA2DCC5602 /* RoomProxyProtocol.swift in Sources */, DC77E9DB2CFBE84A2BDF20C5 /* RoomRolesAndPermissionsFlowCoordinator.swift in Sources */, D10BA4F041DC58580A440A32 /* RoomRolesAndPermissionsScreen.swift in Sources */, diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index a4c0cee691..1da3b89caf 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -325,10 +325,15 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg guard let roomID = content.userInfo[NotificationConstants.UserInfoKey.roomIdentifier] as? String else { return } - let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) - switch await roomProxy?.timeline.sendMessage(replyText, - html: nil, - intentionalMentions: .empty) { + + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { + MXLog.error("Tried to reply in an unjoined room: \(roomID)") + return + } + + switch await roomProxy.timeline.sendMessage(replyText, + html: nil, + intentionalMentions: .empty) { case .success: break default: diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 5e5d334f4c..c024238cc7 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -20,7 +20,7 @@ import SwiftUI import UserNotifications enum RoomFlowCoordinatorAction: Equatable { - case presentCallScreen(roomProxy: RoomProxyProtocol) + case presentCallScreen(roomProxy: JoinedRoomProxyProtocol) case finished static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool { @@ -63,7 +63,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { private let analytics: AnalyticsService private let userIndicatorController: UserIndicatorControllerProtocol - private var roomProxy: RoomProxyProtocol! + private var roomProxy: JoinedRoomProxyProtocol! private var roomScreenCoordinator: RoomScreenCoordinator? private weak var joinRoomScreenCoordinator: JoinRoomScreenCoordinator? @@ -139,7 +139,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { Task { if roomProxy == nil { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { return } @@ -173,7 +173,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { } private func presentCallScreen(roomID: String) async { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { return } @@ -183,13 +183,13 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { private func handleRoomRoute(roomID: String, via: [String], focussedEventID: String? = nil, animated: Bool) async { guard roomID == self.roomID else { fatalError("Navigation route doesn't belong to this room flow.") } - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard let room = await userSession.clientProxy.roomForIdentifier(roomID) else { stateMachine.tryEvent(.presentJoinRoomScreen(via: via), userInfo: EventUserInfo(animated: animated)) return } - switch roomProxy.membership { - case .joined: + switch room { + case .joined(let roomProxy): await storeAndSubscribeToRoomProxy(roomProxy) stateMachine.tryEvent(.presentRoom(focussedEventID: focussedEventID), userInfo: EventUserInfo(animated: animated)) default: @@ -207,7 +207,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { // MARK: - Private - private func storeAndSubscribeToRoomProxy(_ roomProxy: RoomProxyProtocol) async { + private func storeAndSubscribeToRoomProxy(_ roomProxy: JoinedRoomProxyProtocol) async { if let oldRoomProxy = self.roomProxy { if oldRoomProxy.id != roomProxy.id { fatalError("Trying to create different room proxies for the same flow coordinator") @@ -216,11 +216,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { MXLog.warning("Found an existing proxy, returning.") return } - - guard roomProxy.membership == .joined else { - fatalError("Requesting room details for an unjoined room") - } - + await roomProxy.subscribeForUpdates() // Make sure not to set this until after the subscription has succeeded, otherwise the @@ -658,7 +654,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { Task { [weak self] in guard let self else { return } - if let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) { + if case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) { await storeAndSubscribeToRoomProxy(roomProxy) stateMachine.tryEvent(.presentRoom(focussedEventID: nil), userInfo: EventUserInfo(animated: animated)) @@ -1300,7 +1296,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { } } - private func inviteUsers(_ users: [String], in room: RoomProxyProtocol) { + private func inviteUsers(_ users: [String], in room: JoinedRoomProxyProtocol) { navigationStackCoordinator.setSheetCoordinator(nil) Task { diff --git a/ElementX/Sources/FlowCoordinators/RoomRolesAndPermissionsFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomRolesAndPermissionsFlowCoordinator.swift index eedf252c3f..a683c7c9b6 100644 --- a/ElementX/Sources/FlowCoordinators/RoomRolesAndPermissionsFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomRolesAndPermissionsFlowCoordinator.swift @@ -24,7 +24,7 @@ enum RoomRolesAndPermissionsFlowCoordinatorAction: Equatable { } struct RoomRolesAndPermissionsFlowCoordinatorParameters { - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let mediaProvider: MediaProviderProtocol let navigationStackCoordinator: NavigationStackCoordinator let userIndicatorController: UserIndicatorControllerProtocol @@ -32,7 +32,7 @@ struct RoomRolesAndPermissionsFlowCoordinatorParameters { } class RoomRolesAndPermissionsFlowCoordinator: FlowCoordinatorProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let navigationStackCoordinator: NavigationStackCoordinator private let mediaProvider: MediaProviderProtocol private let userIndicatorController: UserIndicatorControllerProtocol diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 53a0637ac4..9842b3ff66 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -561,14 +561,14 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { } private func presentCallScreen(roomID: String) async { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { return } presentCallScreen(roomProxy: roomProxy) } - private func presentCallScreen(roomProxy: RoomProxyProtocol) { + private func presentCallScreen(roomProxy: JoinedRoomProxyProtocol) { let colorScheme: ColorScheme = appMediator.windowManager.mainWindow.traitCollection.userInterfaceStyle == .light ? .light : .dark presentCallScreen(configuration: .init(roomProxy: roomProxy, clientProxy: userSession.clientProxy, diff --git a/ElementX/Sources/Mocks/ClientProxyMock.swift b/ElementX/Sources/Mocks/ClientProxyMock.swift index 9122ae7ed4..943fe32b7f 100644 --- a/ElementX/Sources/Mocks/ClientProxyMock.swift +++ b/ElementX/Sources/Mocks/ClientProxyMock.swift @@ -94,7 +94,7 @@ extension ClientProxyMock { return nil } - return await RoomProxyMock(.init(id: room.id, name: room.name)) + return await .joined(JoinedRoomProxyMock(.init(id: room.id, name: room.name))) } } } diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index b5c0633904..e1f88901a3 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -2681,13 +2681,13 @@ class ClientProxyMock: ClientProxyProtocol { var roomForIdentifierReceivedIdentifier: String? var roomForIdentifierReceivedInvocations: [String] = [] - var roomForIdentifierUnderlyingReturnValue: RoomProxyProtocol? - var roomForIdentifierReturnValue: RoomProxyProtocol? { + var roomForIdentifierUnderlyingReturnValue: RoomProxyType? + var roomForIdentifierReturnValue: RoomProxyType? { get { if Thread.isMainThread { return roomForIdentifierUnderlyingReturnValue } else { - var returnValue: RoomProxyProtocol?? = nil + var returnValue: RoomProxyType?? = nil DispatchQueue.main.sync { returnValue = roomForIdentifierUnderlyingReturnValue } @@ -2705,9 +2705,9 @@ class ClientProxyMock: ClientProxyProtocol { } } } - var roomForIdentifierClosure: ((String) async -> RoomProxyProtocol?)? + var roomForIdentifierClosure: ((String) async -> RoomProxyType?)? - func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? { + func roomForIdentifier(_ identifier: String) async -> RoomProxyType? { roomForIdentifierCallsCount += 1 roomForIdentifierReceivedIdentifier = identifier DispatchQueue.main.async { @@ -5213,60 +5213,80 @@ class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol { } } } -class KeychainControllerMock: KeychainControllerProtocol { - - //MARK: - setRestorationToken - - var setRestorationTokenForUsernameUnderlyingCallsCount = 0 - var setRestorationTokenForUsernameCallsCount: Int { - get { - if Thread.isMainThread { - return setRestorationTokenForUsernameUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = setRestorationTokenForUsernameUnderlyingCallsCount - } +class InvitedRoomProxyMock: InvitedRoomProxyProtocol { + var inviterCallsCount = 0 + var inviterCalled: Bool { + return inviterCallsCount > 0 + } - return returnValue! - } - } - set { - if Thread.isMainThread { - setRestorationTokenForUsernameUnderlyingCallsCount = newValue + var inviter: RoomMemberProxyProtocol? { + get async { + inviterCallsCount += 1 + if let inviterClosure = inviterClosure { + return await inviterClosure() } else { - DispatchQueue.main.sync { - setRestorationTokenForUsernameUnderlyingCallsCount = newValue - } + return underlyingInviter } } } - var setRestorationTokenForUsernameCalled: Bool { - return setRestorationTokenForUsernameCallsCount > 0 + var underlyingInviter: RoomMemberProxyProtocol? + var inviterClosure: (() async -> RoomMemberProxyProtocol?)? + var id: String { + get { return underlyingId } + set(value) { underlyingId = value } } - var setRestorationTokenForUsernameReceivedArguments: (restorationToken: RestorationToken, forUsername: String)? - var setRestorationTokenForUsernameReceivedInvocations: [(restorationToken: RestorationToken, forUsername: String)] = [] - var setRestorationTokenForUsernameClosure: ((RestorationToken, String) -> Void)? - - func setRestorationToken(_ restorationToken: RestorationToken, forUsername: String) { - setRestorationTokenForUsernameCallsCount += 1 - setRestorationTokenForUsernameReceivedArguments = (restorationToken: restorationToken, forUsername: forUsername) - DispatchQueue.main.async { - self.setRestorationTokenForUsernameReceivedInvocations.append((restorationToken: restorationToken, forUsername: forUsername)) - } - setRestorationTokenForUsernameClosure?(restorationToken, forUsername) + var underlyingId: String! + var canonicalAlias: String? + var ownUserID: String { + get { return underlyingOwnUserID } + set(value) { underlyingOwnUserID = value } } - //MARK: - restorationTokens + var underlyingOwnUserID: String! + var name: String? + var topic: String? + var avatar: RoomAvatar { + get { return underlyingAvatar } + set(value) { underlyingAvatar = value } + } + var underlyingAvatar: RoomAvatar! + var avatarURL: URL? + var isPublic: Bool { + get { return underlyingIsPublic } + set(value) { underlyingIsPublic = value } + } + var underlyingIsPublic: Bool! + var isDirect: Bool { + get { return underlyingIsDirect } + set(value) { underlyingIsDirect = value } + } + var underlyingIsDirect: Bool! + var isSpace: Bool { + get { return underlyingIsSpace } + set(value) { underlyingIsSpace = value } + } + var underlyingIsSpace: Bool! + var joinedMembersCount: Int { + get { return underlyingJoinedMembersCount } + set(value) { underlyingJoinedMembersCount = value } + } + var underlyingJoinedMembersCount: Int! + var activeMembersCount: Int { + get { return underlyingActiveMembersCount } + set(value) { underlyingActiveMembersCount = value } + } + var underlyingActiveMembersCount: Int! - var restorationTokensUnderlyingCallsCount = 0 - var restorationTokensCallsCount: Int { + //MARK: - rejectInvitation + + var rejectInvitationUnderlyingCallsCount = 0 + var rejectInvitationCallsCount: Int { get { if Thread.isMainThread { - return restorationTokensUnderlyingCallsCount + return rejectInvitationUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = restorationTokensUnderlyingCallsCount + returnValue = rejectInvitationUnderlyingCallsCount } return returnValue! @@ -5274,27 +5294,27 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - restorationTokensUnderlyingCallsCount = newValue + rejectInvitationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - restorationTokensUnderlyingCallsCount = newValue + rejectInvitationUnderlyingCallsCount = newValue } } } } - var restorationTokensCalled: Bool { - return restorationTokensCallsCount > 0 + var rejectInvitationCalled: Bool { + return rejectInvitationCallsCount > 0 } - var restorationTokensUnderlyingReturnValue: [KeychainCredentials]! - var restorationTokensReturnValue: [KeychainCredentials]! { + var rejectInvitationUnderlyingReturnValue: Result! + var rejectInvitationReturnValue: Result! { get { if Thread.isMainThread { - return restorationTokensUnderlyingReturnValue + return rejectInvitationUnderlyingReturnValue } else { - var returnValue: [KeychainCredentials]? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = restorationTokensUnderlyingReturnValue + returnValue = rejectInvitationUnderlyingReturnValue } return returnValue! @@ -5302,35 +5322,35 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - restorationTokensUnderlyingReturnValue = newValue + rejectInvitationUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - restorationTokensUnderlyingReturnValue = newValue + rejectInvitationUnderlyingReturnValue = newValue } } } } - var restorationTokensClosure: (() -> [KeychainCredentials])? + var rejectInvitationClosure: (() async -> Result)? - func restorationTokens() -> [KeychainCredentials] { - restorationTokensCallsCount += 1 - if let restorationTokensClosure = restorationTokensClosure { - return restorationTokensClosure() + func rejectInvitation() async -> Result { + rejectInvitationCallsCount += 1 + if let rejectInvitationClosure = rejectInvitationClosure { + return await rejectInvitationClosure() } else { - return restorationTokensReturnValue + return rejectInvitationReturnValue } } - //MARK: - removeRestorationTokenForUsername + //MARK: - acceptInvitation - var removeRestorationTokenForUsernameUnderlyingCallsCount = 0 - var removeRestorationTokenForUsernameCallsCount: Int { + var acceptInvitationUnderlyingCallsCount = 0 + var acceptInvitationCallsCount: Int { get { if Thread.isMainThread { - return removeRestorationTokenForUsernameUnderlyingCallsCount + return acceptInvitationUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removeRestorationTokenForUsernameUnderlyingCallsCount + returnValue = acceptInvitationUnderlyingCallsCount } return returnValue! @@ -5338,40 +5358,27 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - removeRestorationTokenForUsernameUnderlyingCallsCount = newValue + acceptInvitationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removeRestorationTokenForUsernameUnderlyingCallsCount = newValue + acceptInvitationUnderlyingCallsCount = newValue } } } } - var removeRestorationTokenForUsernameCalled: Bool { - return removeRestorationTokenForUsernameCallsCount > 0 - } - var removeRestorationTokenForUsernameReceivedUsername: String? - var removeRestorationTokenForUsernameReceivedInvocations: [String] = [] - var removeRestorationTokenForUsernameClosure: ((String) -> Void)? - - func removeRestorationTokenForUsername(_ username: String) { - removeRestorationTokenForUsernameCallsCount += 1 - removeRestorationTokenForUsernameReceivedUsername = username - DispatchQueue.main.async { - self.removeRestorationTokenForUsernameReceivedInvocations.append(username) - } - removeRestorationTokenForUsernameClosure?(username) + var acceptInvitationCalled: Bool { + return acceptInvitationCallsCount > 0 } - //MARK: - removeAllRestorationTokens - var removeAllRestorationTokensUnderlyingCallsCount = 0 - var removeAllRestorationTokensCallsCount: Int { + var acceptInvitationUnderlyingReturnValue: Result! + var acceptInvitationReturnValue: Result! { get { if Thread.isMainThread { - return removeAllRestorationTokensUnderlyingCallsCount + return acceptInvitationUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = removeAllRestorationTokensUnderlyingCallsCount + returnValue = acceptInvitationUnderlyingReturnValue } return returnValue! @@ -5379,63 +5386,164 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - removeAllRestorationTokensUnderlyingCallsCount = newValue + acceptInvitationUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - removeAllRestorationTokensUnderlyingCallsCount = newValue + acceptInvitationUnderlyingReturnValue = newValue } } } } - var removeAllRestorationTokensCalled: Bool { - return removeAllRestorationTokensCallsCount > 0 - } - var removeAllRestorationTokensClosure: (() -> Void)? + var acceptInvitationClosure: (() async -> Result)? - func removeAllRestorationTokens() { - removeAllRestorationTokensCallsCount += 1 - removeAllRestorationTokensClosure?() + func acceptInvitation() async -> Result { + acceptInvitationCallsCount += 1 + if let acceptInvitationClosure = acceptInvitationClosure { + return await acceptInvitationClosure() + } else { + return acceptInvitationReturnValue + } + } +} +class JoinedRoomProxyMock: JoinedRoomProxyProtocol { + var isEncrypted: Bool { + get { return underlyingIsEncrypted } + set(value) { underlyingIsEncrypted = value } + } + var underlyingIsEncrypted: Bool! + var isFavouriteCallsCount = 0 + var isFavouriteCalled: Bool { + return isFavouriteCallsCount > 0 } - //MARK: - containsPINCode - var containsPINCodeThrowableError: Error? - var containsPINCodeUnderlyingCallsCount = 0 - var containsPINCodeCallsCount: Int { - get { - if Thread.isMainThread { - return containsPINCodeUnderlyingCallsCount + var isFavourite: Bool { + get async { + isFavouriteCallsCount += 1 + if let isFavouriteClosure = isFavouriteClosure { + return await isFavouriteClosure() } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = containsPINCodeUnderlyingCallsCount - } + return underlyingIsFavourite + } + } + } + var underlyingIsFavourite: Bool! + var isFavouriteClosure: (() async -> Bool)? + var pinnedEventIDsCallsCount = 0 + var pinnedEventIDsCalled: Bool { + return pinnedEventIDsCallsCount > 0 + } - return returnValue! + var pinnedEventIDs: Set { + get async { + pinnedEventIDsCallsCount += 1 + if let pinnedEventIDsClosure = pinnedEventIDsClosure { + return await pinnedEventIDsClosure() + } else { + return underlyingPinnedEventIDs } } - set { - if Thread.isMainThread { - containsPINCodeUnderlyingCallsCount = newValue + } + var underlyingPinnedEventIDs: Set! + var pinnedEventIDsClosure: (() async -> Set)? + var hasOngoingCall: Bool { + get { return underlyingHasOngoingCall } + set(value) { underlyingHasOngoingCall = value } + } + var underlyingHasOngoingCall: Bool! + var activeRoomCallParticipants: [String] = [] + var membersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> { + get { return underlyingMembersPublisher } + set(value) { underlyingMembersPublisher = value } + } + var underlyingMembersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never>! + var typingMembersPublisher: CurrentValuePublisher<[String], Never> { + get { return underlyingTypingMembersPublisher } + set(value) { underlyingTypingMembersPublisher = value } + } + var underlyingTypingMembersPublisher: CurrentValuePublisher<[String], Never>! + var actionsPublisher: AnyPublisher { + get { return underlyingActionsPublisher } + set(value) { underlyingActionsPublisher = value } + } + var underlyingActionsPublisher: AnyPublisher! + var timeline: TimelineProxyProtocol { + get { return underlyingTimeline } + set(value) { underlyingTimeline = value } + } + var underlyingTimeline: TimelineProxyProtocol! + var pinnedEventsTimelineCallsCount = 0 + var pinnedEventsTimelineCalled: Bool { + return pinnedEventsTimelineCallsCount > 0 + } + + var pinnedEventsTimeline: TimelineProxyProtocol? { + get async { + pinnedEventsTimelineCallsCount += 1 + if let pinnedEventsTimelineClosure = pinnedEventsTimelineClosure { + return await pinnedEventsTimelineClosure() } else { - DispatchQueue.main.sync { - containsPINCodeUnderlyingCallsCount = newValue - } + return underlyingPinnedEventsTimeline } } } - var containsPINCodeCalled: Bool { - return containsPINCodeCallsCount > 0 + var underlyingPinnedEventsTimeline: TimelineProxyProtocol? + var pinnedEventsTimelineClosure: (() async -> TimelineProxyProtocol?)? + var id: String { + get { return underlyingId } + set(value) { underlyingId = value } } + var underlyingId: String! + var canonicalAlias: String? + var ownUserID: String { + get { return underlyingOwnUserID } + set(value) { underlyingOwnUserID = value } + } + var underlyingOwnUserID: String! + var name: String? + var topic: String? + var avatar: RoomAvatar { + get { return underlyingAvatar } + set(value) { underlyingAvatar = value } + } + var underlyingAvatar: RoomAvatar! + var avatarURL: URL? + var isPublic: Bool { + get { return underlyingIsPublic } + set(value) { underlyingIsPublic = value } + } + var underlyingIsPublic: Bool! + var isDirect: Bool { + get { return underlyingIsDirect } + set(value) { underlyingIsDirect = value } + } + var underlyingIsDirect: Bool! + var isSpace: Bool { + get { return underlyingIsSpace } + set(value) { underlyingIsSpace = value } + } + var underlyingIsSpace: Bool! + var joinedMembersCount: Int { + get { return underlyingJoinedMembersCount } + set(value) { underlyingJoinedMembersCount = value } + } + var underlyingJoinedMembersCount: Int! + var activeMembersCount: Int { + get { return underlyingActiveMembersCount } + set(value) { underlyingActiveMembersCount = value } + } + var underlyingActiveMembersCount: Int! - var containsPINCodeUnderlyingReturnValue: Bool! - var containsPINCodeReturnValue: Bool! { + //MARK: - subscribeForUpdates + + var subscribeForUpdatesUnderlyingCallsCount = 0 + var subscribeForUpdatesCallsCount: Int { get { if Thread.isMainThread { - return containsPINCodeUnderlyingReturnValue + return subscribeForUpdatesUnderlyingCallsCount } else { - var returnValue: Bool? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = containsPINCodeUnderlyingReturnValue + returnValue = subscribeForUpdatesUnderlyingCallsCount } return returnValue! @@ -5443,39 +5551,34 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - containsPINCodeUnderlyingReturnValue = newValue + subscribeForUpdatesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - containsPINCodeUnderlyingReturnValue = newValue + subscribeForUpdatesUnderlyingCallsCount = newValue } } } } - var containsPINCodeClosure: (() throws -> Bool)? + var subscribeForUpdatesCalled: Bool { + return subscribeForUpdatesCallsCount > 0 + } + var subscribeForUpdatesClosure: (() async -> Void)? - func containsPINCode() throws -> Bool { - if let error = containsPINCodeThrowableError { - throw error - } - containsPINCodeCallsCount += 1 - if let containsPINCodeClosure = containsPINCodeClosure { - return try containsPINCodeClosure() - } else { - return containsPINCodeReturnValue - } + func subscribeForUpdates() async { + subscribeForUpdatesCallsCount += 1 + await subscribeForUpdatesClosure?() } - //MARK: - setPINCode + //MARK: - subscribeToRoomInfoUpdates - var setPINCodeThrowableError: Error? - var setPINCodeUnderlyingCallsCount = 0 - var setPINCodeCallsCount: Int { + var subscribeToRoomInfoUpdatesUnderlyingCallsCount = 0 + var subscribeToRoomInfoUpdatesCallsCount: Int { get { if Thread.isMainThread { - return setPINCodeUnderlyingCallsCount + return subscribeToRoomInfoUpdatesUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setPINCodeUnderlyingCallsCount + returnValue = subscribeToRoomInfoUpdatesUnderlyingCallsCount } return returnValue! @@ -5483,43 +5586,34 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - setPINCodeUnderlyingCallsCount = newValue + subscribeToRoomInfoUpdatesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setPINCodeUnderlyingCallsCount = newValue + subscribeToRoomInfoUpdatesUnderlyingCallsCount = newValue } } } } - var setPINCodeCalled: Bool { - return setPINCodeCallsCount > 0 + var subscribeToRoomInfoUpdatesCalled: Bool { + return subscribeToRoomInfoUpdatesCallsCount > 0 } - var setPINCodeReceivedPinCode: String? - var setPINCodeReceivedInvocations: [String] = [] - var setPINCodeClosure: ((String) throws -> Void)? + var subscribeToRoomInfoUpdatesClosure: (() -> Void)? - func setPINCode(_ pinCode: String) throws { - if let error = setPINCodeThrowableError { - throw error - } - setPINCodeCallsCount += 1 - setPINCodeReceivedPinCode = pinCode - DispatchQueue.main.async { - self.setPINCodeReceivedInvocations.append(pinCode) - } - try setPINCodeClosure?(pinCode) + func subscribeToRoomInfoUpdates() { + subscribeToRoomInfoUpdatesCallsCount += 1 + subscribeToRoomInfoUpdatesClosure?() } - //MARK: - pinCode + //MARK: - timelineFocusedOnEvent - var pinCodeUnderlyingCallsCount = 0 - var pinCodeCallsCount: Int { + var timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = 0 + var timelineFocusedOnEventEventIDNumberOfEventsCallsCount: Int { get { if Thread.isMainThread { - return pinCodeUnderlyingCallsCount + return timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = pinCodeUnderlyingCallsCount + returnValue = timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount } return returnValue! @@ -5527,27 +5621,29 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - pinCodeUnderlyingCallsCount = newValue + timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - pinCodeUnderlyingCallsCount = newValue + timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = newValue } } } } - var pinCodeCalled: Bool { - return pinCodeCallsCount > 0 + var timelineFocusedOnEventEventIDNumberOfEventsCalled: Bool { + return timelineFocusedOnEventEventIDNumberOfEventsCallsCount > 0 } + var timelineFocusedOnEventEventIDNumberOfEventsReceivedArguments: (eventID: String, numberOfEvents: UInt16)? + var timelineFocusedOnEventEventIDNumberOfEventsReceivedInvocations: [(eventID: String, numberOfEvents: UInt16)] = [] - var pinCodeUnderlyingReturnValue: String? - var pinCodeReturnValue: String? { + var timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue: Result! + var timelineFocusedOnEventEventIDNumberOfEventsReturnValue: Result! { get { if Thread.isMainThread { - return pinCodeUnderlyingReturnValue + return timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue } else { - var returnValue: String?? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = pinCodeUnderlyingReturnValue + returnValue = timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue } return returnValue! @@ -5555,35 +5651,39 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - pinCodeUnderlyingReturnValue = newValue + timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - pinCodeUnderlyingReturnValue = newValue + timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue = newValue } } } } - var pinCodeClosure: (() -> String?)? + var timelineFocusedOnEventEventIDNumberOfEventsClosure: ((String, UInt16) async -> Result)? - func pinCode() -> String? { - pinCodeCallsCount += 1 - if let pinCodeClosure = pinCodeClosure { - return pinCodeClosure() + func timelineFocusedOnEvent(eventID: String, numberOfEvents: UInt16) async -> Result { + timelineFocusedOnEventEventIDNumberOfEventsCallsCount += 1 + timelineFocusedOnEventEventIDNumberOfEventsReceivedArguments = (eventID: eventID, numberOfEvents: numberOfEvents) + DispatchQueue.main.async { + self.timelineFocusedOnEventEventIDNumberOfEventsReceivedInvocations.append((eventID: eventID, numberOfEvents: numberOfEvents)) + } + if let timelineFocusedOnEventEventIDNumberOfEventsClosure = timelineFocusedOnEventEventIDNumberOfEventsClosure { + return await timelineFocusedOnEventEventIDNumberOfEventsClosure(eventID, numberOfEvents) } else { - return pinCodeReturnValue + return timelineFocusedOnEventEventIDNumberOfEventsReturnValue } } - //MARK: - removePINCode + //MARK: - redact - var removePINCodeUnderlyingCallsCount = 0 - var removePINCodeCallsCount: Int { + var redactUnderlyingCallsCount = 0 + var redactCallsCount: Int { get { if Thread.isMainThread { - return removePINCodeUnderlyingCallsCount + return redactUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removePINCodeUnderlyingCallsCount + returnValue = redactUnderlyingCallsCount } return returnValue! @@ -5591,34 +5691,29 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - removePINCodeUnderlyingCallsCount = newValue + redactUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removePINCodeUnderlyingCallsCount = newValue + redactUnderlyingCallsCount = newValue } } } } - var removePINCodeCalled: Bool { - return removePINCodeCallsCount > 0 - } - var removePINCodeClosure: (() -> Void)? - - func removePINCode() { - removePINCodeCallsCount += 1 - removePINCodeClosure?() + var redactCalled: Bool { + return redactCallsCount > 0 } - //MARK: - containsPINCodeBiometricState + var redactReceivedEventID: String? + var redactReceivedInvocations: [String] = [] - var containsPINCodeBiometricStateUnderlyingCallsCount = 0 - var containsPINCodeBiometricStateCallsCount: Int { + var redactUnderlyingReturnValue: Result! + var redactReturnValue: Result! { get { if Thread.isMainThread { - return containsPINCodeBiometricStateUnderlyingCallsCount + return redactUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = containsPINCodeBiometricStateUnderlyingCallsCount + returnValue = redactUnderlyingReturnValue } return returnValue! @@ -5626,27 +5721,39 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - containsPINCodeBiometricStateUnderlyingCallsCount = newValue + redactUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - containsPINCodeBiometricStateUnderlyingCallsCount = newValue + redactUnderlyingReturnValue = newValue } } } } - var containsPINCodeBiometricStateCalled: Bool { - return containsPINCodeBiometricStateCallsCount > 0 + var redactClosure: ((String) async -> Result)? + + func redact(_ eventID: String) async -> Result { + redactCallsCount += 1 + redactReceivedEventID = eventID + DispatchQueue.main.async { + self.redactReceivedInvocations.append(eventID) + } + if let redactClosure = redactClosure { + return await redactClosure(eventID) + } else { + return redactReturnValue + } } + //MARK: - reportContent - var containsPINCodeBiometricStateUnderlyingReturnValue: Bool! - var containsPINCodeBiometricStateReturnValue: Bool! { + var reportContentReasonUnderlyingCallsCount = 0 + var reportContentReasonCallsCount: Int { get { if Thread.isMainThread { - return containsPINCodeBiometricStateUnderlyingReturnValue + return reportContentReasonUnderlyingCallsCount } else { - var returnValue: Bool? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = containsPINCodeBiometricStateUnderlyingReturnValue + returnValue = reportContentReasonUnderlyingCallsCount } return returnValue! @@ -5654,36 +5761,29 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - containsPINCodeBiometricStateUnderlyingReturnValue = newValue + reportContentReasonUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - containsPINCodeBiometricStateUnderlyingReturnValue = newValue + reportContentReasonUnderlyingCallsCount = newValue } } } } - var containsPINCodeBiometricStateClosure: (() -> Bool)? - - func containsPINCodeBiometricState() -> Bool { - containsPINCodeBiometricStateCallsCount += 1 - if let containsPINCodeBiometricStateClosure = containsPINCodeBiometricStateClosure { - return containsPINCodeBiometricStateClosure() - } else { - return containsPINCodeBiometricStateReturnValue - } + var reportContentReasonCalled: Bool { + return reportContentReasonCallsCount > 0 } - //MARK: - setPINCodeBiometricState + var reportContentReasonReceivedArguments: (eventID: String, reason: String?)? + var reportContentReasonReceivedInvocations: [(eventID: String, reason: String?)] = [] - var setPINCodeBiometricStateThrowableError: Error? - var setPINCodeBiometricStateUnderlyingCallsCount = 0 - var setPINCodeBiometricStateCallsCount: Int { + var reportContentReasonUnderlyingReturnValue: Result! + var reportContentReasonReturnValue: Result! { get { if Thread.isMainThread { - return setPINCodeBiometricStateUnderlyingCallsCount + return reportContentReasonUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = setPINCodeBiometricStateUnderlyingCallsCount + returnValue = reportContentReasonUnderlyingReturnValue } return returnValue! @@ -5691,43 +5791,39 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - setPINCodeBiometricStateUnderlyingCallsCount = newValue + reportContentReasonUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setPINCodeBiometricStateUnderlyingCallsCount = newValue + reportContentReasonUnderlyingReturnValue = newValue } } } } - var setPINCodeBiometricStateCalled: Bool { - return setPINCodeBiometricStateCallsCount > 0 - } - var setPINCodeBiometricStateReceivedState: Data? - var setPINCodeBiometricStateReceivedInvocations: [Data] = [] - var setPINCodeBiometricStateClosure: ((Data) throws -> Void)? + var reportContentReasonClosure: ((String, String?) async -> Result)? - func setPINCodeBiometricState(_ state: Data) throws { - if let error = setPINCodeBiometricStateThrowableError { - throw error - } - setPINCodeBiometricStateCallsCount += 1 - setPINCodeBiometricStateReceivedState = state + func reportContent(_ eventID: String, reason: String?) async -> Result { + reportContentReasonCallsCount += 1 + reportContentReasonReceivedArguments = (eventID: eventID, reason: reason) DispatchQueue.main.async { - self.setPINCodeBiometricStateReceivedInvocations.append(state) + self.reportContentReasonReceivedInvocations.append((eventID: eventID, reason: reason)) + } + if let reportContentReasonClosure = reportContentReasonClosure { + return await reportContentReasonClosure(eventID, reason) + } else { + return reportContentReasonReturnValue } - try setPINCodeBiometricStateClosure?(state) } - //MARK: - pinCodeBiometricState + //MARK: - leaveRoom - var pinCodeBiometricStateUnderlyingCallsCount = 0 - var pinCodeBiometricStateCallsCount: Int { + var leaveRoomUnderlyingCallsCount = 0 + var leaveRoomCallsCount: Int { get { if Thread.isMainThread { - return pinCodeBiometricStateUnderlyingCallsCount + return leaveRoomUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = pinCodeBiometricStateUnderlyingCallsCount + returnValue = leaveRoomUnderlyingCallsCount } return returnValue! @@ -5735,27 +5831,27 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - pinCodeBiometricStateUnderlyingCallsCount = newValue + leaveRoomUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - pinCodeBiometricStateUnderlyingCallsCount = newValue + leaveRoomUnderlyingCallsCount = newValue } } } } - var pinCodeBiometricStateCalled: Bool { - return pinCodeBiometricStateCallsCount > 0 + var leaveRoomCalled: Bool { + return leaveRoomCallsCount > 0 } - var pinCodeBiometricStateUnderlyingReturnValue: Data? - var pinCodeBiometricStateReturnValue: Data? { + var leaveRoomUnderlyingReturnValue: Result! + var leaveRoomReturnValue: Result! { get { if Thread.isMainThread { - return pinCodeBiometricStateUnderlyingReturnValue + return leaveRoomUnderlyingReturnValue } else { - var returnValue: Data?? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = pinCodeBiometricStateUnderlyingReturnValue + returnValue = leaveRoomUnderlyingReturnValue } return returnValue! @@ -5763,35 +5859,35 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - pinCodeBiometricStateUnderlyingReturnValue = newValue + leaveRoomUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - pinCodeBiometricStateUnderlyingReturnValue = newValue + leaveRoomUnderlyingReturnValue = newValue } } } } - var pinCodeBiometricStateClosure: (() -> Data?)? + var leaveRoomClosure: (() async -> Result)? - func pinCodeBiometricState() -> Data? { - pinCodeBiometricStateCallsCount += 1 - if let pinCodeBiometricStateClosure = pinCodeBiometricStateClosure { - return pinCodeBiometricStateClosure() + func leaveRoom() async -> Result { + leaveRoomCallsCount += 1 + if let leaveRoomClosure = leaveRoomClosure { + return await leaveRoomClosure() } else { - return pinCodeBiometricStateReturnValue + return leaveRoomReturnValue } } - //MARK: - removePINCodeBiometricState + //MARK: - updateMembers - var removePINCodeBiometricStateUnderlyingCallsCount = 0 - var removePINCodeBiometricStateCallsCount: Int { + var updateMembersUnderlyingCallsCount = 0 + var updateMembersCallsCount: Int { get { if Thread.isMainThread { - return removePINCodeBiometricStateUnderlyingCallsCount + return updateMembersUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removePINCodeBiometricStateUnderlyingCallsCount + returnValue = updateMembersUnderlyingCallsCount } return returnValue! @@ -5799,38 +5895,34 @@ class KeychainControllerMock: KeychainControllerProtocol { } set { if Thread.isMainThread { - removePINCodeBiometricStateUnderlyingCallsCount = newValue + updateMembersUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removePINCodeBiometricStateUnderlyingCallsCount = newValue + updateMembersUnderlyingCallsCount = newValue } } } } - var removePINCodeBiometricStateCalled: Bool { - return removePINCodeBiometricStateCallsCount > 0 + var updateMembersCalled: Bool { + return updateMembersCallsCount > 0 } - var removePINCodeBiometricStateClosure: (() -> Void)? + var updateMembersClosure: (() async -> Void)? - func removePINCodeBiometricState() { - removePINCodeBiometricStateCallsCount += 1 - removePINCodeBiometricStateClosure?() + func updateMembers() async { + updateMembersCallsCount += 1 + await updateMembersClosure?() } -} -class MediaLoaderMock: MediaLoaderProtocol { - - //MARK: - loadMediaContentForSource + //MARK: - getMember - var loadMediaContentForSourceThrowableError: Error? - var loadMediaContentForSourceUnderlyingCallsCount = 0 - var loadMediaContentForSourceCallsCount: Int { + var getMemberUserIDUnderlyingCallsCount = 0 + var getMemberUserIDCallsCount: Int { get { if Thread.isMainThread { - return loadMediaContentForSourceUnderlyingCallsCount + return getMemberUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadMediaContentForSourceUnderlyingCallsCount + returnValue = getMemberUserIDUnderlyingCallsCount } return returnValue! @@ -5838,29 +5930,29 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaContentForSourceUnderlyingCallsCount = newValue + getMemberUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadMediaContentForSourceUnderlyingCallsCount = newValue + getMemberUserIDUnderlyingCallsCount = newValue } } } } - var loadMediaContentForSourceCalled: Bool { - return loadMediaContentForSourceCallsCount > 0 + var getMemberUserIDCalled: Bool { + return getMemberUserIDCallsCount > 0 } - var loadMediaContentForSourceReceivedSource: MediaSourceProxy? - var loadMediaContentForSourceReceivedInvocations: [MediaSourceProxy] = [] + var getMemberUserIDReceivedUserID: String? + var getMemberUserIDReceivedInvocations: [String] = [] - var loadMediaContentForSourceUnderlyingReturnValue: Data! - var loadMediaContentForSourceReturnValue: Data! { + var getMemberUserIDUnderlyingReturnValue: Result! + var getMemberUserIDReturnValue: Result! { get { if Thread.isMainThread { - return loadMediaContentForSourceUnderlyingReturnValue + return getMemberUserIDUnderlyingReturnValue } else { - var returnValue: Data? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = loadMediaContentForSourceUnderlyingReturnValue + returnValue = getMemberUserIDUnderlyingReturnValue } return returnValue! @@ -5868,43 +5960,39 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaContentForSourceUnderlyingReturnValue = newValue + getMemberUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - loadMediaContentForSourceUnderlyingReturnValue = newValue + getMemberUserIDUnderlyingReturnValue = newValue } } } } - var loadMediaContentForSourceClosure: ((MediaSourceProxy) async throws -> Data)? + var getMemberUserIDClosure: ((String) async -> Result)? - func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data { - if let error = loadMediaContentForSourceThrowableError { - throw error - } - loadMediaContentForSourceCallsCount += 1 - loadMediaContentForSourceReceivedSource = source + func getMember(userID: String) async -> Result { + getMemberUserIDCallsCount += 1 + getMemberUserIDReceivedUserID = userID DispatchQueue.main.async { - self.loadMediaContentForSourceReceivedInvocations.append(source) + self.getMemberUserIDReceivedInvocations.append(userID) } - if let loadMediaContentForSourceClosure = loadMediaContentForSourceClosure { - return try await loadMediaContentForSourceClosure(source) + if let getMemberUserIDClosure = getMemberUserIDClosure { + return await getMemberUserIDClosure(userID) } else { - return loadMediaContentForSourceReturnValue + return getMemberUserIDReturnValue } } - //MARK: - loadMediaThumbnailForSource + //MARK: - invite - var loadMediaThumbnailForSourceWidthHeightThrowableError: Error? - var loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = 0 - var loadMediaThumbnailForSourceWidthHeightCallsCount: Int { + var inviteUserIDUnderlyingCallsCount = 0 + var inviteUserIDCallsCount: Int { get { if Thread.isMainThread { - return loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount + return inviteUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount + returnValue = inviteUserIDUnderlyingCallsCount } return returnValue! @@ -5912,29 +6000,29 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue + inviteUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue + inviteUserIDUnderlyingCallsCount = newValue } } } } - var loadMediaThumbnailForSourceWidthHeightCalled: Bool { - return loadMediaThumbnailForSourceWidthHeightCallsCount > 0 + var inviteUserIDCalled: Bool { + return inviteUserIDCallsCount > 0 } - var loadMediaThumbnailForSourceWidthHeightReceivedArguments: (source: MediaSourceProxy, width: UInt, height: UInt)? - var loadMediaThumbnailForSourceWidthHeightReceivedInvocations: [(source: MediaSourceProxy, width: UInt, height: UInt)] = [] + var inviteUserIDReceivedUserID: String? + var inviteUserIDReceivedInvocations: [String] = [] - var loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue: Data! - var loadMediaThumbnailForSourceWidthHeightReturnValue: Data! { + var inviteUserIDUnderlyingReturnValue: Result! + var inviteUserIDReturnValue: Result! { get { if Thread.isMainThread { - return loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue + return inviteUserIDUnderlyingReturnValue } else { - var returnValue: Data? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue + returnValue = inviteUserIDUnderlyingReturnValue } return returnValue! @@ -5942,43 +6030,39 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue + inviteUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue + inviteUserIDUnderlyingReturnValue = newValue } } } } - var loadMediaThumbnailForSourceWidthHeightClosure: ((MediaSourceProxy, UInt, UInt) async throws -> Data)? + var inviteUserIDClosure: ((String) async -> Result)? - func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data { - if let error = loadMediaThumbnailForSourceWidthHeightThrowableError { - throw error - } - loadMediaThumbnailForSourceWidthHeightCallsCount += 1 - loadMediaThumbnailForSourceWidthHeightReceivedArguments = (source: source, width: width, height: height) + func invite(userID: String) async -> Result { + inviteUserIDCallsCount += 1 + inviteUserIDReceivedUserID = userID DispatchQueue.main.async { - self.loadMediaThumbnailForSourceWidthHeightReceivedInvocations.append((source: source, width: width, height: height)) + self.inviteUserIDReceivedInvocations.append(userID) } - if let loadMediaThumbnailForSourceWidthHeightClosure = loadMediaThumbnailForSourceWidthHeightClosure { - return try await loadMediaThumbnailForSourceWidthHeightClosure(source, width, height) + if let inviteUserIDClosure = inviteUserIDClosure { + return await inviteUserIDClosure(userID) } else { - return loadMediaThumbnailForSourceWidthHeightReturnValue + return inviteUserIDReturnValue } } - //MARK: - loadMediaFileForSource + //MARK: - setName - var loadMediaFileForSourceBodyThrowableError: Error? - var loadMediaFileForSourceBodyUnderlyingCallsCount = 0 - var loadMediaFileForSourceBodyCallsCount: Int { + var setNameUnderlyingCallsCount = 0 + var setNameCallsCount: Int { get { if Thread.isMainThread { - return loadMediaFileForSourceBodyUnderlyingCallsCount + return setNameUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadMediaFileForSourceBodyUnderlyingCallsCount + returnValue = setNameUnderlyingCallsCount } return returnValue! @@ -5986,29 +6070,29 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaFileForSourceBodyUnderlyingCallsCount = newValue + setNameUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadMediaFileForSourceBodyUnderlyingCallsCount = newValue + setNameUnderlyingCallsCount = newValue } } } } - var loadMediaFileForSourceBodyCalled: Bool { - return loadMediaFileForSourceBodyCallsCount > 0 + var setNameCalled: Bool { + return setNameCallsCount > 0 } - var loadMediaFileForSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)? - var loadMediaFileForSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = [] + var setNameReceivedName: String? + var setNameReceivedInvocations: [String] = [] - var loadMediaFileForSourceBodyUnderlyingReturnValue: MediaFileHandleProxy! - var loadMediaFileForSourceBodyReturnValue: MediaFileHandleProxy! { + var setNameUnderlyingReturnValue: Result! + var setNameReturnValue: Result! { get { if Thread.isMainThread { - return loadMediaFileForSourceBodyUnderlyingReturnValue + return setNameUnderlyingReturnValue } else { - var returnValue: MediaFileHandleProxy? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = loadMediaFileForSourceBodyUnderlyingReturnValue + returnValue = setNameUnderlyingReturnValue } return returnValue! @@ -6016,62 +6100,39 @@ class MediaLoaderMock: MediaLoaderProtocol { } set { if Thread.isMainThread { - loadMediaFileForSourceBodyUnderlyingReturnValue = newValue + setNameUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - loadMediaFileForSourceBodyUnderlyingReturnValue = newValue + setNameUnderlyingReturnValue = newValue } } } } - var loadMediaFileForSourceBodyClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)? + var setNameClosure: ((String) async -> Result)? - func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy { - if let error = loadMediaFileForSourceBodyThrowableError { - throw error - } - loadMediaFileForSourceBodyCallsCount += 1 - loadMediaFileForSourceBodyReceivedArguments = (source: source, body: body) + func setName(_ name: String) async -> Result { + setNameCallsCount += 1 + setNameReceivedName = name DispatchQueue.main.async { - self.loadMediaFileForSourceBodyReceivedInvocations.append((source: source, body: body)) + self.setNameReceivedInvocations.append(name) } - if let loadMediaFileForSourceBodyClosure = loadMediaFileForSourceBodyClosure { - return try await loadMediaFileForSourceBodyClosure(source, body) + if let setNameClosure = setNameClosure { + return await setNameClosure(name) } else { - return loadMediaFileForSourceBodyReturnValue + return setNameReturnValue } } -} -class MediaPlayerMock: MediaPlayerProtocol { - var mediaSource: MediaSourceProxy? - var duration: TimeInterval { - get { return underlyingDuration } - set(value) { underlyingDuration = value } - } - var underlyingDuration: TimeInterval! - var currentTime: TimeInterval { - get { return underlyingCurrentTime } - set(value) { underlyingCurrentTime = value } - } - var underlyingCurrentTime: TimeInterval! - var url: URL? - var state: MediaPlayerState { - get { return underlyingState } - set(value) { underlyingState = value } - } - var underlyingState: MediaPlayerState! - - //MARK: - load + //MARK: - setTopic - var loadMediaSourceUsingAutoplayUnderlyingCallsCount = 0 - var loadMediaSourceUsingAutoplayCallsCount: Int { + var setTopicUnderlyingCallsCount = 0 + var setTopicCallsCount: Int { get { if Thread.isMainThread { - return loadMediaSourceUsingAutoplayUnderlyingCallsCount + return setTopicUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadMediaSourceUsingAutoplayUnderlyingCallsCount + returnValue = setTopicUnderlyingCallsCount } return returnValue! @@ -6079,40 +6140,29 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue + setTopicUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue + setTopicUnderlyingCallsCount = newValue } } } } - var loadMediaSourceUsingAutoplayCalled: Bool { - return loadMediaSourceUsingAutoplayCallsCount > 0 - } - var loadMediaSourceUsingAutoplayReceivedArguments: (mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)? - var loadMediaSourceUsingAutoplayReceivedInvocations: [(mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)] = [] - var loadMediaSourceUsingAutoplayClosure: ((MediaSourceProxy, URL, Bool) -> Void)? - - func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) { - loadMediaSourceUsingAutoplayCallsCount += 1 - loadMediaSourceUsingAutoplayReceivedArguments = (mediaSource: mediaSource, url: url, autoplay: autoplay) - DispatchQueue.main.async { - self.loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay)) - } - loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay) + var setTopicCalled: Bool { + return setTopicCallsCount > 0 } - //MARK: - reset + var setTopicReceivedTopic: String? + var setTopicReceivedInvocations: [String] = [] - var resetUnderlyingCallsCount = 0 - var resetCallsCount: Int { + var setTopicUnderlyingReturnValue: Result! + var setTopicReturnValue: Result! { get { if Thread.isMainThread { - return resetUnderlyingCallsCount + return setTopicUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = resetUnderlyingCallsCount + returnValue = setTopicUnderlyingReturnValue } return returnValue! @@ -6120,34 +6170,39 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - resetUnderlyingCallsCount = newValue + setTopicUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - resetUnderlyingCallsCount = newValue + setTopicUnderlyingReturnValue = newValue } } } } - var resetCalled: Bool { - return resetCallsCount > 0 - } - var resetClosure: (() -> Void)? + var setTopicClosure: ((String) async -> Result)? - func reset() { - resetCallsCount += 1 - resetClosure?() + func setTopic(_ topic: String) async -> Result { + setTopicCallsCount += 1 + setTopicReceivedTopic = topic + DispatchQueue.main.async { + self.setTopicReceivedInvocations.append(topic) + } + if let setTopicClosure = setTopicClosure { + return await setTopicClosure(topic) + } else { + return setTopicReturnValue + } } - //MARK: - play + //MARK: - removeAvatar - var playUnderlyingCallsCount = 0 - var playCallsCount: Int { + var removeAvatarUnderlyingCallsCount = 0 + var removeAvatarCallsCount: Int { get { if Thread.isMainThread { - return playUnderlyingCallsCount + return removeAvatarUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = playUnderlyingCallsCount + returnValue = removeAvatarUnderlyingCallsCount } return returnValue! @@ -6155,34 +6210,27 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - playUnderlyingCallsCount = newValue + removeAvatarUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - playUnderlyingCallsCount = newValue + removeAvatarUnderlyingCallsCount = newValue } } } } - var playCalled: Bool { - return playCallsCount > 0 - } - var playClosure: (() -> Void)? - - func play() { - playCallsCount += 1 - playClosure?() + var removeAvatarCalled: Bool { + return removeAvatarCallsCount > 0 } - //MARK: - pause - var pauseUnderlyingCallsCount = 0 - var pauseCallsCount: Int { + var removeAvatarUnderlyingReturnValue: Result! + var removeAvatarReturnValue: Result! { get { if Thread.isMainThread { - return pauseUnderlyingCallsCount + return removeAvatarUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = pauseUnderlyingCallsCount + returnValue = removeAvatarUnderlyingReturnValue } return returnValue! @@ -6190,34 +6238,35 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - pauseUnderlyingCallsCount = newValue + removeAvatarUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - pauseUnderlyingCallsCount = newValue + removeAvatarUnderlyingReturnValue = newValue } } } } - var pauseCalled: Bool { - return pauseCallsCount > 0 - } - var pauseClosure: (() -> Void)? + var removeAvatarClosure: (() async -> Result)? - func pause() { - pauseCallsCount += 1 - pauseClosure?() + func removeAvatar() async -> Result { + removeAvatarCallsCount += 1 + if let removeAvatarClosure = removeAvatarClosure { + return await removeAvatarClosure() + } else { + return removeAvatarReturnValue + } } - //MARK: - stop + //MARK: - uploadAvatar - var stopUnderlyingCallsCount = 0 - var stopCallsCount: Int { + var uploadAvatarMediaUnderlyingCallsCount = 0 + var uploadAvatarMediaCallsCount: Int { get { if Thread.isMainThread { - return stopUnderlyingCallsCount + return uploadAvatarMediaUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = stopUnderlyingCallsCount + returnValue = uploadAvatarMediaUnderlyingCallsCount } return returnValue! @@ -6225,34 +6274,29 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - stopUnderlyingCallsCount = newValue + uploadAvatarMediaUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - stopUnderlyingCallsCount = newValue + uploadAvatarMediaUnderlyingCallsCount = newValue } } } } - var stopCalled: Bool { - return stopCallsCount > 0 - } - var stopClosure: (() -> Void)? - - func stop() { - stopCallsCount += 1 - stopClosure?() + var uploadAvatarMediaCalled: Bool { + return uploadAvatarMediaCallsCount > 0 } - //MARK: - seek + var uploadAvatarMediaReceivedMedia: MediaInfo? + var uploadAvatarMediaReceivedInvocations: [MediaInfo] = [] - var seekToUnderlyingCallsCount = 0 - var seekToCallsCount: Int { + var uploadAvatarMediaUnderlyingReturnValue: Result! + var uploadAvatarMediaReturnValue: Result! { get { if Thread.isMainThread { - return seekToUnderlyingCallsCount + return uploadAvatarMediaUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = seekToUnderlyingCallsCount + returnValue = uploadAvatarMediaUnderlyingReturnValue } return returnValue! @@ -6260,43 +6304,39 @@ class MediaPlayerMock: MediaPlayerProtocol { } set { if Thread.isMainThread { - seekToUnderlyingCallsCount = newValue + uploadAvatarMediaUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - seekToUnderlyingCallsCount = newValue + uploadAvatarMediaUnderlyingReturnValue = newValue } } } } - var seekToCalled: Bool { - return seekToCallsCount > 0 - } - var seekToReceivedProgress: Double? - var seekToReceivedInvocations: [Double] = [] - var seekToClosure: ((Double) async -> Void)? + var uploadAvatarMediaClosure: ((MediaInfo) async -> Result)? - func seek(to progress: Double) async { - seekToCallsCount += 1 - seekToReceivedProgress = progress + func uploadAvatar(media: MediaInfo) async -> Result { + uploadAvatarMediaCallsCount += 1 + uploadAvatarMediaReceivedMedia = media DispatchQueue.main.async { - self.seekToReceivedInvocations.append(progress) + self.uploadAvatarMediaReceivedInvocations.append(media) + } + if let uploadAvatarMediaClosure = uploadAvatarMediaClosure { + return await uploadAvatarMediaClosure(media) + } else { + return uploadAvatarMediaReturnValue } - await seekToClosure?(progress) } -} -class MediaPlayerProviderMock: MediaPlayerProviderProtocol { - - //MARK: - player + //MARK: - markAsRead - var playerForUnderlyingCallsCount = 0 - var playerForCallsCount: Int { + var markAsReadReceiptTypeUnderlyingCallsCount = 0 + var markAsReadReceiptTypeCallsCount: Int { get { if Thread.isMainThread { - return playerForUnderlyingCallsCount + return markAsReadReceiptTypeUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = playerForUnderlyingCallsCount + returnValue = markAsReadReceiptTypeUnderlyingCallsCount } return returnValue! @@ -6304,29 +6344,29 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - playerForUnderlyingCallsCount = newValue + markAsReadReceiptTypeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - playerForUnderlyingCallsCount = newValue + markAsReadReceiptTypeUnderlyingCallsCount = newValue } } } } - var playerForCalled: Bool { - return playerForCallsCount > 0 + var markAsReadReceiptTypeCalled: Bool { + return markAsReadReceiptTypeCallsCount > 0 } - var playerForReceivedMediaSource: MediaSourceProxy? - var playerForReceivedInvocations: [MediaSourceProxy] = [] + var markAsReadReceiptTypeReceivedReceiptType: ReceiptType? + var markAsReadReceiptTypeReceivedInvocations: [ReceiptType] = [] - var playerForUnderlyingReturnValue: Result! - var playerForReturnValue: Result! { + var markAsReadReceiptTypeUnderlyingReturnValue: Result! + var markAsReadReceiptTypeReturnValue: Result! { get { if Thread.isMainThread { - return playerForUnderlyingReturnValue + return markAsReadReceiptTypeUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = playerForUnderlyingReturnValue + returnValue = markAsReadReceiptTypeUnderlyingReturnValue } return returnValue! @@ -6334,39 +6374,39 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - playerForUnderlyingReturnValue = newValue + markAsReadReceiptTypeUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - playerForUnderlyingReturnValue = newValue + markAsReadReceiptTypeUnderlyingReturnValue = newValue } } } } - var playerForClosure: ((MediaSourceProxy) -> Result)? + var markAsReadReceiptTypeClosure: ((ReceiptType) async -> Result)? - func player(for mediaSource: MediaSourceProxy) -> Result { - playerForCallsCount += 1 - playerForReceivedMediaSource = mediaSource + func markAsRead(receiptType: ReceiptType) async -> Result { + markAsReadReceiptTypeCallsCount += 1 + markAsReadReceiptTypeReceivedReceiptType = receiptType DispatchQueue.main.async { - self.playerForReceivedInvocations.append(mediaSource) + self.markAsReadReceiptTypeReceivedInvocations.append(receiptType) } - if let playerForClosure = playerForClosure { - return playerForClosure(mediaSource) + if let markAsReadReceiptTypeClosure = markAsReadReceiptTypeClosure { + return await markAsReadReceiptTypeClosure(receiptType) } else { - return playerForReturnValue + return markAsReadReceiptTypeReturnValue } } - //MARK: - playerState + //MARK: - edit - var playerStateForUnderlyingCallsCount = 0 - var playerStateForCallsCount: Int { + var editEventIDNewContentUnderlyingCallsCount = 0 + var editEventIDNewContentCallsCount: Int { get { if Thread.isMainThread { - return playerStateForUnderlyingCallsCount + return editEventIDNewContentUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = playerStateForUnderlyingCallsCount + returnValue = editEventIDNewContentUnderlyingCallsCount } return returnValue! @@ -6374,29 +6414,29 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - playerStateForUnderlyingCallsCount = newValue + editEventIDNewContentUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - playerStateForUnderlyingCallsCount = newValue + editEventIDNewContentUnderlyingCallsCount = newValue } } } } - var playerStateForCalled: Bool { - return playerStateForCallsCount > 0 + var editEventIDNewContentCalled: Bool { + return editEventIDNewContentCallsCount > 0 } - var playerStateForReceivedId: AudioPlayerStateIdentifier? - var playerStateForReceivedInvocations: [AudioPlayerStateIdentifier] = [] + var editEventIDNewContentReceivedArguments: (eventID: String, newContent: RoomMessageEventContentWithoutRelation)? + var editEventIDNewContentReceivedInvocations: [(eventID: String, newContent: RoomMessageEventContentWithoutRelation)] = [] - var playerStateForUnderlyingReturnValue: AudioPlayerState? - var playerStateForReturnValue: AudioPlayerState? { + var editEventIDNewContentUnderlyingReturnValue: Result! + var editEventIDNewContentReturnValue: Result! { get { if Thread.isMainThread { - return playerStateForUnderlyingReturnValue + return editEventIDNewContentUnderlyingReturnValue } else { - var returnValue: AudioPlayerState?? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = playerStateForUnderlyingReturnValue + returnValue = editEventIDNewContentUnderlyingReturnValue } return returnValue! @@ -6404,39 +6444,39 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - playerStateForUnderlyingReturnValue = newValue + editEventIDNewContentUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - playerStateForUnderlyingReturnValue = newValue + editEventIDNewContentUnderlyingReturnValue = newValue } } } } - var playerStateForClosure: ((AudioPlayerStateIdentifier) -> AudioPlayerState?)? + var editEventIDNewContentClosure: ((String, RoomMessageEventContentWithoutRelation) async -> Result)? - func playerState(for id: AudioPlayerStateIdentifier) -> AudioPlayerState? { - playerStateForCallsCount += 1 - playerStateForReceivedId = id + func edit(eventID: String, newContent: RoomMessageEventContentWithoutRelation) async -> Result { + editEventIDNewContentCallsCount += 1 + editEventIDNewContentReceivedArguments = (eventID: eventID, newContent: newContent) DispatchQueue.main.async { - self.playerStateForReceivedInvocations.append(id) + self.editEventIDNewContentReceivedInvocations.append((eventID: eventID, newContent: newContent)) } - if let playerStateForClosure = playerStateForClosure { - return playerStateForClosure(id) + if let editEventIDNewContentClosure = editEventIDNewContentClosure { + return await editEventIDNewContentClosure(eventID, newContent) } else { - return playerStateForReturnValue + return editEventIDNewContentReturnValue } } - //MARK: - register + //MARK: - sendTypingNotification - var registerAudioPlayerStateUnderlyingCallsCount = 0 - var registerAudioPlayerStateCallsCount: Int { + var sendTypingNotificationIsTypingUnderlyingCallsCount = 0 + var sendTypingNotificationIsTypingCallsCount: Int { get { if Thread.isMainThread { - return registerAudioPlayerStateUnderlyingCallsCount + return sendTypingNotificationIsTypingUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = registerAudioPlayerStateUnderlyingCallsCount + returnValue = sendTypingNotificationIsTypingUnderlyingCallsCount } return returnValue! @@ -6444,40 +6484,29 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - registerAudioPlayerStateUnderlyingCallsCount = newValue + sendTypingNotificationIsTypingUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - registerAudioPlayerStateUnderlyingCallsCount = newValue + sendTypingNotificationIsTypingUnderlyingCallsCount = newValue } } } } - var registerAudioPlayerStateCalled: Bool { - return registerAudioPlayerStateCallsCount > 0 - } - var registerAudioPlayerStateReceivedAudioPlayerState: AudioPlayerState? - var registerAudioPlayerStateReceivedInvocations: [AudioPlayerState] = [] - var registerAudioPlayerStateClosure: ((AudioPlayerState) -> Void)? - - func register(audioPlayerState: AudioPlayerState) { - registerAudioPlayerStateCallsCount += 1 - registerAudioPlayerStateReceivedAudioPlayerState = audioPlayerState - DispatchQueue.main.async { - self.registerAudioPlayerStateReceivedInvocations.append(audioPlayerState) - } - registerAudioPlayerStateClosure?(audioPlayerState) + var sendTypingNotificationIsTypingCalled: Bool { + return sendTypingNotificationIsTypingCallsCount > 0 } - //MARK: - unregister + var sendTypingNotificationIsTypingReceivedIsTyping: Bool? + var sendTypingNotificationIsTypingReceivedInvocations: [Bool] = [] - var unregisterAudioPlayerStateUnderlyingCallsCount = 0 - var unregisterAudioPlayerStateCallsCount: Int { + var sendTypingNotificationIsTypingUnderlyingReturnValue: Result! + var sendTypingNotificationIsTypingReturnValue: Result! { get { if Thread.isMainThread { - return unregisterAudioPlayerStateUnderlyingCallsCount + return sendTypingNotificationIsTypingUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = unregisterAudioPlayerStateUnderlyingCallsCount + returnValue = sendTypingNotificationIsTypingUnderlyingReturnValue } return returnValue! @@ -6485,40 +6514,40 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - unregisterAudioPlayerStateUnderlyingCallsCount = newValue + sendTypingNotificationIsTypingUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - unregisterAudioPlayerStateUnderlyingCallsCount = newValue + sendTypingNotificationIsTypingUnderlyingReturnValue = newValue } } } } - var unregisterAudioPlayerStateCalled: Bool { - return unregisterAudioPlayerStateCallsCount > 0 - } - var unregisterAudioPlayerStateReceivedAudioPlayerState: AudioPlayerState? - var unregisterAudioPlayerStateReceivedInvocations: [AudioPlayerState] = [] - var unregisterAudioPlayerStateClosure: ((AudioPlayerState) -> Void)? + var sendTypingNotificationIsTypingClosure: ((Bool) async -> Result)? - func unregister(audioPlayerState: AudioPlayerState) { - unregisterAudioPlayerStateCallsCount += 1 - unregisterAudioPlayerStateReceivedAudioPlayerState = audioPlayerState + @discardableResult + func sendTypingNotification(isTyping: Bool) async -> Result { + sendTypingNotificationIsTypingCallsCount += 1 + sendTypingNotificationIsTypingReceivedIsTyping = isTyping DispatchQueue.main.async { - self.unregisterAudioPlayerStateReceivedInvocations.append(audioPlayerState) + self.sendTypingNotificationIsTypingReceivedInvocations.append(isTyping) + } + if let sendTypingNotificationIsTypingClosure = sendTypingNotificationIsTypingClosure { + return await sendTypingNotificationIsTypingClosure(isTyping) + } else { + return sendTypingNotificationIsTypingReturnValue } - unregisterAudioPlayerStateClosure?(audioPlayerState) } - //MARK: - detachAllStates + //MARK: - flagAsUnread - var detachAllStatesExceptUnderlyingCallsCount = 0 - var detachAllStatesExceptCallsCount: Int { + var flagAsUnreadUnderlyingCallsCount = 0 + var flagAsUnreadCallsCount: Int { get { if Thread.isMainThread { - return detachAllStatesExceptUnderlyingCallsCount + return flagAsUnreadUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = detachAllStatesExceptUnderlyingCallsCount + returnValue = flagAsUnreadUnderlyingCallsCount } return returnValue! @@ -6526,52 +6555,29 @@ class MediaPlayerProviderMock: MediaPlayerProviderProtocol { } set { if Thread.isMainThread { - detachAllStatesExceptUnderlyingCallsCount = newValue + flagAsUnreadUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - detachAllStatesExceptUnderlyingCallsCount = newValue + flagAsUnreadUnderlyingCallsCount = newValue } } } } - var detachAllStatesExceptCalled: Bool { - return detachAllStatesExceptCallsCount > 0 - } - var detachAllStatesExceptReceivedException: AudioPlayerState? - var detachAllStatesExceptReceivedInvocations: [AudioPlayerState?] = [] - var detachAllStatesExceptClosure: ((AudioPlayerState?) async -> Void)? - - func detachAllStates(except exception: AudioPlayerState?) async { - detachAllStatesExceptCallsCount += 1 - detachAllStatesExceptReceivedException = exception - DispatchQueue.main.async { - self.detachAllStatesExceptReceivedInvocations.append(exception) - } - await detachAllStatesExceptClosure?(exception) - } -} -class NetworkMonitorMock: NetworkMonitorProtocol { - var reachabilityPublisher: CurrentValuePublisher { - get { return underlyingReachabilityPublisher } - set(value) { underlyingReachabilityPublisher = value } + var flagAsUnreadCalled: Bool { + return flagAsUnreadCallsCount > 0 } - var underlyingReachabilityPublisher: CurrentValuePublisher! - -} -class NotificationManagerMock: NotificationManagerProtocol { - weak var delegate: NotificationManagerDelegate? - - //MARK: - start + var flagAsUnreadReceivedIsUnread: Bool? + var flagAsUnreadReceivedInvocations: [Bool] = [] - var startUnderlyingCallsCount = 0 - var startCallsCount: Int { + var flagAsUnreadUnderlyingReturnValue: Result! + var flagAsUnreadReturnValue: Result! { get { if Thread.isMainThread { - return startUnderlyingCallsCount + return flagAsUnreadUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = startUnderlyingCallsCount + returnValue = flagAsUnreadUnderlyingReturnValue } return returnValue! @@ -6579,34 +6585,39 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - startUnderlyingCallsCount = newValue + flagAsUnreadUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - startUnderlyingCallsCount = newValue + flagAsUnreadUnderlyingReturnValue = newValue } } } } - var startCalled: Bool { - return startCallsCount > 0 - } - var startClosure: (() -> Void)? + var flagAsUnreadClosure: ((Bool) async -> Result)? - func start() { - startCallsCount += 1 - startClosure?() + func flagAsUnread(_ isUnread: Bool) async -> Result { + flagAsUnreadCallsCount += 1 + flagAsUnreadReceivedIsUnread = isUnread + DispatchQueue.main.async { + self.flagAsUnreadReceivedInvocations.append(isUnread) + } + if let flagAsUnreadClosure = flagAsUnreadClosure { + return await flagAsUnreadClosure(isUnread) + } else { + return flagAsUnreadReturnValue + } } - //MARK: - register + //MARK: - flagAsFavourite - var registerWithUnderlyingCallsCount = 0 - var registerWithCallsCount: Int { + var flagAsFavouriteUnderlyingCallsCount = 0 + var flagAsFavouriteCallsCount: Int { get { if Thread.isMainThread { - return registerWithUnderlyingCallsCount + return flagAsFavouriteUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = registerWithUnderlyingCallsCount + returnValue = flagAsFavouriteUnderlyingCallsCount } return returnValue! @@ -6614,29 +6625,29 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - registerWithUnderlyingCallsCount = newValue + flagAsFavouriteUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - registerWithUnderlyingCallsCount = newValue + flagAsFavouriteUnderlyingCallsCount = newValue } } } } - var registerWithCalled: Bool { - return registerWithCallsCount > 0 + var flagAsFavouriteCalled: Bool { + return flagAsFavouriteCallsCount > 0 } - var registerWithReceivedDeviceToken: Data? - var registerWithReceivedInvocations: [Data] = [] + var flagAsFavouriteReceivedIsFavourite: Bool? + var flagAsFavouriteReceivedInvocations: [Bool] = [] - var registerWithUnderlyingReturnValue: Bool! - var registerWithReturnValue: Bool! { + var flagAsFavouriteUnderlyingReturnValue: Result! + var flagAsFavouriteReturnValue: Result! { get { if Thread.isMainThread { - return registerWithUnderlyingReturnValue + return flagAsFavouriteUnderlyingReturnValue } else { - var returnValue: Bool? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = registerWithUnderlyingReturnValue + returnValue = flagAsFavouriteUnderlyingReturnValue } return returnValue! @@ -6644,39 +6655,67 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - registerWithUnderlyingReturnValue = newValue + flagAsFavouriteUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - registerWithUnderlyingReturnValue = newValue + flagAsFavouriteUnderlyingReturnValue = newValue } } } } - var registerWithClosure: ((Data) async -> Bool)? + var flagAsFavouriteClosure: ((Bool) async -> Result)? - func register(with deviceToken: Data) async -> Bool { - registerWithCallsCount += 1 - registerWithReceivedDeviceToken = deviceToken + func flagAsFavourite(_ isFavourite: Bool) async -> Result { + flagAsFavouriteCallsCount += 1 + flagAsFavouriteReceivedIsFavourite = isFavourite DispatchQueue.main.async { - self.registerWithReceivedInvocations.append(deviceToken) + self.flagAsFavouriteReceivedInvocations.append(isFavourite) } - if let registerWithClosure = registerWithClosure { - return await registerWithClosure(deviceToken) + if let flagAsFavouriteClosure = flagAsFavouriteClosure { + return await flagAsFavouriteClosure(isFavourite) } else { - return registerWithReturnValue + return flagAsFavouriteReturnValue } } - //MARK: - registrationFailed + //MARK: - powerLevels - var registrationFailedWithUnderlyingCallsCount = 0 - var registrationFailedWithCallsCount: Int { + var powerLevelsUnderlyingCallsCount = 0 + var powerLevelsCallsCount: Int { get { if Thread.isMainThread { - return registrationFailedWithUnderlyingCallsCount + return powerLevelsUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = powerLevelsUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + powerLevelsUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + powerLevelsUnderlyingCallsCount = newValue + } + } + } + } + var powerLevelsCalled: Bool { + return powerLevelsCallsCount > 0 + } + + var powerLevelsUnderlyingReturnValue: Result! + var powerLevelsReturnValue: Result! { + get { + if Thread.isMainThread { + return powerLevelsUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = registrationFailedWithUnderlyingCallsCount + returnValue = powerLevelsUnderlyingReturnValue } return returnValue! @@ -6684,40 +6723,35 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - registrationFailedWithUnderlyingCallsCount = newValue + powerLevelsUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - registrationFailedWithUnderlyingCallsCount = newValue + powerLevelsUnderlyingReturnValue = newValue } } } } - var registrationFailedWithCalled: Bool { - return registrationFailedWithCallsCount > 0 - } - var registrationFailedWithReceivedError: Error? - var registrationFailedWithReceivedInvocations: [Error] = [] - var registrationFailedWithClosure: ((Error) -> Void)? + var powerLevelsClosure: (() async -> Result)? - func registrationFailed(with error: Error) { - registrationFailedWithCallsCount += 1 - registrationFailedWithReceivedError = error - DispatchQueue.main.async { - self.registrationFailedWithReceivedInvocations.append(error) + func powerLevels() async -> Result { + powerLevelsCallsCount += 1 + if let powerLevelsClosure = powerLevelsClosure { + return await powerLevelsClosure() + } else { + return powerLevelsReturnValue } - registrationFailedWithClosure?(error) } - //MARK: - showLocalNotification + //MARK: - applyPowerLevelChanges - var showLocalNotificationWithSubtitleUnderlyingCallsCount = 0 - var showLocalNotificationWithSubtitleCallsCount: Int { + var applyPowerLevelChangesUnderlyingCallsCount = 0 + var applyPowerLevelChangesCallsCount: Int { get { if Thread.isMainThread { - return showLocalNotificationWithSubtitleUnderlyingCallsCount + return applyPowerLevelChangesUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = showLocalNotificationWithSubtitleUnderlyingCallsCount + returnValue = applyPowerLevelChangesUnderlyingCallsCount } return returnValue! @@ -6725,40 +6759,29 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - showLocalNotificationWithSubtitleUnderlyingCallsCount = newValue + applyPowerLevelChangesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - showLocalNotificationWithSubtitleUnderlyingCallsCount = newValue + applyPowerLevelChangesUnderlyingCallsCount = newValue } } } } - var showLocalNotificationWithSubtitleCalled: Bool { - return showLocalNotificationWithSubtitleCallsCount > 0 - } - var showLocalNotificationWithSubtitleReceivedArguments: (title: String, subtitle: String?)? - var showLocalNotificationWithSubtitleReceivedInvocations: [(title: String, subtitle: String?)] = [] - var showLocalNotificationWithSubtitleClosure: ((String, String?) async -> Void)? - - func showLocalNotification(with title: String, subtitle: String?) async { - showLocalNotificationWithSubtitleCallsCount += 1 - showLocalNotificationWithSubtitleReceivedArguments = (title: title, subtitle: subtitle) - DispatchQueue.main.async { - self.showLocalNotificationWithSubtitleReceivedInvocations.append((title: title, subtitle: subtitle)) - } - await showLocalNotificationWithSubtitleClosure?(title, subtitle) + var applyPowerLevelChangesCalled: Bool { + return applyPowerLevelChangesCallsCount > 0 } - //MARK: - setUserSession + var applyPowerLevelChangesReceivedChanges: RoomPowerLevelChanges? + var applyPowerLevelChangesReceivedInvocations: [RoomPowerLevelChanges] = [] - var setUserSessionUnderlyingCallsCount = 0 - var setUserSessionCallsCount: Int { + var applyPowerLevelChangesUnderlyingReturnValue: Result! + var applyPowerLevelChangesReturnValue: Result! { get { if Thread.isMainThread { - return setUserSessionUnderlyingCallsCount + return applyPowerLevelChangesUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = setUserSessionUnderlyingCallsCount + returnValue = applyPowerLevelChangesUnderlyingReturnValue } return returnValue! @@ -6766,40 +6789,39 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - setUserSessionUnderlyingCallsCount = newValue + applyPowerLevelChangesUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setUserSessionUnderlyingCallsCount = newValue + applyPowerLevelChangesUnderlyingReturnValue = newValue } } } } - var setUserSessionCalled: Bool { - return setUserSessionCallsCount > 0 - } - var setUserSessionReceivedUserSession: UserSessionProtocol? - var setUserSessionReceivedInvocations: [UserSessionProtocol?] = [] - var setUserSessionClosure: ((UserSessionProtocol?) -> Void)? + var applyPowerLevelChangesClosure: ((RoomPowerLevelChanges) async -> Result)? - func setUserSession(_ userSession: UserSessionProtocol?) { - setUserSessionCallsCount += 1 - setUserSessionReceivedUserSession = userSession + func applyPowerLevelChanges(_ changes: RoomPowerLevelChanges) async -> Result { + applyPowerLevelChangesCallsCount += 1 + applyPowerLevelChangesReceivedChanges = changes DispatchQueue.main.async { - self.setUserSessionReceivedInvocations.append(userSession) + self.applyPowerLevelChangesReceivedInvocations.append(changes) + } + if let applyPowerLevelChangesClosure = applyPowerLevelChangesClosure { + return await applyPowerLevelChangesClosure(changes) + } else { + return applyPowerLevelChangesReturnValue } - setUserSessionClosure?(userSession) } - //MARK: - requestAuthorization + //MARK: - resetPowerLevels - var requestAuthorizationUnderlyingCallsCount = 0 - var requestAuthorizationCallsCount: Int { + var resetPowerLevelsUnderlyingCallsCount = 0 + var resetPowerLevelsCallsCount: Int { get { if Thread.isMainThread { - return requestAuthorizationUnderlyingCallsCount + return resetPowerLevelsUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = requestAuthorizationUnderlyingCallsCount + returnValue = resetPowerLevelsUnderlyingCallsCount } return returnValue! @@ -6807,34 +6829,27 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - requestAuthorizationUnderlyingCallsCount = newValue + resetPowerLevelsUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - requestAuthorizationUnderlyingCallsCount = newValue + resetPowerLevelsUnderlyingCallsCount = newValue } } } } - var requestAuthorizationCalled: Bool { - return requestAuthorizationCallsCount > 0 - } - var requestAuthorizationClosure: (() -> Void)? - - func requestAuthorization() { - requestAuthorizationCallsCount += 1 - requestAuthorizationClosure?() + var resetPowerLevelsCalled: Bool { + return resetPowerLevelsCallsCount > 0 } - //MARK: - removeDeliveredMessageNotifications - var removeDeliveredMessageNotificationsForUnderlyingCallsCount = 0 - var removeDeliveredMessageNotificationsForCallsCount: Int { + var resetPowerLevelsUnderlyingReturnValue: Result! + var resetPowerLevelsReturnValue: Result! { get { if Thread.isMainThread { - return removeDeliveredMessageNotificationsForUnderlyingCallsCount + return resetPowerLevelsUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = removeDeliveredMessageNotificationsForUnderlyingCallsCount + returnValue = resetPowerLevelsUnderlyingReturnValue } return returnValue! @@ -6842,40 +6857,35 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - removeDeliveredMessageNotificationsForUnderlyingCallsCount = newValue + resetPowerLevelsUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - removeDeliveredMessageNotificationsForUnderlyingCallsCount = newValue + resetPowerLevelsUnderlyingReturnValue = newValue } } } } - var removeDeliveredMessageNotificationsForCalled: Bool { - return removeDeliveredMessageNotificationsForCallsCount > 0 - } - var removeDeliveredMessageNotificationsForReceivedRoomID: String? - var removeDeliveredMessageNotificationsForReceivedInvocations: [String] = [] - var removeDeliveredMessageNotificationsForClosure: ((String) async -> Void)? + var resetPowerLevelsClosure: (() async -> Result)? - func removeDeliveredMessageNotifications(for roomID: String) async { - removeDeliveredMessageNotificationsForCallsCount += 1 - removeDeliveredMessageNotificationsForReceivedRoomID = roomID - DispatchQueue.main.async { - self.removeDeliveredMessageNotificationsForReceivedInvocations.append(roomID) + func resetPowerLevels() async -> Result { + resetPowerLevelsCallsCount += 1 + if let resetPowerLevelsClosure = resetPowerLevelsClosure { + return await resetPowerLevelsClosure() + } else { + return resetPowerLevelsReturnValue } - await removeDeliveredMessageNotificationsForClosure?(roomID) } - //MARK: - removeDeliveredInviteNotifications + //MARK: - suggestedRole - var removeDeliveredInviteNotificationsUnderlyingCallsCount = 0 - var removeDeliveredInviteNotificationsCallsCount: Int { + var suggestedRoleForUnderlyingCallsCount = 0 + var suggestedRoleForCallsCount: Int { get { if Thread.isMainThread { - return removeDeliveredInviteNotificationsUnderlyingCallsCount + return suggestedRoleForUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removeDeliveredInviteNotificationsUnderlyingCallsCount + returnValue = suggestedRoleForUnderlyingCallsCount } return returnValue! @@ -6883,43 +6893,29 @@ class NotificationManagerMock: NotificationManagerProtocol { } set { if Thread.isMainThread { - removeDeliveredInviteNotificationsUnderlyingCallsCount = newValue + suggestedRoleForUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removeDeliveredInviteNotificationsUnderlyingCallsCount = newValue + suggestedRoleForUnderlyingCallsCount = newValue } } } } - var removeDeliveredInviteNotificationsCalled: Bool { - return removeDeliveredInviteNotificationsCallsCount > 0 - } - var removeDeliveredInviteNotificationsClosure: (() async -> Void)? - - func removeDeliveredInviteNotifications() async { - removeDeliveredInviteNotificationsCallsCount += 1 - await removeDeliveredInviteNotificationsClosure?() - } -} -class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { - var callbacks: PassthroughSubject { - get { return underlyingCallbacks } - set(value) { underlyingCallbacks = value } + var suggestedRoleForCalled: Bool { + return suggestedRoleForCallsCount > 0 } - var underlyingCallbacks: PassthroughSubject! - - //MARK: - getNotificationSettings + var suggestedRoleForReceivedUserID: String? + var suggestedRoleForReceivedInvocations: [String] = [] - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError: Error? - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = 0 - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount: Int { + var suggestedRoleForUnderlyingReturnValue: Result! + var suggestedRoleForReturnValue: Result! { get { if Thread.isMainThread { - return getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount + return suggestedRoleForUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount + returnValue = suggestedRoleForUnderlyingReturnValue } return returnValue! @@ -6927,29 +6923,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + suggestedRoleForUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + suggestedRoleForUnderlyingReturnValue = newValue } } } } - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCalled: Bool { - return getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount > 0 + var suggestedRoleForClosure: ((String) async -> Result)? + + func suggestedRole(for userID: String) async -> Result { + suggestedRoleForCallsCount += 1 + suggestedRoleForReceivedUserID = userID + DispatchQueue.main.async { + self.suggestedRoleForReceivedInvocations.append(userID) + } + if let suggestedRoleForClosure = suggestedRoleForClosure { + return await suggestedRoleForClosure(userID) + } else { + return suggestedRoleForReturnValue + } } - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)? - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = [] + //MARK: - updatePowerLevelsForUsers - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue: RoomNotificationSettingsProxyProtocol! - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue: RoomNotificationSettingsProxyProtocol! { + var updatePowerLevelsForUsersUnderlyingCallsCount = 0 + var updatePowerLevelsForUsersCallsCount: Int { get { if Thread.isMainThread { - return getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue + return updatePowerLevelsForUsersUnderlyingCallsCount } else { - var returnValue: RoomNotificationSettingsProxyProtocol? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue + returnValue = updatePowerLevelsForUsersUnderlyingCallsCount } return returnValue! @@ -6957,43 +6963,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue = newValue + updatePowerLevelsForUsersUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue = newValue + updatePowerLevelsForUsersUnderlyingCallsCount = newValue } } } } - var getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> RoomNotificationSettingsProxyProtocol)? - - func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol { - if let error = getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError { - throw error - } - getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount += 1 - getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne) - DispatchQueue.main.async { - self.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)) - } - if let getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure = getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure { - return try await getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure(roomId, isEncrypted, isOneToOne) - } else { - return getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue - } + var updatePowerLevelsForUsersCalled: Bool { + return updatePowerLevelsForUsersCallsCount > 0 } - //MARK: - setNotificationMode + var updatePowerLevelsForUsersReceivedUpdates: [(userID: String, powerLevel: Int64)]? + var updatePowerLevelsForUsersReceivedInvocations: [[(userID: String, powerLevel: Int64)]] = [] - var setNotificationModeRoomIdModeThrowableError: Error? - var setNotificationModeRoomIdModeUnderlyingCallsCount = 0 - var setNotificationModeRoomIdModeCallsCount: Int { + var updatePowerLevelsForUsersUnderlyingReturnValue: Result! + var updatePowerLevelsForUsersReturnValue: Result! { get { if Thread.isMainThread { - return setNotificationModeRoomIdModeUnderlyingCallsCount + return updatePowerLevelsForUsersUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = setNotificationModeRoomIdModeUnderlyingCallsCount + returnValue = updatePowerLevelsForUsersUnderlyingReturnValue } return returnValue! @@ -7001,44 +6993,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - setNotificationModeRoomIdModeUnderlyingCallsCount = newValue + updatePowerLevelsForUsersUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setNotificationModeRoomIdModeUnderlyingCallsCount = newValue + updatePowerLevelsForUsersUnderlyingReturnValue = newValue } } } } - var setNotificationModeRoomIdModeCalled: Bool { - return setNotificationModeRoomIdModeCallsCount > 0 - } - var setNotificationModeRoomIdModeReceivedArguments: (roomId: String, mode: RoomNotificationModeProxy)? - var setNotificationModeRoomIdModeReceivedInvocations: [(roomId: String, mode: RoomNotificationModeProxy)] = [] - var setNotificationModeRoomIdModeClosure: ((String, RoomNotificationModeProxy) async throws -> Void)? + var updatePowerLevelsForUsersClosure: (([(userID: String, powerLevel: Int64)]) async -> Result)? - func setNotificationMode(roomId: String, mode: RoomNotificationModeProxy) async throws { - if let error = setNotificationModeRoomIdModeThrowableError { - throw error - } - setNotificationModeRoomIdModeCallsCount += 1 - setNotificationModeRoomIdModeReceivedArguments = (roomId: roomId, mode: mode) + func updatePowerLevelsForUsers(_ updates: [(userID: String, powerLevel: Int64)]) async -> Result { + updatePowerLevelsForUsersCallsCount += 1 + updatePowerLevelsForUsersReceivedUpdates = updates DispatchQueue.main.async { - self.setNotificationModeRoomIdModeReceivedInvocations.append((roomId: roomId, mode: mode)) + self.updatePowerLevelsForUsersReceivedInvocations.append(updates) + } + if let updatePowerLevelsForUsersClosure = updatePowerLevelsForUsersClosure { + return await updatePowerLevelsForUsersClosure(updates) + } else { + return updatePowerLevelsForUsersReturnValue } - try await setNotificationModeRoomIdModeClosure?(roomId, mode) } - //MARK: - getUserDefinedRoomNotificationMode + //MARK: - canUser - var getUserDefinedRoomNotificationModeRoomIdThrowableError: Error? - var getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = 0 - var getUserDefinedRoomNotificationModeRoomIdCallsCount: Int { + var canUserUserIDSendStateEventUnderlyingCallsCount = 0 + var canUserUserIDSendStateEventCallsCount: Int { get { if Thread.isMainThread { - return getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount + return canUserUserIDSendStateEventUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount + returnValue = canUserUserIDSendStateEventUnderlyingCallsCount } return returnValue! @@ -7046,29 +7033,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = newValue + canUserUserIDSendStateEventUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = newValue + canUserUserIDSendStateEventUnderlyingCallsCount = newValue } } } } - var getUserDefinedRoomNotificationModeRoomIdCalled: Bool { - return getUserDefinedRoomNotificationModeRoomIdCallsCount > 0 + var canUserUserIDSendStateEventCalled: Bool { + return canUserUserIDSendStateEventCallsCount > 0 } - var getUserDefinedRoomNotificationModeRoomIdReceivedRoomId: String? - var getUserDefinedRoomNotificationModeRoomIdReceivedInvocations: [String] = [] + var canUserUserIDSendStateEventReceivedArguments: (userID: String, event: StateEventType)? + var canUserUserIDSendStateEventReceivedInvocations: [(userID: String, event: StateEventType)] = [] - var getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue: RoomNotificationModeProxy? - var getUserDefinedRoomNotificationModeRoomIdReturnValue: RoomNotificationModeProxy? { + var canUserUserIDSendStateEventUnderlyingReturnValue: Result! + var canUserUserIDSendStateEventReturnValue: Result! { get { if Thread.isMainThread { - return getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue + return canUserUserIDSendStateEventUnderlyingReturnValue } else { - var returnValue: RoomNotificationModeProxy?? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue + returnValue = canUserUserIDSendStateEventUnderlyingReturnValue } return returnValue! @@ -7076,42 +7063,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue = newValue + canUserUserIDSendStateEventUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue = newValue + canUserUserIDSendStateEventUnderlyingReturnValue = newValue } } } } - var getUserDefinedRoomNotificationModeRoomIdClosure: ((String) async throws -> RoomNotificationModeProxy?)? + var canUserUserIDSendStateEventClosure: ((String, StateEventType) async -> Result)? - func getUserDefinedRoomNotificationMode(roomId: String) async throws -> RoomNotificationModeProxy? { - if let error = getUserDefinedRoomNotificationModeRoomIdThrowableError { - throw error - } - getUserDefinedRoomNotificationModeRoomIdCallsCount += 1 - getUserDefinedRoomNotificationModeRoomIdReceivedRoomId = roomId + func canUser(userID: String, sendStateEvent event: StateEventType) async -> Result { + canUserUserIDSendStateEventCallsCount += 1 + canUserUserIDSendStateEventReceivedArguments = (userID: userID, event: event) DispatchQueue.main.async { - self.getUserDefinedRoomNotificationModeRoomIdReceivedInvocations.append(roomId) + self.canUserUserIDSendStateEventReceivedInvocations.append((userID: userID, event: event)) } - if let getUserDefinedRoomNotificationModeRoomIdClosure = getUserDefinedRoomNotificationModeRoomIdClosure { - return try await getUserDefinedRoomNotificationModeRoomIdClosure(roomId) + if let canUserUserIDSendStateEventClosure = canUserUserIDSendStateEventClosure { + return await canUserUserIDSendStateEventClosure(userID, event) } else { - return getUserDefinedRoomNotificationModeRoomIdReturnValue + return canUserUserIDSendStateEventReturnValue } } - //MARK: - getDefaultRoomNotificationMode + //MARK: - canUserInvite - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = 0 - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount: Int { + var canUserInviteUserIDUnderlyingCallsCount = 0 + var canUserInviteUserIDCallsCount: Int { get { if Thread.isMainThread { - return getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount + return canUserInviteUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount + returnValue = canUserInviteUserIDUnderlyingCallsCount } return returnValue! @@ -7119,29 +7103,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + canUserInviteUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + canUserInviteUserIDUnderlyingCallsCount = newValue } } } } - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneCalled: Bool { - return getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount > 0 + var canUserInviteUserIDCalled: Bool { + return canUserInviteUserIDCallsCount > 0 } - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool)? - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool)] = [] + var canUserInviteUserIDReceivedUserID: String? + var canUserInviteUserIDReceivedInvocations: [String] = [] - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue: RoomNotificationModeProxy! - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue: RoomNotificationModeProxy! { + var canUserInviteUserIDUnderlyingReturnValue: Result! + var canUserInviteUserIDReturnValue: Result! { get { if Thread.isMainThread { - return getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue + return canUserInviteUserIDUnderlyingReturnValue } else { - var returnValue: RoomNotificationModeProxy? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue + returnValue = canUserInviteUserIDUnderlyingReturnValue } return returnValue! @@ -7149,40 +7133,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue = newValue + canUserInviteUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue = newValue + canUserInviteUserIDUnderlyingReturnValue = newValue } } } } - var getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure: ((Bool, Bool) async -> RoomNotificationModeProxy)? + var canUserInviteUserIDClosure: ((String) async -> Result)? - func getDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy { - getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount += 1 - getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne) + func canUserInvite(userID: String) async -> Result { + canUserInviteUserIDCallsCount += 1 + canUserInviteUserIDReceivedUserID = userID DispatchQueue.main.async { - self.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne)) + self.canUserInviteUserIDReceivedInvocations.append(userID) } - if let getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure = getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure { - return await getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure(isEncrypted, isOneToOne) + if let canUserInviteUserIDClosure = canUserInviteUserIDClosure { + return await canUserInviteUserIDClosure(userID) } else { - return getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue + return canUserInviteUserIDReturnValue } } - //MARK: - setDefaultRoomNotificationMode + //MARK: - canUserRedactOther - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeThrowableError: Error? - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = 0 - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount: Int { + var canUserRedactOtherUserIDUnderlyingCallsCount = 0 + var canUserRedactOtherUserIDCallsCount: Int { get { if Thread.isMainThread { - return setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount + return canUserRedactOtherUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount + returnValue = canUserRedactOtherUserIDUnderlyingCallsCount } return returnValue! @@ -7190,44 +7173,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = newValue + canUserRedactOtherUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = newValue + canUserRedactOtherUserIDUnderlyingCallsCount = newValue } } } } - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCalled: Bool { - return setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount > 0 - } - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy)? - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy)] = [] - var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeClosure: ((Bool, Bool, RoomNotificationModeProxy) async throws -> Void)? - - func setDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy) async throws { - if let error = setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeThrowableError { - throw error - } - setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount += 1 - setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne, mode: mode) - DispatchQueue.main.async { - self.setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne, mode: mode)) - } - try await setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeClosure?(isEncrypted, isOneToOne, mode) + var canUserRedactOtherUserIDCalled: Bool { + return canUserRedactOtherUserIDCallsCount > 0 } - //MARK: - restoreDefaultNotificationMode + var canUserRedactOtherUserIDReceivedUserID: String? + var canUserRedactOtherUserIDReceivedInvocations: [String] = [] - var restoreDefaultNotificationModeRoomIdThrowableError: Error? - var restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = 0 - var restoreDefaultNotificationModeRoomIdCallsCount: Int { + var canUserRedactOtherUserIDUnderlyingReturnValue: Result! + var canUserRedactOtherUserIDReturnValue: Result! { get { if Thread.isMainThread { - return restoreDefaultNotificationModeRoomIdUnderlyingCallsCount + return canUserRedactOtherUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = restoreDefaultNotificationModeRoomIdUnderlyingCallsCount + returnValue = canUserRedactOtherUserIDUnderlyingReturnValue } return returnValue! @@ -7235,44 +7203,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = newValue + canUserRedactOtherUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = newValue + canUserRedactOtherUserIDUnderlyingReturnValue = newValue } } } } - var restoreDefaultNotificationModeRoomIdCalled: Bool { - return restoreDefaultNotificationModeRoomIdCallsCount > 0 - } - var restoreDefaultNotificationModeRoomIdReceivedRoomId: String? - var restoreDefaultNotificationModeRoomIdReceivedInvocations: [String] = [] - var restoreDefaultNotificationModeRoomIdClosure: ((String) async throws -> Void)? + var canUserRedactOtherUserIDClosure: ((String) async -> Result)? - func restoreDefaultNotificationMode(roomId: String) async throws { - if let error = restoreDefaultNotificationModeRoomIdThrowableError { - throw error - } - restoreDefaultNotificationModeRoomIdCallsCount += 1 - restoreDefaultNotificationModeRoomIdReceivedRoomId = roomId + func canUserRedactOther(userID: String) async -> Result { + canUserRedactOtherUserIDCallsCount += 1 + canUserRedactOtherUserIDReceivedUserID = userID DispatchQueue.main.async { - self.restoreDefaultNotificationModeRoomIdReceivedInvocations.append(roomId) + self.canUserRedactOtherUserIDReceivedInvocations.append(userID) + } + if let canUserRedactOtherUserIDClosure = canUserRedactOtherUserIDClosure { + return await canUserRedactOtherUserIDClosure(userID) + } else { + return canUserRedactOtherUserIDReturnValue } - try await restoreDefaultNotificationModeRoomIdClosure?(roomId) } - //MARK: - unmuteRoom + //MARK: - canUserRedactOwn - var unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError: Error? - var unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = 0 - var unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount: Int { + var canUserRedactOwnUserIDUnderlyingCallsCount = 0 + var canUserRedactOwnUserIDCallsCount: Int { get { if Thread.isMainThread { - return unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount + return canUserRedactOwnUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount + returnValue = canUserRedactOwnUserIDUnderlyingCallsCount } return returnValue! @@ -7280,44 +7243,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + canUserRedactOwnUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue + canUserRedactOwnUserIDUnderlyingCallsCount = newValue } } } } - var unmuteRoomRoomIdIsEncryptedIsOneToOneCalled: Bool { - return unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount > 0 - } - var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)? - var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = [] - var unmuteRoomRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> Void)? - - func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws { - if let error = unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError { - throw error - } - unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount += 1 - unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne) - DispatchQueue.main.async { - self.unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)) - } - try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne) + var canUserRedactOwnUserIDCalled: Bool { + return canUserRedactOwnUserIDCallsCount > 0 } - //MARK: - isRoomMentionEnabled + var canUserRedactOwnUserIDReceivedUserID: String? + var canUserRedactOwnUserIDReceivedInvocations: [String] = [] - var isRoomMentionEnabledThrowableError: Error? - var isRoomMentionEnabledUnderlyingCallsCount = 0 - var isRoomMentionEnabledCallsCount: Int { + var canUserRedactOwnUserIDUnderlyingReturnValue: Result! + var canUserRedactOwnUserIDReturnValue: Result! { get { if Thread.isMainThread { - return isRoomMentionEnabledUnderlyingCallsCount + return canUserRedactOwnUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = isRoomMentionEnabledUnderlyingCallsCount + returnValue = canUserRedactOwnUserIDUnderlyingReturnValue } return returnValue! @@ -7325,27 +7273,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isRoomMentionEnabledUnderlyingCallsCount = newValue + canUserRedactOwnUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - isRoomMentionEnabledUnderlyingCallsCount = newValue + canUserRedactOwnUserIDUnderlyingReturnValue = newValue } } } } - var isRoomMentionEnabledCalled: Bool { - return isRoomMentionEnabledCallsCount > 0 + var canUserRedactOwnUserIDClosure: ((String) async -> Result)? + + func canUserRedactOwn(userID: String) async -> Result { + canUserRedactOwnUserIDCallsCount += 1 + canUserRedactOwnUserIDReceivedUserID = userID + DispatchQueue.main.async { + self.canUserRedactOwnUserIDReceivedInvocations.append(userID) + } + if let canUserRedactOwnUserIDClosure = canUserRedactOwnUserIDClosure { + return await canUserRedactOwnUserIDClosure(userID) + } else { + return canUserRedactOwnUserIDReturnValue + } } + //MARK: - canUserKick - var isRoomMentionEnabledUnderlyingReturnValue: Bool! - var isRoomMentionEnabledReturnValue: Bool! { + var canUserKickUserIDUnderlyingCallsCount = 0 + var canUserKickUserIDCallsCount: Int { get { if Thread.isMainThread { - return isRoomMentionEnabledUnderlyingReturnValue + return canUserKickUserIDUnderlyingCallsCount } else { - var returnValue: Bool? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = isRoomMentionEnabledUnderlyingReturnValue + returnValue = canUserKickUserIDUnderlyingCallsCount } return returnValue! @@ -7353,39 +7313,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isRoomMentionEnabledUnderlyingReturnValue = newValue + canUserKickUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - isRoomMentionEnabledUnderlyingReturnValue = newValue + canUserKickUserIDUnderlyingCallsCount = newValue } } } } - var isRoomMentionEnabledClosure: (() async throws -> Bool)? - - func isRoomMentionEnabled() async throws -> Bool { - if let error = isRoomMentionEnabledThrowableError { - throw error - } - isRoomMentionEnabledCallsCount += 1 - if let isRoomMentionEnabledClosure = isRoomMentionEnabledClosure { - return try await isRoomMentionEnabledClosure() - } else { - return isRoomMentionEnabledReturnValue - } + var canUserKickUserIDCalled: Bool { + return canUserKickUserIDCallsCount > 0 } - //MARK: - setRoomMentionEnabled + var canUserKickUserIDReceivedUserID: String? + var canUserKickUserIDReceivedInvocations: [String] = [] - var setRoomMentionEnabledEnabledThrowableError: Error? - var setRoomMentionEnabledEnabledUnderlyingCallsCount = 0 - var setRoomMentionEnabledEnabledCallsCount: Int { + var canUserKickUserIDUnderlyingReturnValue: Result! + var canUserKickUserIDReturnValue: Result! { get { if Thread.isMainThread { - return setRoomMentionEnabledEnabledUnderlyingCallsCount + return canUserKickUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = setRoomMentionEnabledEnabledUnderlyingCallsCount + returnValue = canUserKickUserIDUnderlyingReturnValue } return returnValue! @@ -7393,44 +7343,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - setRoomMentionEnabledEnabledUnderlyingCallsCount = newValue + canUserKickUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setRoomMentionEnabledEnabledUnderlyingCallsCount = newValue + canUserKickUserIDUnderlyingReturnValue = newValue } } } } - var setRoomMentionEnabledEnabledCalled: Bool { - return setRoomMentionEnabledEnabledCallsCount > 0 - } - var setRoomMentionEnabledEnabledReceivedEnabled: Bool? - var setRoomMentionEnabledEnabledReceivedInvocations: [Bool] = [] - var setRoomMentionEnabledEnabledClosure: ((Bool) async throws -> Void)? + var canUserKickUserIDClosure: ((String) async -> Result)? - func setRoomMentionEnabled(enabled: Bool) async throws { - if let error = setRoomMentionEnabledEnabledThrowableError { - throw error - } - setRoomMentionEnabledEnabledCallsCount += 1 - setRoomMentionEnabledEnabledReceivedEnabled = enabled + func canUserKick(userID: String) async -> Result { + canUserKickUserIDCallsCount += 1 + canUserKickUserIDReceivedUserID = userID DispatchQueue.main.async { - self.setRoomMentionEnabledEnabledReceivedInvocations.append(enabled) + self.canUserKickUserIDReceivedInvocations.append(userID) + } + if let canUserKickUserIDClosure = canUserKickUserIDClosure { + return await canUserKickUserIDClosure(userID) + } else { + return canUserKickUserIDReturnValue } - try await setRoomMentionEnabledEnabledClosure?(enabled) } - //MARK: - isCallEnabled + //MARK: - canUserBan - var isCallEnabledThrowableError: Error? - var isCallEnabledUnderlyingCallsCount = 0 - var isCallEnabledCallsCount: Int { + var canUserBanUserIDUnderlyingCallsCount = 0 + var canUserBanUserIDCallsCount: Int { get { if Thread.isMainThread { - return isCallEnabledUnderlyingCallsCount + return canUserBanUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = isCallEnabledUnderlyingCallsCount + returnValue = canUserBanUserIDUnderlyingCallsCount } return returnValue! @@ -7438,27 +7383,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isCallEnabledUnderlyingCallsCount = newValue + canUserBanUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - isCallEnabledUnderlyingCallsCount = newValue + canUserBanUserIDUnderlyingCallsCount = newValue } } } } - var isCallEnabledCalled: Bool { - return isCallEnabledCallsCount > 0 + var canUserBanUserIDCalled: Bool { + return canUserBanUserIDCallsCount > 0 } + var canUserBanUserIDReceivedUserID: String? + var canUserBanUserIDReceivedInvocations: [String] = [] - var isCallEnabledUnderlyingReturnValue: Bool! - var isCallEnabledReturnValue: Bool! { + var canUserBanUserIDUnderlyingReturnValue: Result! + var canUserBanUserIDReturnValue: Result! { get { if Thread.isMainThread { - return isCallEnabledUnderlyingReturnValue + return canUserBanUserIDUnderlyingReturnValue } else { - var returnValue: Bool? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = isCallEnabledUnderlyingReturnValue + returnValue = canUserBanUserIDUnderlyingReturnValue } return returnValue! @@ -7466,39 +7413,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isCallEnabledUnderlyingReturnValue = newValue + canUserBanUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - isCallEnabledUnderlyingReturnValue = newValue + canUserBanUserIDUnderlyingReturnValue = newValue } } } } - var isCallEnabledClosure: (() async throws -> Bool)? + var canUserBanUserIDClosure: ((String) async -> Result)? - func isCallEnabled() async throws -> Bool { - if let error = isCallEnabledThrowableError { - throw error + func canUserBan(userID: String) async -> Result { + canUserBanUserIDCallsCount += 1 + canUserBanUserIDReceivedUserID = userID + DispatchQueue.main.async { + self.canUserBanUserIDReceivedInvocations.append(userID) } - isCallEnabledCallsCount += 1 - if let isCallEnabledClosure = isCallEnabledClosure { - return try await isCallEnabledClosure() + if let canUserBanUserIDClosure = canUserBanUserIDClosure { + return await canUserBanUserIDClosure(userID) } else { - return isCallEnabledReturnValue + return canUserBanUserIDReturnValue } } - //MARK: - setCallEnabled + //MARK: - canUserTriggerRoomNotification - var setCallEnabledEnabledThrowableError: Error? - var setCallEnabledEnabledUnderlyingCallsCount = 0 - var setCallEnabledEnabledCallsCount: Int { + var canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = 0 + var canUserTriggerRoomNotificationUserIDCallsCount: Int { get { if Thread.isMainThread { - return setCallEnabledEnabledUnderlyingCallsCount + return canUserTriggerRoomNotificationUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setCallEnabledEnabledUnderlyingCallsCount + returnValue = canUserTriggerRoomNotificationUserIDUnderlyingCallsCount } return returnValue! @@ -7506,44 +7453,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - setCallEnabledEnabledUnderlyingCallsCount = newValue + canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setCallEnabledEnabledUnderlyingCallsCount = newValue + canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = newValue } } } } - var setCallEnabledEnabledCalled: Bool { - return setCallEnabledEnabledCallsCount > 0 - } - var setCallEnabledEnabledReceivedEnabled: Bool? - var setCallEnabledEnabledReceivedInvocations: [Bool] = [] - var setCallEnabledEnabledClosure: ((Bool) async throws -> Void)? - - func setCallEnabled(enabled: Bool) async throws { - if let error = setCallEnabledEnabledThrowableError { - throw error - } - setCallEnabledEnabledCallsCount += 1 - setCallEnabledEnabledReceivedEnabled = enabled - DispatchQueue.main.async { - self.setCallEnabledEnabledReceivedInvocations.append(enabled) - } - try await setCallEnabledEnabledClosure?(enabled) + var canUserTriggerRoomNotificationUserIDCalled: Bool { + return canUserTriggerRoomNotificationUserIDCallsCount > 0 } - //MARK: - isInviteForMeEnabled + var canUserTriggerRoomNotificationUserIDReceivedUserID: String? + var canUserTriggerRoomNotificationUserIDReceivedInvocations: [String] = [] - var isInviteForMeEnabledThrowableError: Error? - var isInviteForMeEnabledUnderlyingCallsCount = 0 - var isInviteForMeEnabledCallsCount: Int { + var canUserTriggerRoomNotificationUserIDUnderlyingReturnValue: Result! + var canUserTriggerRoomNotificationUserIDReturnValue: Result! { get { if Thread.isMainThread { - return isInviteForMeEnabledUnderlyingCallsCount + return canUserTriggerRoomNotificationUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = isInviteForMeEnabledUnderlyingCallsCount + returnValue = canUserTriggerRoomNotificationUserIDUnderlyingReturnValue } return returnValue! @@ -7551,27 +7483,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isInviteForMeEnabledUnderlyingCallsCount = newValue + canUserTriggerRoomNotificationUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - isInviteForMeEnabledUnderlyingCallsCount = newValue + canUserTriggerRoomNotificationUserIDUnderlyingReturnValue = newValue } } } } - var isInviteForMeEnabledCalled: Bool { - return isInviteForMeEnabledCallsCount > 0 + var canUserTriggerRoomNotificationUserIDClosure: ((String) async -> Result)? + + func canUserTriggerRoomNotification(userID: String) async -> Result { + canUserTriggerRoomNotificationUserIDCallsCount += 1 + canUserTriggerRoomNotificationUserIDReceivedUserID = userID + DispatchQueue.main.async { + self.canUserTriggerRoomNotificationUserIDReceivedInvocations.append(userID) + } + if let canUserTriggerRoomNotificationUserIDClosure = canUserTriggerRoomNotificationUserIDClosure { + return await canUserTriggerRoomNotificationUserIDClosure(userID) + } else { + return canUserTriggerRoomNotificationUserIDReturnValue + } } + //MARK: - canUserPinOrUnpin - var isInviteForMeEnabledUnderlyingReturnValue: Bool! - var isInviteForMeEnabledReturnValue: Bool! { + var canUserPinOrUnpinUserIDUnderlyingCallsCount = 0 + var canUserPinOrUnpinUserIDCallsCount: Int { get { if Thread.isMainThread { - return isInviteForMeEnabledUnderlyingReturnValue + return canUserPinOrUnpinUserIDUnderlyingCallsCount } else { - var returnValue: Bool? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = isInviteForMeEnabledUnderlyingReturnValue + returnValue = canUserPinOrUnpinUserIDUnderlyingCallsCount } return returnValue! @@ -7579,39 +7523,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - isInviteForMeEnabledUnderlyingReturnValue = newValue + canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - isInviteForMeEnabledUnderlyingReturnValue = newValue + canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue } } } } - var isInviteForMeEnabledClosure: (() async throws -> Bool)? - - func isInviteForMeEnabled() async throws -> Bool { - if let error = isInviteForMeEnabledThrowableError { - throw error - } - isInviteForMeEnabledCallsCount += 1 - if let isInviteForMeEnabledClosure = isInviteForMeEnabledClosure { - return try await isInviteForMeEnabledClosure() - } else { - return isInviteForMeEnabledReturnValue - } + var canUserPinOrUnpinUserIDCalled: Bool { + return canUserPinOrUnpinUserIDCallsCount > 0 } - //MARK: - setInviteForMeEnabled + var canUserPinOrUnpinUserIDReceivedUserID: String? + var canUserPinOrUnpinUserIDReceivedInvocations: [String] = [] - var setInviteForMeEnabledEnabledThrowableError: Error? - var setInviteForMeEnabledEnabledUnderlyingCallsCount = 0 - var setInviteForMeEnabledEnabledCallsCount: Int { + var canUserPinOrUnpinUserIDUnderlyingReturnValue: Result! + var canUserPinOrUnpinUserIDReturnValue: Result! { get { if Thread.isMainThread { - return setInviteForMeEnabledEnabledUnderlyingCallsCount + return canUserPinOrUnpinUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = setInviteForMeEnabledEnabledUnderlyingCallsCount + returnValue = canUserPinOrUnpinUserIDUnderlyingReturnValue } return returnValue! @@ -7619,44 +7553,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - setInviteForMeEnabledEnabledUnderlyingCallsCount = newValue + canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setInviteForMeEnabledEnabledUnderlyingCallsCount = newValue + canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue } } } } - var setInviteForMeEnabledEnabledCalled: Bool { - return setInviteForMeEnabledEnabledCallsCount > 0 - } - var setInviteForMeEnabledEnabledReceivedEnabled: Bool? - var setInviteForMeEnabledEnabledReceivedInvocations: [Bool] = [] - var setInviteForMeEnabledEnabledClosure: ((Bool) async throws -> Void)? + var canUserPinOrUnpinUserIDClosure: ((String) async -> Result)? - func setInviteForMeEnabled(enabled: Bool) async throws { - if let error = setInviteForMeEnabledEnabledThrowableError { - throw error - } - setInviteForMeEnabledEnabledCallsCount += 1 - setInviteForMeEnabledEnabledReceivedEnabled = enabled + func canUserPinOrUnpin(userID: String) async -> Result { + canUserPinOrUnpinUserIDCallsCount += 1 + canUserPinOrUnpinUserIDReceivedUserID = userID DispatchQueue.main.async { - self.setInviteForMeEnabledEnabledReceivedInvocations.append(enabled) + self.canUserPinOrUnpinUserIDReceivedInvocations.append(userID) + } + if let canUserPinOrUnpinUserIDClosure = canUserPinOrUnpinUserIDClosure { + return await canUserPinOrUnpinUserIDClosure(userID) + } else { + return canUserPinOrUnpinUserIDReturnValue } - try await setInviteForMeEnabledEnabledClosure?(enabled) } - //MARK: - getRoomsWithUserDefinedRules + //MARK: - kickUser - var getRoomsWithUserDefinedRulesThrowableError: Error? - var getRoomsWithUserDefinedRulesUnderlyingCallsCount = 0 - var getRoomsWithUserDefinedRulesCallsCount: Int { + var kickUserUnderlyingCallsCount = 0 + var kickUserCallsCount: Int { get { if Thread.isMainThread { - return getRoomsWithUserDefinedRulesUnderlyingCallsCount + return kickUserUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getRoomsWithUserDefinedRulesUnderlyingCallsCount + returnValue = kickUserUnderlyingCallsCount } return returnValue! @@ -7664,27 +7593,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getRoomsWithUserDefinedRulesUnderlyingCallsCount = newValue + kickUserUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getRoomsWithUserDefinedRulesUnderlyingCallsCount = newValue + kickUserUnderlyingCallsCount = newValue } } } } - var getRoomsWithUserDefinedRulesCalled: Bool { - return getRoomsWithUserDefinedRulesCallsCount > 0 + var kickUserCalled: Bool { + return kickUserCallsCount > 0 } + var kickUserReceivedUserID: String? + var kickUserReceivedInvocations: [String] = [] - var getRoomsWithUserDefinedRulesUnderlyingReturnValue: [String]! - var getRoomsWithUserDefinedRulesReturnValue: [String]! { + var kickUserUnderlyingReturnValue: Result! + var kickUserReturnValue: Result! { get { if Thread.isMainThread { - return getRoomsWithUserDefinedRulesUnderlyingReturnValue + return kickUserUnderlyingReturnValue } else { - var returnValue: [String]? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = getRoomsWithUserDefinedRulesUnderlyingReturnValue + returnValue = kickUserUnderlyingReturnValue } return returnValue! @@ -7692,38 +7623,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - getRoomsWithUserDefinedRulesUnderlyingReturnValue = newValue + kickUserUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - getRoomsWithUserDefinedRulesUnderlyingReturnValue = newValue + kickUserUnderlyingReturnValue = newValue } } } } - var getRoomsWithUserDefinedRulesClosure: (() async throws -> [String])? + var kickUserClosure: ((String) async -> Result)? - func getRoomsWithUserDefinedRules() async throws -> [String] { - if let error = getRoomsWithUserDefinedRulesThrowableError { - throw error + func kickUser(_ userID: String) async -> Result { + kickUserCallsCount += 1 + kickUserReceivedUserID = userID + DispatchQueue.main.async { + self.kickUserReceivedInvocations.append(userID) } - getRoomsWithUserDefinedRulesCallsCount += 1 - if let getRoomsWithUserDefinedRulesClosure = getRoomsWithUserDefinedRulesClosure { - return try await getRoomsWithUserDefinedRulesClosure() + if let kickUserClosure = kickUserClosure { + return await kickUserClosure(userID) } else { - return getRoomsWithUserDefinedRulesReturnValue + return kickUserReturnValue } } - //MARK: - canPushEncryptedEventsToDevice + //MARK: - banUser - var canPushEncryptedEventsToDeviceUnderlyingCallsCount = 0 - var canPushEncryptedEventsToDeviceCallsCount: Int { + var banUserUnderlyingCallsCount = 0 + var banUserCallsCount: Int { get { if Thread.isMainThread { - return canPushEncryptedEventsToDeviceUnderlyingCallsCount + return banUserUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canPushEncryptedEventsToDeviceUnderlyingCallsCount + returnValue = banUserUnderlyingCallsCount } return returnValue! @@ -7731,27 +7663,29 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - canPushEncryptedEventsToDeviceUnderlyingCallsCount = newValue + banUserUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canPushEncryptedEventsToDeviceUnderlyingCallsCount = newValue + banUserUnderlyingCallsCount = newValue } } } } - var canPushEncryptedEventsToDeviceCalled: Bool { - return canPushEncryptedEventsToDeviceCallsCount > 0 + var banUserCalled: Bool { + return banUserCallsCount > 0 } + var banUserReceivedUserID: String? + var banUserReceivedInvocations: [String] = [] - var canPushEncryptedEventsToDeviceUnderlyingReturnValue: Bool! - var canPushEncryptedEventsToDeviceReturnValue: Bool! { + var banUserUnderlyingReturnValue: Result! + var banUserReturnValue: Result! { get { if Thread.isMainThread { - return canPushEncryptedEventsToDeviceUnderlyingReturnValue + return banUserUnderlyingReturnValue } else { - var returnValue: Bool? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = canPushEncryptedEventsToDeviceUnderlyingReturnValue + returnValue = banUserUnderlyingReturnValue } return returnValue! @@ -7759,38 +7693,39 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { } set { if Thread.isMainThread { - canPushEncryptedEventsToDeviceUnderlyingReturnValue = newValue + banUserUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canPushEncryptedEventsToDeviceUnderlyingReturnValue = newValue + banUserUnderlyingReturnValue = newValue } } } } - var canPushEncryptedEventsToDeviceClosure: (() async -> Bool)? + var banUserClosure: ((String) async -> Result)? - func canPushEncryptedEventsToDevice() async -> Bool { - canPushEncryptedEventsToDeviceCallsCount += 1 - if let canPushEncryptedEventsToDeviceClosure = canPushEncryptedEventsToDeviceClosure { - return await canPushEncryptedEventsToDeviceClosure() + func banUser(_ userID: String) async -> Result { + banUserCallsCount += 1 + banUserReceivedUserID = userID + DispatchQueue.main.async { + self.banUserReceivedInvocations.append(userID) + } + if let banUserClosure = banUserClosure { + return await banUserClosure(userID) } else { - return canPushEncryptedEventsToDeviceReturnValue + return banUserReturnValue } } -} -class OrientationManagerMock: OrientationManagerProtocol { - - //MARK: - setOrientation + //MARK: - unbanUser - var setOrientationUnderlyingCallsCount = 0 - var setOrientationCallsCount: Int { + var unbanUserUnderlyingCallsCount = 0 + var unbanUserCallsCount: Int { get { if Thread.isMainThread { - return setOrientationUnderlyingCallsCount + return unbanUserUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setOrientationUnderlyingCallsCount + returnValue = unbanUserUnderlyingCallsCount } return returnValue! @@ -7798,40 +7733,69 @@ class OrientationManagerMock: OrientationManagerProtocol { } set { if Thread.isMainThread { - setOrientationUnderlyingCallsCount = newValue + unbanUserUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setOrientationUnderlyingCallsCount = newValue + unbanUserUnderlyingCallsCount = newValue } } } } - var setOrientationCalled: Bool { - return setOrientationCallsCount > 0 + var unbanUserCalled: Bool { + return unbanUserCallsCount > 0 } - var setOrientationReceivedOrientation: UIInterfaceOrientationMask? - var setOrientationReceivedInvocations: [UIInterfaceOrientationMask] = [] - var setOrientationClosure: ((UIInterfaceOrientationMask) -> Void)? + var unbanUserReceivedUserID: String? + var unbanUserReceivedInvocations: [String] = [] - func setOrientation(_ orientation: UIInterfaceOrientationMask) { - setOrientationCallsCount += 1 - setOrientationReceivedOrientation = orientation + var unbanUserUnderlyingReturnValue: Result! + var unbanUserReturnValue: Result! { + get { + if Thread.isMainThread { + return unbanUserUnderlyingReturnValue + } else { + var returnValue: Result? = nil + DispatchQueue.main.sync { + returnValue = unbanUserUnderlyingReturnValue + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + unbanUserUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + unbanUserUnderlyingReturnValue = newValue + } + } + } + } + var unbanUserClosure: ((String) async -> Result)? + + func unbanUser(_ userID: String) async -> Result { + unbanUserCallsCount += 1 + unbanUserReceivedUserID = userID DispatchQueue.main.async { - self.setOrientationReceivedInvocations.append(orientation) + self.unbanUserReceivedInvocations.append(userID) + } + if let unbanUserClosure = unbanUserClosure { + return await unbanUserClosure(userID) + } else { + return unbanUserReturnValue } - setOrientationClosure?(orientation) } - //MARK: - lockOrientation + //MARK: - canUserJoinCall - var lockOrientationUnderlyingCallsCount = 0 - var lockOrientationCallsCount: Int { + var canUserJoinCallUserIDUnderlyingCallsCount = 0 + var canUserJoinCallUserIDCallsCount: Int { get { if Thread.isMainThread { - return lockOrientationUnderlyingCallsCount + return canUserJoinCallUserIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = lockOrientationUnderlyingCallsCount + returnValue = canUserJoinCallUserIDUnderlyingCallsCount } return returnValue! @@ -7839,43 +7803,29 @@ class OrientationManagerMock: OrientationManagerProtocol { } set { if Thread.isMainThread { - lockOrientationUnderlyingCallsCount = newValue + canUserJoinCallUserIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - lockOrientationUnderlyingCallsCount = newValue + canUserJoinCallUserIDUnderlyingCallsCount = newValue } } } } - var lockOrientationCalled: Bool { - return lockOrientationCallsCount > 0 - } - var lockOrientationReceivedOrientation: UIInterfaceOrientationMask? - var lockOrientationReceivedInvocations: [UIInterfaceOrientationMask] = [] - var lockOrientationClosure: ((UIInterfaceOrientationMask) -> Void)? - - func lockOrientation(_ orientation: UIInterfaceOrientationMask) { - lockOrientationCallsCount += 1 - lockOrientationReceivedOrientation = orientation - DispatchQueue.main.async { - self.lockOrientationReceivedInvocations.append(orientation) - } - lockOrientationClosure?(orientation) + var canUserJoinCallUserIDCalled: Bool { + return canUserJoinCallUserIDCallsCount > 0 } -} -class PHGPostHogMock: PHGPostHogProtocol { - - //MARK: - optIn + var canUserJoinCallUserIDReceivedUserID: String? + var canUserJoinCallUserIDReceivedInvocations: [String] = [] - var optInUnderlyingCallsCount = 0 - var optInCallsCount: Int { + var canUserJoinCallUserIDUnderlyingReturnValue: Result! + var canUserJoinCallUserIDReturnValue: Result! { get { if Thread.isMainThread { - return optInUnderlyingCallsCount + return canUserJoinCallUserIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = optInUnderlyingCallsCount + returnValue = canUserJoinCallUserIDUnderlyingReturnValue } return returnValue! @@ -7883,34 +7833,39 @@ class PHGPostHogMock: PHGPostHogProtocol { } set { if Thread.isMainThread { - optInUnderlyingCallsCount = newValue + canUserJoinCallUserIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - optInUnderlyingCallsCount = newValue + canUserJoinCallUserIDUnderlyingReturnValue = newValue } } } } - var optInCalled: Bool { - return optInCallsCount > 0 - } - var optInClosure: (() -> Void)? + var canUserJoinCallUserIDClosure: ((String) async -> Result)? - func optIn() { - optInCallsCount += 1 - optInClosure?() + func canUserJoinCall(userID: String) async -> Result { + canUserJoinCallUserIDCallsCount += 1 + canUserJoinCallUserIDReceivedUserID = userID + DispatchQueue.main.async { + self.canUserJoinCallUserIDReceivedInvocations.append(userID) + } + if let canUserJoinCallUserIDClosure = canUserJoinCallUserIDClosure { + return await canUserJoinCallUserIDClosure(userID) + } else { + return canUserJoinCallUserIDReturnValue + } } - //MARK: - optOut + //MARK: - elementCallWidgetDriver - var optOutUnderlyingCallsCount = 0 - var optOutCallsCount: Int { + var elementCallWidgetDriverDeviceIDUnderlyingCallsCount = 0 + var elementCallWidgetDriverDeviceIDCallsCount: Int { get { if Thread.isMainThread { - return optOutUnderlyingCallsCount + return elementCallWidgetDriverDeviceIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = optOutUnderlyingCallsCount + returnValue = elementCallWidgetDriverDeviceIDUnderlyingCallsCount } return returnValue! @@ -7918,34 +7873,29 @@ class PHGPostHogMock: PHGPostHogProtocol { } set { if Thread.isMainThread { - optOutUnderlyingCallsCount = newValue + elementCallWidgetDriverDeviceIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - optOutUnderlyingCallsCount = newValue + elementCallWidgetDriverDeviceIDUnderlyingCallsCount = newValue } } } } - var optOutCalled: Bool { - return optOutCallsCount > 0 - } - var optOutClosure: (() -> Void)? - - func optOut() { - optOutCallsCount += 1 - optOutClosure?() + var elementCallWidgetDriverDeviceIDCalled: Bool { + return elementCallWidgetDriverDeviceIDCallsCount > 0 } - //MARK: - reset + var elementCallWidgetDriverDeviceIDReceivedDeviceID: String? + var elementCallWidgetDriverDeviceIDReceivedInvocations: [String] = [] - var resetUnderlyingCallsCount = 0 - var resetCallsCount: Int { + var elementCallWidgetDriverDeviceIDUnderlyingReturnValue: ElementCallWidgetDriverProtocol! + var elementCallWidgetDriverDeviceIDReturnValue: ElementCallWidgetDriverProtocol! { get { if Thread.isMainThread { - return resetUnderlyingCallsCount + return elementCallWidgetDriverDeviceIDUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: ElementCallWidgetDriverProtocol? = nil DispatchQueue.main.sync { - returnValue = resetUnderlyingCallsCount + returnValue = elementCallWidgetDriverDeviceIDUnderlyingReturnValue } return returnValue! @@ -7953,34 +7903,39 @@ class PHGPostHogMock: PHGPostHogProtocol { } set { if Thread.isMainThread { - resetUnderlyingCallsCount = newValue + elementCallWidgetDriverDeviceIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - resetUnderlyingCallsCount = newValue + elementCallWidgetDriverDeviceIDUnderlyingReturnValue = newValue } } } } - var resetCalled: Bool { - return resetCallsCount > 0 - } - var resetClosure: (() -> Void)? + var elementCallWidgetDriverDeviceIDClosure: ((String) -> ElementCallWidgetDriverProtocol)? - func reset() { - resetCallsCount += 1 - resetClosure?() + func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol { + elementCallWidgetDriverDeviceIDCallsCount += 1 + elementCallWidgetDriverDeviceIDReceivedDeviceID = deviceID + DispatchQueue.main.async { + self.elementCallWidgetDriverDeviceIDReceivedInvocations.append(deviceID) + } + if let elementCallWidgetDriverDeviceIDClosure = elementCallWidgetDriverDeviceIDClosure { + return elementCallWidgetDriverDeviceIDClosure(deviceID) + } else { + return elementCallWidgetDriverDeviceIDReturnValue + } } - //MARK: - capture + //MARK: - sendCallNotificationIfNeeded - var capturePropertiesUserPropertiesUnderlyingCallsCount = 0 - var capturePropertiesUserPropertiesCallsCount: Int { + var sendCallNotificationIfNeededUnderlyingCallsCount = 0 + var sendCallNotificationIfNeededCallsCount: Int { get { if Thread.isMainThread { - return capturePropertiesUserPropertiesUnderlyingCallsCount + return sendCallNotificationIfNeededUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = capturePropertiesUserPropertiesUnderlyingCallsCount + returnValue = sendCallNotificationIfNeededUnderlyingCallsCount } return returnValue! @@ -7988,40 +7943,27 @@ class PHGPostHogMock: PHGPostHogProtocol { } set { if Thread.isMainThread { - capturePropertiesUserPropertiesUnderlyingCallsCount = newValue + sendCallNotificationIfNeededUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - capturePropertiesUserPropertiesUnderlyingCallsCount = newValue + sendCallNotificationIfNeededUnderlyingCallsCount = newValue } } } } - var capturePropertiesUserPropertiesCalled: Bool { - return capturePropertiesUserPropertiesCallsCount > 0 - } - var capturePropertiesUserPropertiesReceivedArguments: (event: String, properties: [String: Any]?, userProperties: [String: Any]?)? - var capturePropertiesUserPropertiesReceivedInvocations: [(event: String, properties: [String: Any]?, userProperties: [String: Any]?)] = [] - var capturePropertiesUserPropertiesClosure: ((String, [String: Any]?, [String: Any]?) -> Void)? - - func capture(_ event: String, properties: [String: Any]?, userProperties: [String: Any]?) { - capturePropertiesUserPropertiesCallsCount += 1 - capturePropertiesUserPropertiesReceivedArguments = (event: event, properties: properties, userProperties: userProperties) - DispatchQueue.main.async { - self.capturePropertiesUserPropertiesReceivedInvocations.append((event: event, properties: properties, userProperties: userProperties)) - } - capturePropertiesUserPropertiesClosure?(event, properties, userProperties) + var sendCallNotificationIfNeededCalled: Bool { + return sendCallNotificationIfNeededCallsCount > 0 } - //MARK: - screen - var screenPropertiesUnderlyingCallsCount = 0 - var screenPropertiesCallsCount: Int { + var sendCallNotificationIfNeededUnderlyingReturnValue: Result! + var sendCallNotificationIfNeededReturnValue: Result! { get { if Thread.isMainThread { - return screenPropertiesUnderlyingCallsCount + return sendCallNotificationIfNeededUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = screenPropertiesUnderlyingCallsCount + returnValue = sendCallNotificationIfNeededUnderlyingReturnValue } return returnValue! @@ -8029,43 +7971,35 @@ class PHGPostHogMock: PHGPostHogProtocol { } set { if Thread.isMainThread { - screenPropertiesUnderlyingCallsCount = newValue + sendCallNotificationIfNeededUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - screenPropertiesUnderlyingCallsCount = newValue + sendCallNotificationIfNeededUnderlyingReturnValue = newValue } } } } - var screenPropertiesCalled: Bool { - return screenPropertiesCallsCount > 0 - } - var screenPropertiesReceivedArguments: (screenTitle: String, properties: [String: Any]?)? - var screenPropertiesReceivedInvocations: [(screenTitle: String, properties: [String: Any]?)] = [] - var screenPropertiesClosure: ((String, [String: Any]?) -> Void)? + var sendCallNotificationIfNeededClosure: (() async -> Result)? - func screen(_ screenTitle: String, properties: [String: Any]?) { - screenPropertiesCallsCount += 1 - screenPropertiesReceivedArguments = (screenTitle: screenTitle, properties: properties) - DispatchQueue.main.async { - self.screenPropertiesReceivedInvocations.append((screenTitle: screenTitle, properties: properties)) + func sendCallNotificationIfNeeded() async -> Result { + sendCallNotificationIfNeededCallsCount += 1 + if let sendCallNotificationIfNeededClosure = sendCallNotificationIfNeededClosure { + return await sendCallNotificationIfNeededClosure() + } else { + return sendCallNotificationIfNeededReturnValue } - screenPropertiesClosure?(screenTitle, properties) } -} -class PollInteractionHandlerMock: PollInteractionHandlerProtocol { - - //MARK: - sendPollResponse + //MARK: - matrixToPermalink - var sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = 0 - var sendPollResponsePollStartIDOptionIDCallsCount: Int { + var matrixToPermalinkUnderlyingCallsCount = 0 + var matrixToPermalinkCallsCount: Int { get { if Thread.isMainThread { - return sendPollResponsePollStartIDOptionIDUnderlyingCallsCount + return matrixToPermalinkUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = sendPollResponsePollStartIDOptionIDUnderlyingCallsCount + returnValue = matrixToPermalinkUnderlyingCallsCount } return returnValue! @@ -8073,29 +8007,27 @@ class PollInteractionHandlerMock: PollInteractionHandlerProtocol { } set { if Thread.isMainThread { - sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = newValue + matrixToPermalinkUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = newValue + matrixToPermalinkUnderlyingCallsCount = newValue } } } } - var sendPollResponsePollStartIDOptionIDCalled: Bool { - return sendPollResponsePollStartIDOptionIDCallsCount > 0 + var matrixToPermalinkCalled: Bool { + return matrixToPermalinkCallsCount > 0 } - var sendPollResponsePollStartIDOptionIDReceivedArguments: (pollStartID: String, optionID: String)? - var sendPollResponsePollStartIDOptionIDReceivedInvocations: [(pollStartID: String, optionID: String)] = [] - var sendPollResponsePollStartIDOptionIDUnderlyingReturnValue: Result! - var sendPollResponsePollStartIDOptionIDReturnValue: Result! { + var matrixToPermalinkUnderlyingReturnValue: Result! + var matrixToPermalinkReturnValue: Result! { get { if Thread.isMainThread { - return sendPollResponsePollStartIDOptionIDUnderlyingReturnValue + return matrixToPermalinkUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = sendPollResponsePollStartIDOptionIDUnderlyingReturnValue + returnValue = matrixToPermalinkUnderlyingReturnValue } return returnValue! @@ -8103,39 +8035,35 @@ class PollInteractionHandlerMock: PollInteractionHandlerProtocol { } set { if Thread.isMainThread { - sendPollResponsePollStartIDOptionIDUnderlyingReturnValue = newValue + matrixToPermalinkUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - sendPollResponsePollStartIDOptionIDUnderlyingReturnValue = newValue + matrixToPermalinkUnderlyingReturnValue = newValue } } } } - var sendPollResponsePollStartIDOptionIDClosure: ((String, String) async -> Result)? + var matrixToPermalinkClosure: (() async -> Result)? - func sendPollResponse(pollStartID: String, optionID: String) async -> Result { - sendPollResponsePollStartIDOptionIDCallsCount += 1 - sendPollResponsePollStartIDOptionIDReceivedArguments = (pollStartID: pollStartID, optionID: optionID) - DispatchQueue.main.async { - self.sendPollResponsePollStartIDOptionIDReceivedInvocations.append((pollStartID: pollStartID, optionID: optionID)) - } - if let sendPollResponsePollStartIDOptionIDClosure = sendPollResponsePollStartIDOptionIDClosure { - return await sendPollResponsePollStartIDOptionIDClosure(pollStartID, optionID) + func matrixToPermalink() async -> Result { + matrixToPermalinkCallsCount += 1 + if let matrixToPermalinkClosure = matrixToPermalinkClosure { + return await matrixToPermalinkClosure() } else { - return sendPollResponsePollStartIDOptionIDReturnValue + return matrixToPermalinkReturnValue } } - //MARK: - endPoll + //MARK: - matrixToEventPermalink - var endPollPollStartIDUnderlyingCallsCount = 0 - var endPollPollStartIDCallsCount: Int { + var matrixToEventPermalinkUnderlyingCallsCount = 0 + var matrixToEventPermalinkCallsCount: Int { get { if Thread.isMainThread { - return endPollPollStartIDUnderlyingCallsCount + return matrixToEventPermalinkUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = endPollPollStartIDUnderlyingCallsCount + returnValue = matrixToEventPermalinkUnderlyingCallsCount } return returnValue! @@ -8143,29 +8071,29 @@ class PollInteractionHandlerMock: PollInteractionHandlerProtocol { } set { if Thread.isMainThread { - endPollPollStartIDUnderlyingCallsCount = newValue + matrixToEventPermalinkUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - endPollPollStartIDUnderlyingCallsCount = newValue + matrixToEventPermalinkUnderlyingCallsCount = newValue } } } } - var endPollPollStartIDCalled: Bool { - return endPollPollStartIDCallsCount > 0 + var matrixToEventPermalinkCalled: Bool { + return matrixToEventPermalinkCallsCount > 0 } - var endPollPollStartIDReceivedPollStartID: String? - var endPollPollStartIDReceivedInvocations: [String] = [] + var matrixToEventPermalinkReceivedEventID: String? + var matrixToEventPermalinkReceivedInvocations: [String] = [] - var endPollPollStartIDUnderlyingReturnValue: Result! - var endPollPollStartIDReturnValue: Result! { + var matrixToEventPermalinkUnderlyingReturnValue: Result! + var matrixToEventPermalinkReturnValue: Result! { get { if Thread.isMainThread { - return endPollPollStartIDUnderlyingReturnValue + return matrixToEventPermalinkUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = endPollPollStartIDUnderlyingReturnValue + returnValue = matrixToEventPermalinkUnderlyingReturnValue } return returnValue! @@ -8173,47 +8101,39 @@ class PollInteractionHandlerMock: PollInteractionHandlerProtocol { } set { if Thread.isMainThread { - endPollPollStartIDUnderlyingReturnValue = newValue + matrixToEventPermalinkUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - endPollPollStartIDUnderlyingReturnValue = newValue + matrixToEventPermalinkUnderlyingReturnValue = newValue } } } } - var endPollPollStartIDClosure: ((String) async -> Result)? + var matrixToEventPermalinkClosure: ((String) async -> Result)? - func endPoll(pollStartID: String) async -> Result { - endPollPollStartIDCallsCount += 1 - endPollPollStartIDReceivedPollStartID = pollStartID + func matrixToEventPermalink(_ eventID: String) async -> Result { + matrixToEventPermalinkCallsCount += 1 + matrixToEventPermalinkReceivedEventID = eventID DispatchQueue.main.async { - self.endPollPollStartIDReceivedInvocations.append(pollStartID) - } - if let endPollPollStartIDClosure = endPollPollStartIDClosure { - return await endPollPollStartIDClosure(pollStartID) - } else { - return endPollPollStartIDReturnValue + self.matrixToEventPermalinkReceivedInvocations.append(eventID) + } + if let matrixToEventPermalinkClosure = matrixToEventPermalinkClosure { + return await matrixToEventPermalinkClosure(eventID) + } else { + return matrixToEventPermalinkReturnValue } } -} -class QRCodeLoginServiceMock: QRCodeLoginServiceProtocol { - var qrLoginProgressPublisher: AnyPublisher { - get { return underlyingQrLoginProgressPublisher } - set(value) { underlyingQrLoginProgressPublisher = value } - } - var underlyingQrLoginProgressPublisher: AnyPublisher! - - //MARK: - loginWithQRCode + //MARK: - saveDraft - var loginWithQRCodeDataUnderlyingCallsCount = 0 - var loginWithQRCodeDataCallsCount: Int { + var saveDraftUnderlyingCallsCount = 0 + var saveDraftCallsCount: Int { get { if Thread.isMainThread { - return loginWithQRCodeDataUnderlyingCallsCount + return saveDraftUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loginWithQRCodeDataUnderlyingCallsCount + returnValue = saveDraftUnderlyingCallsCount } return returnValue! @@ -8221,29 +8141,29 @@ class QRCodeLoginServiceMock: QRCodeLoginServiceProtocol { } set { if Thread.isMainThread { - loginWithQRCodeDataUnderlyingCallsCount = newValue + saveDraftUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loginWithQRCodeDataUnderlyingCallsCount = newValue + saveDraftUnderlyingCallsCount = newValue } } } } - var loginWithQRCodeDataCalled: Bool { - return loginWithQRCodeDataCallsCount > 0 + var saveDraftCalled: Bool { + return saveDraftCallsCount > 0 } - var loginWithQRCodeDataReceivedData: Data? - var loginWithQRCodeDataReceivedInvocations: [Data] = [] + var saveDraftReceivedDraft: ComposerDraft? + var saveDraftReceivedInvocations: [ComposerDraft] = [] - var loginWithQRCodeDataUnderlyingReturnValue: Result! - var loginWithQRCodeDataReturnValue: Result! { + var saveDraftUnderlyingReturnValue: Result! + var saveDraftReturnValue: Result! { get { if Thread.isMainThread { - return loginWithQRCodeDataUnderlyingReturnValue + return saveDraftUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = loginWithQRCodeDataUnderlyingReturnValue + returnValue = saveDraftUnderlyingReturnValue } return returnValue! @@ -8251,47 +8171,39 @@ class QRCodeLoginServiceMock: QRCodeLoginServiceProtocol { } set { if Thread.isMainThread { - loginWithQRCodeDataUnderlyingReturnValue = newValue + saveDraftUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - loginWithQRCodeDataUnderlyingReturnValue = newValue + saveDraftUnderlyingReturnValue = newValue } } } } - var loginWithQRCodeDataClosure: ((Data) async -> Result)? + var saveDraftClosure: ((ComposerDraft) async -> Result)? - func loginWithQRCode(data: Data) async -> Result { - loginWithQRCodeDataCallsCount += 1 - loginWithQRCodeDataReceivedData = data + func saveDraft(_ draft: ComposerDraft) async -> Result { + saveDraftCallsCount += 1 + saveDraftReceivedDraft = draft DispatchQueue.main.async { - self.loginWithQRCodeDataReceivedInvocations.append(data) + self.saveDraftReceivedInvocations.append(draft) } - if let loginWithQRCodeDataClosure = loginWithQRCodeDataClosure { - return await loginWithQRCodeDataClosure(data) + if let saveDraftClosure = saveDraftClosure { + return await saveDraftClosure(draft) } else { - return loginWithQRCodeDataReturnValue + return saveDraftReturnValue } } -} -class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { - var resultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never> { - get { return underlyingResultsPublisher } - set(value) { underlyingResultsPublisher = value } - } - var underlyingResultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never>! - - //MARK: - search + //MARK: - loadDraft - var searchQueryUnderlyingCallsCount = 0 - var searchQueryCallsCount: Int { + var loadDraftUnderlyingCallsCount = 0 + var loadDraftCallsCount: Int { get { if Thread.isMainThread { - return searchQueryUnderlyingCallsCount + return loadDraftUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = searchQueryUnderlyingCallsCount + returnValue = loadDraftUnderlyingCallsCount } return returnValue! @@ -8299,29 +8211,27 @@ class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { } set { if Thread.isMainThread { - searchQueryUnderlyingCallsCount = newValue + loadDraftUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - searchQueryUnderlyingCallsCount = newValue + loadDraftUnderlyingCallsCount = newValue } } } } - var searchQueryCalled: Bool { - return searchQueryCallsCount > 0 + var loadDraftCalled: Bool { + return loadDraftCallsCount > 0 } - var searchQueryReceivedQuery: String? - var searchQueryReceivedInvocations: [String?] = [] - var searchQueryUnderlyingReturnValue: Result! - var searchQueryReturnValue: Result! { + var loadDraftUnderlyingReturnValue: Result! + var loadDraftReturnValue: Result! { get { if Thread.isMainThread { - return searchQueryUnderlyingReturnValue + return loadDraftUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = searchQueryUnderlyingReturnValue + returnValue = loadDraftUnderlyingReturnValue } return returnValue! @@ -8329,39 +8239,35 @@ class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { } set { if Thread.isMainThread { - searchQueryUnderlyingReturnValue = newValue + loadDraftUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - searchQueryUnderlyingReturnValue = newValue + loadDraftUnderlyingReturnValue = newValue } } } } - var searchQueryClosure: ((String?) async -> Result)? + var loadDraftClosure: (() async -> Result)? - func search(query: String?) async -> Result { - searchQueryCallsCount += 1 - searchQueryReceivedQuery = query - DispatchQueue.main.async { - self.searchQueryReceivedInvocations.append(query) - } - if let searchQueryClosure = searchQueryClosure { - return await searchQueryClosure(query) + func loadDraft() async -> Result { + loadDraftCallsCount += 1 + if let loadDraftClosure = loadDraftClosure { + return await loadDraftClosure() } else { - return searchQueryReturnValue + return loadDraftReturnValue } } - //MARK: - nextPage + //MARK: - clearDraft - var nextPageUnderlyingCallsCount = 0 - var nextPageCallsCount: Int { + var clearDraftUnderlyingCallsCount = 0 + var clearDraftCallsCount: Int { get { if Thread.isMainThread { - return nextPageUnderlyingCallsCount + return clearDraftUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = nextPageUnderlyingCallsCount + returnValue = clearDraftUnderlyingCallsCount } return returnValue! @@ -8369,27 +8275,27 @@ class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { } set { if Thread.isMainThread { - nextPageUnderlyingCallsCount = newValue + clearDraftUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - nextPageUnderlyingCallsCount = newValue + clearDraftUnderlyingCallsCount = newValue } } } } - var nextPageCalled: Bool { - return nextPageCallsCount > 0 + var clearDraftCalled: Bool { + return clearDraftCallsCount > 0 } - var nextPageUnderlyingReturnValue: Result! - var nextPageReturnValue: Result! { + var clearDraftUnderlyingReturnValue: Result! + var clearDraftReturnValue: Result! { get { if Thread.isMainThread { - return nextPageUnderlyingReturnValue + return clearDraftUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = nextPageUnderlyingReturnValue + returnValue = clearDraftUnderlyingReturnValue } return returnValue! @@ -8397,229 +8303,107 @@ class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { } set { if Thread.isMainThread { - nextPageUnderlyingReturnValue = newValue + clearDraftUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - nextPageUnderlyingReturnValue = newValue + clearDraftUnderlyingReturnValue = newValue } } } } - var nextPageClosure: (() async -> Result)? + var clearDraftClosure: (() async -> Result)? - func nextPage() async -> Result { - nextPageCallsCount += 1 - if let nextPageClosure = nextPageClosure { - return await nextPageClosure() + func clearDraft() async -> Result { + clearDraftCallsCount += 1 + if let clearDraftClosure = clearDraftClosure { + return await clearDraftClosure() } else { - return nextPageReturnValue + return clearDraftReturnValue } } } -class RoomMemberProxyMock: RoomMemberProxyProtocol { - var userID: String { - get { return underlyingUserID } - set(value) { underlyingUserID = value } - } - var underlyingUserID: String! - var displayName: String? - var avatarURL: URL? - var membership: MembershipState { - get { return underlyingMembership } - set(value) { underlyingMembership = value } - } - var underlyingMembership: MembershipState! - var isIgnored: Bool { - get { return underlyingIsIgnored } - set(value) { underlyingIsIgnored = value } - } - var underlyingIsIgnored: Bool! - var powerLevel: Int { - get { return underlyingPowerLevel } - set(value) { underlyingPowerLevel = value } - } - var underlyingPowerLevel: Int! - var role: RoomMemberRole { - get { return underlyingRole } - set(value) { underlyingRole = value } - } - var underlyingRole: RoomMemberRole! - -} -class RoomNotificationSettingsProxyMock: RoomNotificationSettingsProxyProtocol { - var mode: RoomNotificationModeProxy { - get { return underlyingMode } - set(value) { underlyingMode = value } - } - var underlyingMode: RoomNotificationModeProxy! - var isDefault: Bool { - get { return underlyingIsDefault } - set(value) { underlyingIsDefault = value } - } - var underlyingIsDefault: Bool! +class KeychainControllerMock: KeychainControllerProtocol { -} -class RoomProxyMock: RoomProxyProtocol { - var id: String { - get { return underlyingId } - set(value) { underlyingId = value } - } - var underlyingId: String! - var isDirect: Bool { - get { return underlyingIsDirect } - set(value) { underlyingIsDirect = value } - } - var underlyingIsDirect: Bool! - var isPublic: Bool { - get { return underlyingIsPublic } - set(value) { underlyingIsPublic = value } - } - var underlyingIsPublic: Bool! - var isSpace: Bool { - get { return underlyingIsSpace } - set(value) { underlyingIsSpace = value } - } - var underlyingIsSpace: Bool! - var isEncrypted: Bool { - get { return underlyingIsEncrypted } - set(value) { underlyingIsEncrypted = value } - } - var underlyingIsEncrypted: Bool! - var isFavouriteCallsCount = 0 - var isFavouriteCalled: Bool { - return isFavouriteCallsCount > 0 - } + //MARK: - setRestorationToken - var isFavourite: Bool { - get async { - isFavouriteCallsCount += 1 - if let isFavouriteClosure = isFavouriteClosure { - return await isFavouriteClosure() + var setRestorationTokenForUsernameUnderlyingCallsCount = 0 + var setRestorationTokenForUsernameCallsCount: Int { + get { + if Thread.isMainThread { + return setRestorationTokenForUsernameUnderlyingCallsCount } else { - return underlyingIsFavourite - } - } - } - var underlyingIsFavourite: Bool! - var isFavouriteClosure: (() async -> Bool)? - var pinnedEventIDsCallsCount = 0 - var pinnedEventIDsCalled: Bool { - return pinnedEventIDsCallsCount > 0 - } + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = setRestorationTokenForUsernameUnderlyingCallsCount + } - var pinnedEventIDs: Set { - get async { - pinnedEventIDsCallsCount += 1 - if let pinnedEventIDsClosure = pinnedEventIDsClosure { - return await pinnedEventIDsClosure() + return returnValue! + } + } + set { + if Thread.isMainThread { + setRestorationTokenForUsernameUnderlyingCallsCount = newValue } else { - return underlyingPinnedEventIDs + DispatchQueue.main.sync { + setRestorationTokenForUsernameUnderlyingCallsCount = newValue + } } } } - var underlyingPinnedEventIDs: Set! - var pinnedEventIDsClosure: (() async -> Set)? - var membership: Membership { - get { return underlyingMembership } - set(value) { underlyingMembership = value } + var setRestorationTokenForUsernameCalled: Bool { + return setRestorationTokenForUsernameCallsCount > 0 } - var underlyingMembership: Membership! - var inviterCallsCount = 0 - var inviterCalled: Bool { - return inviterCallsCount > 0 + var setRestorationTokenForUsernameReceivedArguments: (restorationToken: RestorationToken, forUsername: String)? + var setRestorationTokenForUsernameReceivedInvocations: [(restorationToken: RestorationToken, forUsername: String)] = [] + var setRestorationTokenForUsernameClosure: ((RestorationToken, String) -> Void)? + + func setRestorationToken(_ restorationToken: RestorationToken, forUsername: String) { + setRestorationTokenForUsernameCallsCount += 1 + setRestorationTokenForUsernameReceivedArguments = (restorationToken: restorationToken, forUsername: forUsername) + DispatchQueue.main.async { + self.setRestorationTokenForUsernameReceivedInvocations.append((restorationToken: restorationToken, forUsername: forUsername)) + } + setRestorationTokenForUsernameClosure?(restorationToken, forUsername) } + //MARK: - restorationTokens - var inviter: RoomMemberProxyProtocol? { - get async { - inviterCallsCount += 1 - if let inviterClosure = inviterClosure { - return await inviterClosure() + var restorationTokensUnderlyingCallsCount = 0 + var restorationTokensCallsCount: Int { + get { + if Thread.isMainThread { + return restorationTokensUnderlyingCallsCount } else { - return underlyingInviter + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = restorationTokensUnderlyingCallsCount + } + + return returnValue! } } - } - var underlyingInviter: RoomMemberProxyProtocol? - var inviterClosure: (() async -> RoomMemberProxyProtocol?)? - var hasOngoingCall: Bool { - get { return underlyingHasOngoingCall } - set(value) { underlyingHasOngoingCall = value } - } - var underlyingHasOngoingCall: Bool! - var activeRoomCallParticipants: [String] = [] - var canonicalAlias: String? - var ownUserID: String { - get { return underlyingOwnUserID } - set(value) { underlyingOwnUserID = value } - } - var underlyingOwnUserID: String! - var name: String? - var topic: String? - var avatar: RoomAvatar { - get { return underlyingAvatar } - set(value) { underlyingAvatar = value } - } - var underlyingAvatar: RoomAvatar! - var avatarURL: URL? - var membersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> { - get { return underlyingMembersPublisher } - set(value) { underlyingMembersPublisher = value } - } - var underlyingMembersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never>! - var typingMembersPublisher: CurrentValuePublisher<[String], Never> { - get { return underlyingTypingMembersPublisher } - set(value) { underlyingTypingMembersPublisher = value } - } - var underlyingTypingMembersPublisher: CurrentValuePublisher<[String], Never>! - var joinedMembersCount: Int { - get { return underlyingJoinedMembersCount } - set(value) { underlyingJoinedMembersCount = value } - } - var underlyingJoinedMembersCount: Int! - var activeMembersCount: Int { - get { return underlyingActiveMembersCount } - set(value) { underlyingActiveMembersCount = value } - } - var underlyingActiveMembersCount: Int! - var actionsPublisher: AnyPublisher { - get { return underlyingActionsPublisher } - set(value) { underlyingActionsPublisher = value } - } - var underlyingActionsPublisher: AnyPublisher! - var timeline: TimelineProxyProtocol { - get { return underlyingTimeline } - set(value) { underlyingTimeline = value } - } - var underlyingTimeline: TimelineProxyProtocol! - var pinnedEventsTimelineCallsCount = 0 - var pinnedEventsTimelineCalled: Bool { - return pinnedEventsTimelineCallsCount > 0 - } - - var pinnedEventsTimeline: TimelineProxyProtocol? { - get async { - pinnedEventsTimelineCallsCount += 1 - if let pinnedEventsTimelineClosure = pinnedEventsTimelineClosure { - return await pinnedEventsTimelineClosure() + set { + if Thread.isMainThread { + restorationTokensUnderlyingCallsCount = newValue } else { - return underlyingPinnedEventsTimeline + DispatchQueue.main.sync { + restorationTokensUnderlyingCallsCount = newValue + } } } } - var underlyingPinnedEventsTimeline: TimelineProxyProtocol? - var pinnedEventsTimelineClosure: (() async -> TimelineProxyProtocol?)? - - //MARK: - subscribeForUpdates + var restorationTokensCalled: Bool { + return restorationTokensCallsCount > 0 + } - var subscribeForUpdatesUnderlyingCallsCount = 0 - var subscribeForUpdatesCallsCount: Int { + var restorationTokensUnderlyingReturnValue: [KeychainCredentials]! + var restorationTokensReturnValue: [KeychainCredentials]! { get { if Thread.isMainThread { - return subscribeForUpdatesUnderlyingCallsCount + return restorationTokensUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: [KeychainCredentials]? = nil DispatchQueue.main.sync { - returnValue = subscribeForUpdatesUnderlyingCallsCount + returnValue = restorationTokensUnderlyingReturnValue } return returnValue! @@ -8627,34 +8411,35 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - subscribeForUpdatesUnderlyingCallsCount = newValue + restorationTokensUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - subscribeForUpdatesUnderlyingCallsCount = newValue + restorationTokensUnderlyingReturnValue = newValue } } } } - var subscribeForUpdatesCalled: Bool { - return subscribeForUpdatesCallsCount > 0 - } - var subscribeForUpdatesClosure: (() async -> Void)? + var restorationTokensClosure: (() -> [KeychainCredentials])? - func subscribeForUpdates() async { - subscribeForUpdatesCallsCount += 1 - await subscribeForUpdatesClosure?() + func restorationTokens() -> [KeychainCredentials] { + restorationTokensCallsCount += 1 + if let restorationTokensClosure = restorationTokensClosure { + return restorationTokensClosure() + } else { + return restorationTokensReturnValue + } } - //MARK: - subscribeToRoomInfoUpdates + //MARK: - removeRestorationTokenForUsername - var subscribeToRoomInfoUpdatesUnderlyingCallsCount = 0 - var subscribeToRoomInfoUpdatesCallsCount: Int { + var removeRestorationTokenForUsernameUnderlyingCallsCount = 0 + var removeRestorationTokenForUsernameCallsCount: Int { get { if Thread.isMainThread { - return subscribeToRoomInfoUpdatesUnderlyingCallsCount + return removeRestorationTokenForUsernameUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = subscribeToRoomInfoUpdatesUnderlyingCallsCount + returnValue = removeRestorationTokenForUsernameUnderlyingCallsCount } return returnValue! @@ -8662,34 +8447,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - subscribeToRoomInfoUpdatesUnderlyingCallsCount = newValue + removeRestorationTokenForUsernameUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - subscribeToRoomInfoUpdatesUnderlyingCallsCount = newValue + removeRestorationTokenForUsernameUnderlyingCallsCount = newValue } } } } - var subscribeToRoomInfoUpdatesCalled: Bool { - return subscribeToRoomInfoUpdatesCallsCount > 0 + var removeRestorationTokenForUsernameCalled: Bool { + return removeRestorationTokenForUsernameCallsCount > 0 } - var subscribeToRoomInfoUpdatesClosure: (() -> Void)? + var removeRestorationTokenForUsernameReceivedUsername: String? + var removeRestorationTokenForUsernameReceivedInvocations: [String] = [] + var removeRestorationTokenForUsernameClosure: ((String) -> Void)? - func subscribeToRoomInfoUpdates() { - subscribeToRoomInfoUpdatesCallsCount += 1 - subscribeToRoomInfoUpdatesClosure?() + func removeRestorationTokenForUsername(_ username: String) { + removeRestorationTokenForUsernameCallsCount += 1 + removeRestorationTokenForUsernameReceivedUsername = username + DispatchQueue.main.async { + self.removeRestorationTokenForUsernameReceivedInvocations.append(username) + } + removeRestorationTokenForUsernameClosure?(username) } - //MARK: - timelineFocusedOnEvent + //MARK: - removeAllRestorationTokens - var timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = 0 - var timelineFocusedOnEventEventIDNumberOfEventsCallsCount: Int { + var removeAllRestorationTokensUnderlyingCallsCount = 0 + var removeAllRestorationTokensCallsCount: Int { get { if Thread.isMainThread { - return timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount + return removeAllRestorationTokensUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount + returnValue = removeAllRestorationTokensUnderlyingCallsCount } return returnValue! @@ -8697,29 +8488,35 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = newValue + removeAllRestorationTokensUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - timelineFocusedOnEventEventIDNumberOfEventsUnderlyingCallsCount = newValue + removeAllRestorationTokensUnderlyingCallsCount = newValue } } } } - var timelineFocusedOnEventEventIDNumberOfEventsCalled: Bool { - return timelineFocusedOnEventEventIDNumberOfEventsCallsCount > 0 + var removeAllRestorationTokensCalled: Bool { + return removeAllRestorationTokensCallsCount > 0 } - var timelineFocusedOnEventEventIDNumberOfEventsReceivedArguments: (eventID: String, numberOfEvents: UInt16)? - var timelineFocusedOnEventEventIDNumberOfEventsReceivedInvocations: [(eventID: String, numberOfEvents: UInt16)] = [] + var removeAllRestorationTokensClosure: (() -> Void)? - var timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue: Result! - var timelineFocusedOnEventEventIDNumberOfEventsReturnValue: Result! { + func removeAllRestorationTokens() { + removeAllRestorationTokensCallsCount += 1 + removeAllRestorationTokensClosure?() + } + //MARK: - containsPINCode + + var containsPINCodeThrowableError: Error? + var containsPINCodeUnderlyingCallsCount = 0 + var containsPINCodeCallsCount: Int { get { if Thread.isMainThread { - return timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue + return containsPINCodeUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue + returnValue = containsPINCodeUnderlyingCallsCount } return returnValue! @@ -8727,39 +8524,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue = newValue + containsPINCodeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - timelineFocusedOnEventEventIDNumberOfEventsUnderlyingReturnValue = newValue + containsPINCodeUnderlyingCallsCount = newValue } } } } - var timelineFocusedOnEventEventIDNumberOfEventsClosure: ((String, UInt16) async -> Result)? - - func timelineFocusedOnEvent(eventID: String, numberOfEvents: UInt16) async -> Result { - timelineFocusedOnEventEventIDNumberOfEventsCallsCount += 1 - timelineFocusedOnEventEventIDNumberOfEventsReceivedArguments = (eventID: eventID, numberOfEvents: numberOfEvents) - DispatchQueue.main.async { - self.timelineFocusedOnEventEventIDNumberOfEventsReceivedInvocations.append((eventID: eventID, numberOfEvents: numberOfEvents)) - } - if let timelineFocusedOnEventEventIDNumberOfEventsClosure = timelineFocusedOnEventEventIDNumberOfEventsClosure { - return await timelineFocusedOnEventEventIDNumberOfEventsClosure(eventID, numberOfEvents) - } else { - return timelineFocusedOnEventEventIDNumberOfEventsReturnValue - } + var containsPINCodeCalled: Bool { + return containsPINCodeCallsCount > 0 } - //MARK: - redact - var redactUnderlyingCallsCount = 0 - var redactCallsCount: Int { + var containsPINCodeUnderlyingReturnValue: Bool! + var containsPINCodeReturnValue: Bool! { get { if Thread.isMainThread { - return redactUnderlyingCallsCount + return containsPINCodeUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = redactUnderlyingCallsCount + returnValue = containsPINCodeUnderlyingReturnValue } return returnValue! @@ -8767,29 +8552,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - redactUnderlyingCallsCount = newValue + containsPINCodeUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - redactUnderlyingCallsCount = newValue + containsPINCodeUnderlyingReturnValue = newValue } } } } - var redactCalled: Bool { - return redactCallsCount > 0 + var containsPINCodeClosure: (() throws -> Bool)? + + func containsPINCode() throws -> Bool { + if let error = containsPINCodeThrowableError { + throw error + } + containsPINCodeCallsCount += 1 + if let containsPINCodeClosure = containsPINCodeClosure { + return try containsPINCodeClosure() + } else { + return containsPINCodeReturnValue + } } - var redactReceivedEventID: String? - var redactReceivedInvocations: [String] = [] + //MARK: - setPINCode - var redactUnderlyingReturnValue: Result! - var redactReturnValue: Result! { + var setPINCodeThrowableError: Error? + var setPINCodeUnderlyingCallsCount = 0 + var setPINCodeCallsCount: Int { get { if Thread.isMainThread { - return redactUnderlyingReturnValue + return setPINCodeUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = redactUnderlyingReturnValue + returnValue = setPINCodeUnderlyingCallsCount } return returnValue! @@ -8797,39 +8592,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - redactUnderlyingReturnValue = newValue + setPINCodeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - redactUnderlyingReturnValue = newValue + setPINCodeUnderlyingCallsCount = newValue } } } } - var redactClosure: ((String) async -> Result)? + var setPINCodeCalled: Bool { + return setPINCodeCallsCount > 0 + } + var setPINCodeReceivedPinCode: String? + var setPINCodeReceivedInvocations: [String] = [] + var setPINCodeClosure: ((String) throws -> Void)? - func redact(_ eventID: String) async -> Result { - redactCallsCount += 1 - redactReceivedEventID = eventID - DispatchQueue.main.async { - self.redactReceivedInvocations.append(eventID) + func setPINCode(_ pinCode: String) throws { + if let error = setPINCodeThrowableError { + throw error } - if let redactClosure = redactClosure { - return await redactClosure(eventID) - } else { - return redactReturnValue + setPINCodeCallsCount += 1 + setPINCodeReceivedPinCode = pinCode + DispatchQueue.main.async { + self.setPINCodeReceivedInvocations.append(pinCode) } + try setPINCodeClosure?(pinCode) } - //MARK: - reportContent + //MARK: - pinCode - var reportContentReasonUnderlyingCallsCount = 0 - var reportContentReasonCallsCount: Int { + var pinCodeUnderlyingCallsCount = 0 + var pinCodeCallsCount: Int { get { if Thread.isMainThread { - return reportContentReasonUnderlyingCallsCount + return pinCodeUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = reportContentReasonUnderlyingCallsCount + returnValue = pinCodeUnderlyingCallsCount } return returnValue! @@ -8837,29 +8636,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - reportContentReasonUnderlyingCallsCount = newValue + pinCodeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - reportContentReasonUnderlyingCallsCount = newValue + pinCodeUnderlyingCallsCount = newValue } } } } - var reportContentReasonCalled: Bool { - return reportContentReasonCallsCount > 0 + var pinCodeCalled: Bool { + return pinCodeCallsCount > 0 } - var reportContentReasonReceivedArguments: (eventID: String, reason: String?)? - var reportContentReasonReceivedInvocations: [(eventID: String, reason: String?)] = [] - var reportContentReasonUnderlyingReturnValue: Result! - var reportContentReasonReturnValue: Result! { + var pinCodeUnderlyingReturnValue: String? + var pinCodeReturnValue: String? { get { if Thread.isMainThread { - return reportContentReasonUnderlyingReturnValue + return pinCodeUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: String?? = nil DispatchQueue.main.sync { - returnValue = reportContentReasonUnderlyingReturnValue + returnValue = pinCodeUnderlyingReturnValue } return returnValue! @@ -8867,39 +8664,35 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - reportContentReasonUnderlyingReturnValue = newValue + pinCodeUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - reportContentReasonUnderlyingReturnValue = newValue + pinCodeUnderlyingReturnValue = newValue } } } } - var reportContentReasonClosure: ((String, String?) async -> Result)? + var pinCodeClosure: (() -> String?)? - func reportContent(_ eventID: String, reason: String?) async -> Result { - reportContentReasonCallsCount += 1 - reportContentReasonReceivedArguments = (eventID: eventID, reason: reason) - DispatchQueue.main.async { - self.reportContentReasonReceivedInvocations.append((eventID: eventID, reason: reason)) - } - if let reportContentReasonClosure = reportContentReasonClosure { - return await reportContentReasonClosure(eventID, reason) + func pinCode() -> String? { + pinCodeCallsCount += 1 + if let pinCodeClosure = pinCodeClosure { + return pinCodeClosure() } else { - return reportContentReasonReturnValue + return pinCodeReturnValue } } - //MARK: - leaveRoom + //MARK: - removePINCode - var leaveRoomUnderlyingCallsCount = 0 - var leaveRoomCallsCount: Int { + var removePINCodeUnderlyingCallsCount = 0 + var removePINCodeCallsCount: Int { get { if Thread.isMainThread { - return leaveRoomUnderlyingCallsCount + return removePINCodeUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = leaveRoomUnderlyingCallsCount + returnValue = removePINCodeUnderlyingCallsCount } return returnValue! @@ -8907,27 +8700,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - leaveRoomUnderlyingCallsCount = newValue + removePINCodeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - leaveRoomUnderlyingCallsCount = newValue + removePINCodeUnderlyingCallsCount = newValue } } } } - var leaveRoomCalled: Bool { - return leaveRoomCallsCount > 0 + var removePINCodeCalled: Bool { + return removePINCodeCallsCount > 0 } + var removePINCodeClosure: (() -> Void)? - var leaveRoomUnderlyingReturnValue: Result! - var leaveRoomReturnValue: Result! { + func removePINCode() { + removePINCodeCallsCount += 1 + removePINCodeClosure?() + } + //MARK: - containsPINCodeBiometricState + + var containsPINCodeBiometricStateUnderlyingCallsCount = 0 + var containsPINCodeBiometricStateCallsCount: Int { get { if Thread.isMainThread { - return leaveRoomUnderlyingReturnValue + return containsPINCodeBiometricStateUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = leaveRoomUnderlyingReturnValue + returnValue = containsPINCodeBiometricStateUnderlyingCallsCount } return returnValue! @@ -8935,35 +8735,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - leaveRoomUnderlyingReturnValue = newValue + containsPINCodeBiometricStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - leaveRoomUnderlyingReturnValue = newValue + containsPINCodeBiometricStateUnderlyingCallsCount = newValue } } } } - var leaveRoomClosure: (() async -> Result)? - - func leaveRoom() async -> Result { - leaveRoomCallsCount += 1 - if let leaveRoomClosure = leaveRoomClosure { - return await leaveRoomClosure() - } else { - return leaveRoomReturnValue - } + var containsPINCodeBiometricStateCalled: Bool { + return containsPINCodeBiometricStateCallsCount > 0 } - //MARK: - updateMembers - var updateMembersUnderlyingCallsCount = 0 - var updateMembersCallsCount: Int { + var containsPINCodeBiometricStateUnderlyingReturnValue: Bool! + var containsPINCodeBiometricStateReturnValue: Bool! { get { if Thread.isMainThread { - return updateMembersUnderlyingCallsCount + return containsPINCodeBiometricStateUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = updateMembersUnderlyingCallsCount + returnValue = containsPINCodeBiometricStateUnderlyingReturnValue } return returnValue! @@ -8971,34 +8763,36 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - updateMembersUnderlyingCallsCount = newValue + containsPINCodeBiometricStateUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - updateMembersUnderlyingCallsCount = newValue + containsPINCodeBiometricStateUnderlyingReturnValue = newValue } } } } - var updateMembersCalled: Bool { - return updateMembersCallsCount > 0 - } - var updateMembersClosure: (() async -> Void)? + var containsPINCodeBiometricStateClosure: (() -> Bool)? - func updateMembers() async { - updateMembersCallsCount += 1 - await updateMembersClosure?() + func containsPINCodeBiometricState() -> Bool { + containsPINCodeBiometricStateCallsCount += 1 + if let containsPINCodeBiometricStateClosure = containsPINCodeBiometricStateClosure { + return containsPINCodeBiometricStateClosure() + } else { + return containsPINCodeBiometricStateReturnValue + } } - //MARK: - getMember + //MARK: - setPINCodeBiometricState - var getMemberUserIDUnderlyingCallsCount = 0 - var getMemberUserIDCallsCount: Int { + var setPINCodeBiometricStateThrowableError: Error? + var setPINCodeBiometricStateUnderlyingCallsCount = 0 + var setPINCodeBiometricStateCallsCount: Int { get { if Thread.isMainThread { - return getMemberUserIDUnderlyingCallsCount + return setPINCodeBiometricStateUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getMemberUserIDUnderlyingCallsCount + returnValue = setPINCodeBiometricStateUnderlyingCallsCount } return returnValue! @@ -9006,29 +8800,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - getMemberUserIDUnderlyingCallsCount = newValue + setPINCodeBiometricStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getMemberUserIDUnderlyingCallsCount = newValue + setPINCodeBiometricStateUnderlyingCallsCount = newValue } } } } - var getMemberUserIDCalled: Bool { - return getMemberUserIDCallsCount > 0 + var setPINCodeBiometricStateCalled: Bool { + return setPINCodeBiometricStateCallsCount > 0 } - var getMemberUserIDReceivedUserID: String? - var getMemberUserIDReceivedInvocations: [String] = [] + var setPINCodeBiometricStateReceivedState: Data? + var setPINCodeBiometricStateReceivedInvocations: [Data] = [] + var setPINCodeBiometricStateClosure: ((Data) throws -> Void)? - var getMemberUserIDUnderlyingReturnValue: Result! - var getMemberUserIDReturnValue: Result! { + func setPINCodeBiometricState(_ state: Data) throws { + if let error = setPINCodeBiometricStateThrowableError { + throw error + } + setPINCodeBiometricStateCallsCount += 1 + setPINCodeBiometricStateReceivedState = state + DispatchQueue.main.async { + self.setPINCodeBiometricStateReceivedInvocations.append(state) + } + try setPINCodeBiometricStateClosure?(state) + } + //MARK: - pinCodeBiometricState + + var pinCodeBiometricStateUnderlyingCallsCount = 0 + var pinCodeBiometricStateCallsCount: Int { get { if Thread.isMainThread { - return getMemberUserIDUnderlyingReturnValue + return pinCodeBiometricStateUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = getMemberUserIDUnderlyingReturnValue + returnValue = pinCodeBiometricStateUnderlyingCallsCount } return returnValue! @@ -9036,39 +8844,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - getMemberUserIDUnderlyingReturnValue = newValue + pinCodeBiometricStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - getMemberUserIDUnderlyingReturnValue = newValue + pinCodeBiometricStateUnderlyingCallsCount = newValue } } } } - var getMemberUserIDClosure: ((String) async -> Result)? - - func getMember(userID: String) async -> Result { - getMemberUserIDCallsCount += 1 - getMemberUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.getMemberUserIDReceivedInvocations.append(userID) - } - if let getMemberUserIDClosure = getMemberUserIDClosure { - return await getMemberUserIDClosure(userID) - } else { - return getMemberUserIDReturnValue - } + var pinCodeBiometricStateCalled: Bool { + return pinCodeBiometricStateCallsCount > 0 } - //MARK: - rejectInvitation - var rejectInvitationUnderlyingCallsCount = 0 - var rejectInvitationCallsCount: Int { + var pinCodeBiometricStateUnderlyingReturnValue: Data? + var pinCodeBiometricStateReturnValue: Data? { get { if Thread.isMainThread { - return rejectInvitationUnderlyingCallsCount + return pinCodeBiometricStateUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Data?? = nil DispatchQueue.main.sync { - returnValue = rejectInvitationUnderlyingCallsCount + returnValue = pinCodeBiometricStateUnderlyingReturnValue } return returnValue! @@ -9076,27 +8872,35 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - rejectInvitationUnderlyingCallsCount = newValue + pinCodeBiometricStateUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - rejectInvitationUnderlyingCallsCount = newValue + pinCodeBiometricStateUnderlyingReturnValue = newValue } } } } - var rejectInvitationCalled: Bool { - return rejectInvitationCallsCount > 0 + var pinCodeBiometricStateClosure: (() -> Data?)? + + func pinCodeBiometricState() -> Data? { + pinCodeBiometricStateCallsCount += 1 + if let pinCodeBiometricStateClosure = pinCodeBiometricStateClosure { + return pinCodeBiometricStateClosure() + } else { + return pinCodeBiometricStateReturnValue + } } + //MARK: - removePINCodeBiometricState - var rejectInvitationUnderlyingReturnValue: Result! - var rejectInvitationReturnValue: Result! { + var removePINCodeBiometricStateUnderlyingCallsCount = 0 + var removePINCodeBiometricStateCallsCount: Int { get { if Thread.isMainThread { - return rejectInvitationUnderlyingReturnValue + return removePINCodeBiometricStateUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = rejectInvitationUnderlyingReturnValue + returnValue = removePINCodeBiometricStateUnderlyingCallsCount } return returnValue! @@ -9104,35 +8908,38 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - rejectInvitationUnderlyingReturnValue = newValue + removePINCodeBiometricStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - rejectInvitationUnderlyingReturnValue = newValue + removePINCodeBiometricStateUnderlyingCallsCount = newValue } } } } - var rejectInvitationClosure: (() async -> Result)? + var removePINCodeBiometricStateCalled: Bool { + return removePINCodeBiometricStateCallsCount > 0 + } + var removePINCodeBiometricStateClosure: (() -> Void)? - func rejectInvitation() async -> Result { - rejectInvitationCallsCount += 1 - if let rejectInvitationClosure = rejectInvitationClosure { - return await rejectInvitationClosure() - } else { - return rejectInvitationReturnValue - } + func removePINCodeBiometricState() { + removePINCodeBiometricStateCallsCount += 1 + removePINCodeBiometricStateClosure?() } - //MARK: - acceptInvitation +} +class MediaLoaderMock: MediaLoaderProtocol { - var acceptInvitationUnderlyingCallsCount = 0 - var acceptInvitationCallsCount: Int { + //MARK: - loadMediaContentForSource + + var loadMediaContentForSourceThrowableError: Error? + var loadMediaContentForSourceUnderlyingCallsCount = 0 + var loadMediaContentForSourceCallsCount: Int { get { if Thread.isMainThread { - return acceptInvitationUnderlyingCallsCount + return loadMediaContentForSourceUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = acceptInvitationUnderlyingCallsCount + returnValue = loadMediaContentForSourceUnderlyingCallsCount } return returnValue! @@ -9140,27 +8947,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - acceptInvitationUnderlyingCallsCount = newValue + loadMediaContentForSourceUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - acceptInvitationUnderlyingCallsCount = newValue + loadMediaContentForSourceUnderlyingCallsCount = newValue } } } } - var acceptInvitationCalled: Bool { - return acceptInvitationCallsCount > 0 + var loadMediaContentForSourceCalled: Bool { + return loadMediaContentForSourceCallsCount > 0 } + var loadMediaContentForSourceReceivedSource: MediaSourceProxy? + var loadMediaContentForSourceReceivedInvocations: [MediaSourceProxy] = [] - var acceptInvitationUnderlyingReturnValue: Result! - var acceptInvitationReturnValue: Result! { + var loadMediaContentForSourceUnderlyingReturnValue: Data! + var loadMediaContentForSourceReturnValue: Data! { get { if Thread.isMainThread { - return acceptInvitationUnderlyingReturnValue + return loadMediaContentForSourceUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Data? = nil DispatchQueue.main.sync { - returnValue = acceptInvitationUnderlyingReturnValue + returnValue = loadMediaContentForSourceUnderlyingReturnValue } return returnValue! @@ -9168,35 +8977,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - acceptInvitationUnderlyingReturnValue = newValue + loadMediaContentForSourceUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - acceptInvitationUnderlyingReturnValue = newValue + loadMediaContentForSourceUnderlyingReturnValue = newValue } } } } - var acceptInvitationClosure: (() async -> Result)? + var loadMediaContentForSourceClosure: ((MediaSourceProxy) async throws -> Data)? - func acceptInvitation() async -> Result { - acceptInvitationCallsCount += 1 - if let acceptInvitationClosure = acceptInvitationClosure { - return await acceptInvitationClosure() + func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data { + if let error = loadMediaContentForSourceThrowableError { + throw error + } + loadMediaContentForSourceCallsCount += 1 + loadMediaContentForSourceReceivedSource = source + DispatchQueue.main.async { + self.loadMediaContentForSourceReceivedInvocations.append(source) + } + if let loadMediaContentForSourceClosure = loadMediaContentForSourceClosure { + return try await loadMediaContentForSourceClosure(source) } else { - return acceptInvitationReturnValue + return loadMediaContentForSourceReturnValue } } - //MARK: - invite + //MARK: - loadMediaThumbnailForSource - var inviteUserIDUnderlyingCallsCount = 0 - var inviteUserIDCallsCount: Int { + var loadMediaThumbnailForSourceWidthHeightThrowableError: Error? + var loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = 0 + var loadMediaThumbnailForSourceWidthHeightCallsCount: Int { get { if Thread.isMainThread { - return inviteUserIDUnderlyingCallsCount + return loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = inviteUserIDUnderlyingCallsCount + returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount } return returnValue! @@ -9204,29 +9021,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - inviteUserIDUnderlyingCallsCount = newValue + loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - inviteUserIDUnderlyingCallsCount = newValue + loadMediaThumbnailForSourceWidthHeightUnderlyingCallsCount = newValue } } } } - var inviteUserIDCalled: Bool { - return inviteUserIDCallsCount > 0 + var loadMediaThumbnailForSourceWidthHeightCalled: Bool { + return loadMediaThumbnailForSourceWidthHeightCallsCount > 0 } - var inviteUserIDReceivedUserID: String? - var inviteUserIDReceivedInvocations: [String] = [] + var loadMediaThumbnailForSourceWidthHeightReceivedArguments: (source: MediaSourceProxy, width: UInt, height: UInt)? + var loadMediaThumbnailForSourceWidthHeightReceivedInvocations: [(source: MediaSourceProxy, width: UInt, height: UInt)] = [] - var inviteUserIDUnderlyingReturnValue: Result! - var inviteUserIDReturnValue: Result! { + var loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue: Data! + var loadMediaThumbnailForSourceWidthHeightReturnValue: Data! { get { if Thread.isMainThread { - return inviteUserIDUnderlyingReturnValue + return loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Data? = nil DispatchQueue.main.sync { - returnValue = inviteUserIDUnderlyingReturnValue + returnValue = loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue } return returnValue! @@ -9234,39 +9051,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - inviteUserIDUnderlyingReturnValue = newValue + loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - inviteUserIDUnderlyingReturnValue = newValue + loadMediaThumbnailForSourceWidthHeightUnderlyingReturnValue = newValue } } } } - var inviteUserIDClosure: ((String) async -> Result)? + var loadMediaThumbnailForSourceWidthHeightClosure: ((MediaSourceProxy, UInt, UInt) async throws -> Data)? - func invite(userID: String) async -> Result { - inviteUserIDCallsCount += 1 - inviteUserIDReceivedUserID = userID + func loadMediaThumbnailForSource(_ source: MediaSourceProxy, width: UInt, height: UInt) async throws -> Data { + if let error = loadMediaThumbnailForSourceWidthHeightThrowableError { + throw error + } + loadMediaThumbnailForSourceWidthHeightCallsCount += 1 + loadMediaThumbnailForSourceWidthHeightReceivedArguments = (source: source, width: width, height: height) DispatchQueue.main.async { - self.inviteUserIDReceivedInvocations.append(userID) + self.loadMediaThumbnailForSourceWidthHeightReceivedInvocations.append((source: source, width: width, height: height)) } - if let inviteUserIDClosure = inviteUserIDClosure { - return await inviteUserIDClosure(userID) + if let loadMediaThumbnailForSourceWidthHeightClosure = loadMediaThumbnailForSourceWidthHeightClosure { + return try await loadMediaThumbnailForSourceWidthHeightClosure(source, width, height) } else { - return inviteUserIDReturnValue + return loadMediaThumbnailForSourceWidthHeightReturnValue } } - //MARK: - setName + //MARK: - loadMediaFileForSource - var setNameUnderlyingCallsCount = 0 - var setNameCallsCount: Int { + var loadMediaFileForSourceBodyThrowableError: Error? + var loadMediaFileForSourceBodyUnderlyingCallsCount = 0 + var loadMediaFileForSourceBodyCallsCount: Int { get { if Thread.isMainThread { - return setNameUnderlyingCallsCount + return loadMediaFileForSourceBodyUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setNameUnderlyingCallsCount + returnValue = loadMediaFileForSourceBodyUnderlyingCallsCount } return returnValue! @@ -9274,29 +9095,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - setNameUnderlyingCallsCount = newValue + loadMediaFileForSourceBodyUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setNameUnderlyingCallsCount = newValue + loadMediaFileForSourceBodyUnderlyingCallsCount = newValue } } } } - var setNameCalled: Bool { - return setNameCallsCount > 0 + var loadMediaFileForSourceBodyCalled: Bool { + return loadMediaFileForSourceBodyCallsCount > 0 } - var setNameReceivedName: String? - var setNameReceivedInvocations: [String] = [] + var loadMediaFileForSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)? + var loadMediaFileForSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = [] - var setNameUnderlyingReturnValue: Result! - var setNameReturnValue: Result! { + var loadMediaFileForSourceBodyUnderlyingReturnValue: MediaFileHandleProxy! + var loadMediaFileForSourceBodyReturnValue: MediaFileHandleProxy! { get { if Thread.isMainThread { - return setNameUnderlyingReturnValue + return loadMediaFileForSourceBodyUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: MediaFileHandleProxy? = nil DispatchQueue.main.sync { - returnValue = setNameUnderlyingReturnValue + returnValue = loadMediaFileForSourceBodyUnderlyingReturnValue } return returnValue! @@ -9304,39 +9125,62 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - setNameUnderlyingReturnValue = newValue + loadMediaFileForSourceBodyUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - setNameUnderlyingReturnValue = newValue + loadMediaFileForSourceBodyUnderlyingReturnValue = newValue } } } } - var setNameClosure: ((String) async -> Result)? + var loadMediaFileForSourceBodyClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)? - func setName(_ name: String) async -> Result { - setNameCallsCount += 1 - setNameReceivedName = name + func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy { + if let error = loadMediaFileForSourceBodyThrowableError { + throw error + } + loadMediaFileForSourceBodyCallsCount += 1 + loadMediaFileForSourceBodyReceivedArguments = (source: source, body: body) DispatchQueue.main.async { - self.setNameReceivedInvocations.append(name) + self.loadMediaFileForSourceBodyReceivedInvocations.append((source: source, body: body)) } - if let setNameClosure = setNameClosure { - return await setNameClosure(name) + if let loadMediaFileForSourceBodyClosure = loadMediaFileForSourceBodyClosure { + return try await loadMediaFileForSourceBodyClosure(source, body) } else { - return setNameReturnValue + return loadMediaFileForSourceBodyReturnValue } } - //MARK: - setTopic +} +class MediaPlayerMock: MediaPlayerProtocol { + var mediaSource: MediaSourceProxy? + var duration: TimeInterval { + get { return underlyingDuration } + set(value) { underlyingDuration = value } + } + var underlyingDuration: TimeInterval! + var currentTime: TimeInterval { + get { return underlyingCurrentTime } + set(value) { underlyingCurrentTime = value } + } + var underlyingCurrentTime: TimeInterval! + var url: URL? + var state: MediaPlayerState { + get { return underlyingState } + set(value) { underlyingState = value } + } + var underlyingState: MediaPlayerState! - var setTopicUnderlyingCallsCount = 0 - var setTopicCallsCount: Int { + //MARK: - load + + var loadMediaSourceUsingAutoplayUnderlyingCallsCount = 0 + var loadMediaSourceUsingAutoplayCallsCount: Int { get { if Thread.isMainThread { - return setTopicUnderlyingCallsCount + return loadMediaSourceUsingAutoplayUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setTopicUnderlyingCallsCount + returnValue = loadMediaSourceUsingAutoplayUnderlyingCallsCount } return returnValue! @@ -9344,29 +9188,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - setTopicUnderlyingCallsCount = newValue + loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setTopicUnderlyingCallsCount = newValue + loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue } } } } - var setTopicCalled: Bool { - return setTopicCallsCount > 0 + var loadMediaSourceUsingAutoplayCalled: Bool { + return loadMediaSourceUsingAutoplayCallsCount > 0 } - var setTopicReceivedTopic: String? - var setTopicReceivedInvocations: [String] = [] + var loadMediaSourceUsingAutoplayReceivedArguments: (mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)? + var loadMediaSourceUsingAutoplayReceivedInvocations: [(mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)] = [] + var loadMediaSourceUsingAutoplayClosure: ((MediaSourceProxy, URL, Bool) -> Void)? - var setTopicUnderlyingReturnValue: Result! - var setTopicReturnValue: Result! { + func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) { + loadMediaSourceUsingAutoplayCallsCount += 1 + loadMediaSourceUsingAutoplayReceivedArguments = (mediaSource: mediaSource, url: url, autoplay: autoplay) + DispatchQueue.main.async { + self.loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay)) + } + loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay) + } + //MARK: - reset + + var resetUnderlyingCallsCount = 0 + var resetCallsCount: Int { get { if Thread.isMainThread { - return setTopicUnderlyingReturnValue + return resetUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = setTopicUnderlyingReturnValue + returnValue = resetUnderlyingCallsCount } return returnValue! @@ -9374,39 +9229,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - setTopicUnderlyingReturnValue = newValue + resetUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - setTopicUnderlyingReturnValue = newValue + resetUnderlyingCallsCount = newValue } } } } - var setTopicClosure: ((String) async -> Result)? + var resetCalled: Bool { + return resetCallsCount > 0 + } + var resetClosure: (() -> Void)? - func setTopic(_ topic: String) async -> Result { - setTopicCallsCount += 1 - setTopicReceivedTopic = topic - DispatchQueue.main.async { - self.setTopicReceivedInvocations.append(topic) - } - if let setTopicClosure = setTopicClosure { - return await setTopicClosure(topic) - } else { - return setTopicReturnValue - } + func reset() { + resetCallsCount += 1 + resetClosure?() } - //MARK: - removeAvatar + //MARK: - play - var removeAvatarUnderlyingCallsCount = 0 - var removeAvatarCallsCount: Int { + var playUnderlyingCallsCount = 0 + var playCallsCount: Int { get { if Thread.isMainThread { - return removeAvatarUnderlyingCallsCount + return playUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removeAvatarUnderlyingCallsCount + returnValue = playUnderlyingCallsCount } return returnValue! @@ -9414,27 +9264,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - removeAvatarUnderlyingCallsCount = newValue + playUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removeAvatarUnderlyingCallsCount = newValue + playUnderlyingCallsCount = newValue } } } } - var removeAvatarCalled: Bool { - return removeAvatarCallsCount > 0 + var playCalled: Bool { + return playCallsCount > 0 } + var playClosure: (() -> Void)? - var removeAvatarUnderlyingReturnValue: Result! - var removeAvatarReturnValue: Result! { + func play() { + playCallsCount += 1 + playClosure?() + } + //MARK: - pause + + var pauseUnderlyingCallsCount = 0 + var pauseCallsCount: Int { get { if Thread.isMainThread { - return removeAvatarUnderlyingReturnValue + return pauseUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = removeAvatarUnderlyingReturnValue + returnValue = pauseUnderlyingCallsCount } return returnValue! @@ -9442,35 +9299,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - removeAvatarUnderlyingReturnValue = newValue + pauseUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - removeAvatarUnderlyingReturnValue = newValue + pauseUnderlyingCallsCount = newValue } } } } - var removeAvatarClosure: (() async -> Result)? + var pauseCalled: Bool { + return pauseCallsCount > 0 + } + var pauseClosure: (() -> Void)? - func removeAvatar() async -> Result { - removeAvatarCallsCount += 1 - if let removeAvatarClosure = removeAvatarClosure { - return await removeAvatarClosure() - } else { - return removeAvatarReturnValue - } + func pause() { + pauseCallsCount += 1 + pauseClosure?() } - //MARK: - uploadAvatar + //MARK: - stop - var uploadAvatarMediaUnderlyingCallsCount = 0 - var uploadAvatarMediaCallsCount: Int { + var stopUnderlyingCallsCount = 0 + var stopCallsCount: Int { get { if Thread.isMainThread { - return uploadAvatarMediaUnderlyingCallsCount + return stopUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = uploadAvatarMediaUnderlyingCallsCount + returnValue = stopUnderlyingCallsCount } return returnValue! @@ -9478,29 +9334,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - uploadAvatarMediaUnderlyingCallsCount = newValue + stopUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - uploadAvatarMediaUnderlyingCallsCount = newValue + stopUnderlyingCallsCount = newValue } } } } - var uploadAvatarMediaCalled: Bool { - return uploadAvatarMediaCallsCount > 0 + var stopCalled: Bool { + return stopCallsCount > 0 } - var uploadAvatarMediaReceivedMedia: MediaInfo? - var uploadAvatarMediaReceivedInvocations: [MediaInfo] = [] + var stopClosure: (() -> Void)? - var uploadAvatarMediaUnderlyingReturnValue: Result! - var uploadAvatarMediaReturnValue: Result! { + func stop() { + stopCallsCount += 1 + stopClosure?() + } + //MARK: - seek + + var seekToUnderlyingCallsCount = 0 + var seekToCallsCount: Int { get { if Thread.isMainThread { - return uploadAvatarMediaUnderlyingReturnValue + return seekToUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = uploadAvatarMediaUnderlyingReturnValue + returnValue = seekToUnderlyingCallsCount } return returnValue! @@ -9508,39 +9369,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - uploadAvatarMediaUnderlyingReturnValue = newValue + seekToUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - uploadAvatarMediaUnderlyingReturnValue = newValue + seekToUnderlyingCallsCount = newValue } } } } - var uploadAvatarMediaClosure: ((MediaInfo) async -> Result)? + var seekToCalled: Bool { + return seekToCallsCount > 0 + } + var seekToReceivedProgress: Double? + var seekToReceivedInvocations: [Double] = [] + var seekToClosure: ((Double) async -> Void)? - func uploadAvatar(media: MediaInfo) async -> Result { - uploadAvatarMediaCallsCount += 1 - uploadAvatarMediaReceivedMedia = media + func seek(to progress: Double) async { + seekToCallsCount += 1 + seekToReceivedProgress = progress DispatchQueue.main.async { - self.uploadAvatarMediaReceivedInvocations.append(media) - } - if let uploadAvatarMediaClosure = uploadAvatarMediaClosure { - return await uploadAvatarMediaClosure(media) - } else { - return uploadAvatarMediaReturnValue + self.seekToReceivedInvocations.append(progress) } + await seekToClosure?(progress) } - //MARK: - markAsRead +} +class MediaPlayerProviderMock: MediaPlayerProviderProtocol { - var markAsReadReceiptTypeUnderlyingCallsCount = 0 - var markAsReadReceiptTypeCallsCount: Int { + //MARK: - player + + var playerForUnderlyingCallsCount = 0 + var playerForCallsCount: Int { get { if Thread.isMainThread { - return markAsReadReceiptTypeUnderlyingCallsCount + return playerForUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = markAsReadReceiptTypeUnderlyingCallsCount + returnValue = playerForUnderlyingCallsCount } return returnValue! @@ -9548,29 +9413,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - markAsReadReceiptTypeUnderlyingCallsCount = newValue + playerForUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - markAsReadReceiptTypeUnderlyingCallsCount = newValue + playerForUnderlyingCallsCount = newValue } } } } - var markAsReadReceiptTypeCalled: Bool { - return markAsReadReceiptTypeCallsCount > 0 + var playerForCalled: Bool { + return playerForCallsCount > 0 } - var markAsReadReceiptTypeReceivedReceiptType: ReceiptType? - var markAsReadReceiptTypeReceivedInvocations: [ReceiptType] = [] + var playerForReceivedMediaSource: MediaSourceProxy? + var playerForReceivedInvocations: [MediaSourceProxy] = [] - var markAsReadReceiptTypeUnderlyingReturnValue: Result! - var markAsReadReceiptTypeReturnValue: Result! { + var playerForUnderlyingReturnValue: Result! + var playerForReturnValue: Result! { get { if Thread.isMainThread { - return markAsReadReceiptTypeUnderlyingReturnValue + return playerForUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = markAsReadReceiptTypeUnderlyingReturnValue + returnValue = playerForUnderlyingReturnValue } return returnValue! @@ -9578,39 +9443,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - markAsReadReceiptTypeUnderlyingReturnValue = newValue + playerForUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - markAsReadReceiptTypeUnderlyingReturnValue = newValue + playerForUnderlyingReturnValue = newValue } } } } - var markAsReadReceiptTypeClosure: ((ReceiptType) async -> Result)? + var playerForClosure: ((MediaSourceProxy) -> Result)? - func markAsRead(receiptType: ReceiptType) async -> Result { - markAsReadReceiptTypeCallsCount += 1 - markAsReadReceiptTypeReceivedReceiptType = receiptType + func player(for mediaSource: MediaSourceProxy) -> Result { + playerForCallsCount += 1 + playerForReceivedMediaSource = mediaSource DispatchQueue.main.async { - self.markAsReadReceiptTypeReceivedInvocations.append(receiptType) + self.playerForReceivedInvocations.append(mediaSource) } - if let markAsReadReceiptTypeClosure = markAsReadReceiptTypeClosure { - return await markAsReadReceiptTypeClosure(receiptType) + if let playerForClosure = playerForClosure { + return playerForClosure(mediaSource) } else { - return markAsReadReceiptTypeReturnValue + return playerForReturnValue } } - //MARK: - edit + //MARK: - playerState - var editEventIDNewContentUnderlyingCallsCount = 0 - var editEventIDNewContentCallsCount: Int { + var playerStateForUnderlyingCallsCount = 0 + var playerStateForCallsCount: Int { get { if Thread.isMainThread { - return editEventIDNewContentUnderlyingCallsCount + return playerStateForUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = editEventIDNewContentUnderlyingCallsCount + returnValue = playerStateForUnderlyingCallsCount } return returnValue! @@ -9618,29 +9483,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - editEventIDNewContentUnderlyingCallsCount = newValue + playerStateForUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - editEventIDNewContentUnderlyingCallsCount = newValue + playerStateForUnderlyingCallsCount = newValue } } } } - var editEventIDNewContentCalled: Bool { - return editEventIDNewContentCallsCount > 0 + var playerStateForCalled: Bool { + return playerStateForCallsCount > 0 } - var editEventIDNewContentReceivedArguments: (eventID: String, newContent: RoomMessageEventContentWithoutRelation)? - var editEventIDNewContentReceivedInvocations: [(eventID: String, newContent: RoomMessageEventContentWithoutRelation)] = [] + var playerStateForReceivedId: AudioPlayerStateIdentifier? + var playerStateForReceivedInvocations: [AudioPlayerStateIdentifier] = [] - var editEventIDNewContentUnderlyingReturnValue: Result! - var editEventIDNewContentReturnValue: Result! { + var playerStateForUnderlyingReturnValue: AudioPlayerState? + var playerStateForReturnValue: AudioPlayerState? { get { if Thread.isMainThread { - return editEventIDNewContentUnderlyingReturnValue + return playerStateForUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: AudioPlayerState?? = nil DispatchQueue.main.sync { - returnValue = editEventIDNewContentUnderlyingReturnValue + returnValue = playerStateForUnderlyingReturnValue } return returnValue! @@ -9648,39 +9513,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - editEventIDNewContentUnderlyingReturnValue = newValue + playerStateForUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - editEventIDNewContentUnderlyingReturnValue = newValue + playerStateForUnderlyingReturnValue = newValue } } } } - var editEventIDNewContentClosure: ((String, RoomMessageEventContentWithoutRelation) async -> Result)? + var playerStateForClosure: ((AudioPlayerStateIdentifier) -> AudioPlayerState?)? - func edit(eventID: String, newContent: RoomMessageEventContentWithoutRelation) async -> Result { - editEventIDNewContentCallsCount += 1 - editEventIDNewContentReceivedArguments = (eventID: eventID, newContent: newContent) + func playerState(for id: AudioPlayerStateIdentifier) -> AudioPlayerState? { + playerStateForCallsCount += 1 + playerStateForReceivedId = id DispatchQueue.main.async { - self.editEventIDNewContentReceivedInvocations.append((eventID: eventID, newContent: newContent)) + self.playerStateForReceivedInvocations.append(id) } - if let editEventIDNewContentClosure = editEventIDNewContentClosure { - return await editEventIDNewContentClosure(eventID, newContent) + if let playerStateForClosure = playerStateForClosure { + return playerStateForClosure(id) } else { - return editEventIDNewContentReturnValue + return playerStateForReturnValue } } - //MARK: - sendTypingNotification + //MARK: - register - var sendTypingNotificationIsTypingUnderlyingCallsCount = 0 - var sendTypingNotificationIsTypingCallsCount: Int { + var registerAudioPlayerStateUnderlyingCallsCount = 0 + var registerAudioPlayerStateCallsCount: Int { get { if Thread.isMainThread { - return sendTypingNotificationIsTypingUnderlyingCallsCount + return registerAudioPlayerStateUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = sendTypingNotificationIsTypingUnderlyingCallsCount + returnValue = registerAudioPlayerStateUnderlyingCallsCount } return returnValue! @@ -9688,29 +9553,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - sendTypingNotificationIsTypingUnderlyingCallsCount = newValue + registerAudioPlayerStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - sendTypingNotificationIsTypingUnderlyingCallsCount = newValue + registerAudioPlayerStateUnderlyingCallsCount = newValue } } } } - var sendTypingNotificationIsTypingCalled: Bool { - return sendTypingNotificationIsTypingCallsCount > 0 + var registerAudioPlayerStateCalled: Bool { + return registerAudioPlayerStateCallsCount > 0 } - var sendTypingNotificationIsTypingReceivedIsTyping: Bool? - var sendTypingNotificationIsTypingReceivedInvocations: [Bool] = [] + var registerAudioPlayerStateReceivedAudioPlayerState: AudioPlayerState? + var registerAudioPlayerStateReceivedInvocations: [AudioPlayerState] = [] + var registerAudioPlayerStateClosure: ((AudioPlayerState) -> Void)? - var sendTypingNotificationIsTypingUnderlyingReturnValue: Result! - var sendTypingNotificationIsTypingReturnValue: Result! { + func register(audioPlayerState: AudioPlayerState) { + registerAudioPlayerStateCallsCount += 1 + registerAudioPlayerStateReceivedAudioPlayerState = audioPlayerState + DispatchQueue.main.async { + self.registerAudioPlayerStateReceivedInvocations.append(audioPlayerState) + } + registerAudioPlayerStateClosure?(audioPlayerState) + } + //MARK: - unregister + + var unregisterAudioPlayerStateUnderlyingCallsCount = 0 + var unregisterAudioPlayerStateCallsCount: Int { get { if Thread.isMainThread { - return sendTypingNotificationIsTypingUnderlyingReturnValue + return unregisterAudioPlayerStateUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = sendTypingNotificationIsTypingUnderlyingReturnValue + returnValue = unregisterAudioPlayerStateUnderlyingCallsCount } return returnValue! @@ -9718,40 +9594,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - sendTypingNotificationIsTypingUnderlyingReturnValue = newValue + unregisterAudioPlayerStateUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - sendTypingNotificationIsTypingUnderlyingReturnValue = newValue + unregisterAudioPlayerStateUnderlyingCallsCount = newValue } } } } - var sendTypingNotificationIsTypingClosure: ((Bool) async -> Result)? + var unregisterAudioPlayerStateCalled: Bool { + return unregisterAudioPlayerStateCallsCount > 0 + } + var unregisterAudioPlayerStateReceivedAudioPlayerState: AudioPlayerState? + var unregisterAudioPlayerStateReceivedInvocations: [AudioPlayerState] = [] + var unregisterAudioPlayerStateClosure: ((AudioPlayerState) -> Void)? - @discardableResult - func sendTypingNotification(isTyping: Bool) async -> Result { - sendTypingNotificationIsTypingCallsCount += 1 - sendTypingNotificationIsTypingReceivedIsTyping = isTyping + func unregister(audioPlayerState: AudioPlayerState) { + unregisterAudioPlayerStateCallsCount += 1 + unregisterAudioPlayerStateReceivedAudioPlayerState = audioPlayerState DispatchQueue.main.async { - self.sendTypingNotificationIsTypingReceivedInvocations.append(isTyping) - } - if let sendTypingNotificationIsTypingClosure = sendTypingNotificationIsTypingClosure { - return await sendTypingNotificationIsTypingClosure(isTyping) - } else { - return sendTypingNotificationIsTypingReturnValue + self.unregisterAudioPlayerStateReceivedInvocations.append(audioPlayerState) } + unregisterAudioPlayerStateClosure?(audioPlayerState) } - //MARK: - flagAsUnread + //MARK: - detachAllStates - var flagAsUnreadUnderlyingCallsCount = 0 - var flagAsUnreadCallsCount: Int { + var detachAllStatesExceptUnderlyingCallsCount = 0 + var detachAllStatesExceptCallsCount: Int { get { if Thread.isMainThread { - return flagAsUnreadUnderlyingCallsCount + return detachAllStatesExceptUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = flagAsUnreadUnderlyingCallsCount + returnValue = detachAllStatesExceptUnderlyingCallsCount } return returnValue! @@ -9759,29 +9635,52 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - flagAsUnreadUnderlyingCallsCount = newValue + detachAllStatesExceptUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - flagAsUnreadUnderlyingCallsCount = newValue + detachAllStatesExceptUnderlyingCallsCount = newValue } } } } - var flagAsUnreadCalled: Bool { - return flagAsUnreadCallsCount > 0 + var detachAllStatesExceptCalled: Bool { + return detachAllStatesExceptCallsCount > 0 } - var flagAsUnreadReceivedIsUnread: Bool? - var flagAsUnreadReceivedInvocations: [Bool] = [] + var detachAllStatesExceptReceivedException: AudioPlayerState? + var detachAllStatesExceptReceivedInvocations: [AudioPlayerState?] = [] + var detachAllStatesExceptClosure: ((AudioPlayerState?) async -> Void)? - var flagAsUnreadUnderlyingReturnValue: Result! - var flagAsUnreadReturnValue: Result! { + func detachAllStates(except exception: AudioPlayerState?) async { + detachAllStatesExceptCallsCount += 1 + detachAllStatesExceptReceivedException = exception + DispatchQueue.main.async { + self.detachAllStatesExceptReceivedInvocations.append(exception) + } + await detachAllStatesExceptClosure?(exception) + } +} +class NetworkMonitorMock: NetworkMonitorProtocol { + var reachabilityPublisher: CurrentValuePublisher { + get { return underlyingReachabilityPublisher } + set(value) { underlyingReachabilityPublisher = value } + } + var underlyingReachabilityPublisher: CurrentValuePublisher! + +} +class NotificationManagerMock: NotificationManagerProtocol { + weak var delegate: NotificationManagerDelegate? + + //MARK: - start + + var startUnderlyingCallsCount = 0 + var startCallsCount: Int { get { if Thread.isMainThread { - return flagAsUnreadUnderlyingReturnValue + return startUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = flagAsUnreadUnderlyingReturnValue + returnValue = startUnderlyingCallsCount } return returnValue! @@ -9789,39 +9688,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - flagAsUnreadUnderlyingReturnValue = newValue + startUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - flagAsUnreadUnderlyingReturnValue = newValue + startUnderlyingCallsCount = newValue } } } } - var flagAsUnreadClosure: ((Bool) async -> Result)? + var startCalled: Bool { + return startCallsCount > 0 + } + var startClosure: (() -> Void)? - func flagAsUnread(_ isUnread: Bool) async -> Result { - flagAsUnreadCallsCount += 1 - flagAsUnreadReceivedIsUnread = isUnread - DispatchQueue.main.async { - self.flagAsUnreadReceivedInvocations.append(isUnread) - } - if let flagAsUnreadClosure = flagAsUnreadClosure { - return await flagAsUnreadClosure(isUnread) - } else { - return flagAsUnreadReturnValue - } + func start() { + startCallsCount += 1 + startClosure?() } - //MARK: - flagAsFavourite + //MARK: - register - var flagAsFavouriteUnderlyingCallsCount = 0 - var flagAsFavouriteCallsCount: Int { + var registerWithUnderlyingCallsCount = 0 + var registerWithCallsCount: Int { get { if Thread.isMainThread { - return flagAsFavouriteUnderlyingCallsCount + return registerWithUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = flagAsFavouriteUnderlyingCallsCount + returnValue = registerWithUnderlyingCallsCount } return returnValue! @@ -9829,29 +9723,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - flagAsFavouriteUnderlyingCallsCount = newValue + registerWithUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - flagAsFavouriteUnderlyingCallsCount = newValue + registerWithUnderlyingCallsCount = newValue } } } } - var flagAsFavouriteCalled: Bool { - return flagAsFavouriteCallsCount > 0 + var registerWithCalled: Bool { + return registerWithCallsCount > 0 } - var flagAsFavouriteReceivedIsFavourite: Bool? - var flagAsFavouriteReceivedInvocations: [Bool] = [] + var registerWithReceivedDeviceToken: Data? + var registerWithReceivedInvocations: [Data] = [] - var flagAsFavouriteUnderlyingReturnValue: Result! - var flagAsFavouriteReturnValue: Result! { + var registerWithUnderlyingReturnValue: Bool! + var registerWithReturnValue: Bool! { get { if Thread.isMainThread { - return flagAsFavouriteUnderlyingReturnValue + return registerWithUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = flagAsFavouriteUnderlyingReturnValue + returnValue = registerWithUnderlyingReturnValue } return returnValue! @@ -9859,67 +9753,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - flagAsFavouriteUnderlyingReturnValue = newValue + registerWithUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - flagAsFavouriteUnderlyingReturnValue = newValue + registerWithUnderlyingReturnValue = newValue } } } } - var flagAsFavouriteClosure: ((Bool) async -> Result)? + var registerWithClosure: ((Data) async -> Bool)? - func flagAsFavourite(_ isFavourite: Bool) async -> Result { - flagAsFavouriteCallsCount += 1 - flagAsFavouriteReceivedIsFavourite = isFavourite + func register(with deviceToken: Data) async -> Bool { + registerWithCallsCount += 1 + registerWithReceivedDeviceToken = deviceToken DispatchQueue.main.async { - self.flagAsFavouriteReceivedInvocations.append(isFavourite) + self.registerWithReceivedInvocations.append(deviceToken) } - if let flagAsFavouriteClosure = flagAsFavouriteClosure { - return await flagAsFavouriteClosure(isFavourite) + if let registerWithClosure = registerWithClosure { + return await registerWithClosure(deviceToken) } else { - return flagAsFavouriteReturnValue - } - } - //MARK: - powerLevels - - var powerLevelsUnderlyingCallsCount = 0 - var powerLevelsCallsCount: Int { - get { - if Thread.isMainThread { - return powerLevelsUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = powerLevelsUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - powerLevelsUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - powerLevelsUnderlyingCallsCount = newValue - } - } + return registerWithReturnValue } } - var powerLevelsCalled: Bool { - return powerLevelsCallsCount > 0 - } - - var powerLevelsUnderlyingReturnValue: Result! - var powerLevelsReturnValue: Result! { + //MARK: - registrationFailed + + var registrationFailedWithUnderlyingCallsCount = 0 + var registrationFailedWithCallsCount: Int { get { if Thread.isMainThread { - return powerLevelsUnderlyingReturnValue + return registrationFailedWithUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = powerLevelsUnderlyingReturnValue + returnValue = registrationFailedWithUnderlyingCallsCount } return returnValue! @@ -9927,35 +9793,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - powerLevelsUnderlyingReturnValue = newValue + registrationFailedWithUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - powerLevelsUnderlyingReturnValue = newValue + registrationFailedWithUnderlyingCallsCount = newValue } } } } - var powerLevelsClosure: (() async -> Result)? + var registrationFailedWithCalled: Bool { + return registrationFailedWithCallsCount > 0 + } + var registrationFailedWithReceivedError: Error? + var registrationFailedWithReceivedInvocations: [Error] = [] + var registrationFailedWithClosure: ((Error) -> Void)? - func powerLevels() async -> Result { - powerLevelsCallsCount += 1 - if let powerLevelsClosure = powerLevelsClosure { - return await powerLevelsClosure() - } else { - return powerLevelsReturnValue + func registrationFailed(with error: Error) { + registrationFailedWithCallsCount += 1 + registrationFailedWithReceivedError = error + DispatchQueue.main.async { + self.registrationFailedWithReceivedInvocations.append(error) } + registrationFailedWithClosure?(error) } - //MARK: - applyPowerLevelChanges + //MARK: - showLocalNotification - var applyPowerLevelChangesUnderlyingCallsCount = 0 - var applyPowerLevelChangesCallsCount: Int { + var showLocalNotificationWithSubtitleUnderlyingCallsCount = 0 + var showLocalNotificationWithSubtitleCallsCount: Int { get { if Thread.isMainThread { - return applyPowerLevelChangesUnderlyingCallsCount + return showLocalNotificationWithSubtitleUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = applyPowerLevelChangesUnderlyingCallsCount + returnValue = showLocalNotificationWithSubtitleUnderlyingCallsCount } return returnValue! @@ -9963,29 +9834,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - applyPowerLevelChangesUnderlyingCallsCount = newValue + showLocalNotificationWithSubtitleUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - applyPowerLevelChangesUnderlyingCallsCount = newValue + showLocalNotificationWithSubtitleUnderlyingCallsCount = newValue } } } } - var applyPowerLevelChangesCalled: Bool { - return applyPowerLevelChangesCallsCount > 0 + var showLocalNotificationWithSubtitleCalled: Bool { + return showLocalNotificationWithSubtitleCallsCount > 0 } - var applyPowerLevelChangesReceivedChanges: RoomPowerLevelChanges? - var applyPowerLevelChangesReceivedInvocations: [RoomPowerLevelChanges] = [] + var showLocalNotificationWithSubtitleReceivedArguments: (title: String, subtitle: String?)? + var showLocalNotificationWithSubtitleReceivedInvocations: [(title: String, subtitle: String?)] = [] + var showLocalNotificationWithSubtitleClosure: ((String, String?) async -> Void)? - var applyPowerLevelChangesUnderlyingReturnValue: Result! - var applyPowerLevelChangesReturnValue: Result! { + func showLocalNotification(with title: String, subtitle: String?) async { + showLocalNotificationWithSubtitleCallsCount += 1 + showLocalNotificationWithSubtitleReceivedArguments = (title: title, subtitle: subtitle) + DispatchQueue.main.async { + self.showLocalNotificationWithSubtitleReceivedInvocations.append((title: title, subtitle: subtitle)) + } + await showLocalNotificationWithSubtitleClosure?(title, subtitle) + } + //MARK: - setUserSession + + var setUserSessionUnderlyingCallsCount = 0 + var setUserSessionCallsCount: Int { get { if Thread.isMainThread { - return applyPowerLevelChangesUnderlyingReturnValue + return setUserSessionUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = applyPowerLevelChangesUnderlyingReturnValue + returnValue = setUserSessionUnderlyingCallsCount } return returnValue! @@ -9993,39 +9875,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - applyPowerLevelChangesUnderlyingReturnValue = newValue + setUserSessionUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - applyPowerLevelChangesUnderlyingReturnValue = newValue + setUserSessionUnderlyingCallsCount = newValue } } } } - var applyPowerLevelChangesClosure: ((RoomPowerLevelChanges) async -> Result)? + var setUserSessionCalled: Bool { + return setUserSessionCallsCount > 0 + } + var setUserSessionReceivedUserSession: UserSessionProtocol? + var setUserSessionReceivedInvocations: [UserSessionProtocol?] = [] + var setUserSessionClosure: ((UserSessionProtocol?) -> Void)? - func applyPowerLevelChanges(_ changes: RoomPowerLevelChanges) async -> Result { - applyPowerLevelChangesCallsCount += 1 - applyPowerLevelChangesReceivedChanges = changes + func setUserSession(_ userSession: UserSessionProtocol?) { + setUserSessionCallsCount += 1 + setUserSessionReceivedUserSession = userSession DispatchQueue.main.async { - self.applyPowerLevelChangesReceivedInvocations.append(changes) - } - if let applyPowerLevelChangesClosure = applyPowerLevelChangesClosure { - return await applyPowerLevelChangesClosure(changes) - } else { - return applyPowerLevelChangesReturnValue + self.setUserSessionReceivedInvocations.append(userSession) } + setUserSessionClosure?(userSession) } - //MARK: - resetPowerLevels + //MARK: - requestAuthorization - var resetPowerLevelsUnderlyingCallsCount = 0 - var resetPowerLevelsCallsCount: Int { + var requestAuthorizationUnderlyingCallsCount = 0 + var requestAuthorizationCallsCount: Int { get { if Thread.isMainThread { - return resetPowerLevelsUnderlyingCallsCount + return requestAuthorizationUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = resetPowerLevelsUnderlyingCallsCount + returnValue = requestAuthorizationUnderlyingCallsCount } return returnValue! @@ -10033,27 +9916,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - resetPowerLevelsUnderlyingCallsCount = newValue + requestAuthorizationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - resetPowerLevelsUnderlyingCallsCount = newValue + requestAuthorizationUnderlyingCallsCount = newValue } } } } - var resetPowerLevelsCalled: Bool { - return resetPowerLevelsCallsCount > 0 + var requestAuthorizationCalled: Bool { + return requestAuthorizationCallsCount > 0 } + var requestAuthorizationClosure: (() -> Void)? - var resetPowerLevelsUnderlyingReturnValue: Result! - var resetPowerLevelsReturnValue: Result! { + func requestAuthorization() { + requestAuthorizationCallsCount += 1 + requestAuthorizationClosure?() + } + //MARK: - removeDeliveredMessageNotifications + + var removeDeliveredMessageNotificationsForUnderlyingCallsCount = 0 + var removeDeliveredMessageNotificationsForCallsCount: Int { get { if Thread.isMainThread { - return resetPowerLevelsUnderlyingReturnValue + return removeDeliveredMessageNotificationsForUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = resetPowerLevelsUnderlyingReturnValue + returnValue = removeDeliveredMessageNotificationsForUnderlyingCallsCount } return returnValue! @@ -10061,35 +9951,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - resetPowerLevelsUnderlyingReturnValue = newValue + removeDeliveredMessageNotificationsForUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - resetPowerLevelsUnderlyingReturnValue = newValue + removeDeliveredMessageNotificationsForUnderlyingCallsCount = newValue } } } } - var resetPowerLevelsClosure: (() async -> Result)? + var removeDeliveredMessageNotificationsForCalled: Bool { + return removeDeliveredMessageNotificationsForCallsCount > 0 + } + var removeDeliveredMessageNotificationsForReceivedRoomID: String? + var removeDeliveredMessageNotificationsForReceivedInvocations: [String] = [] + var removeDeliveredMessageNotificationsForClosure: ((String) async -> Void)? - func resetPowerLevels() async -> Result { - resetPowerLevelsCallsCount += 1 - if let resetPowerLevelsClosure = resetPowerLevelsClosure { - return await resetPowerLevelsClosure() - } else { - return resetPowerLevelsReturnValue + func removeDeliveredMessageNotifications(for roomID: String) async { + removeDeliveredMessageNotificationsForCallsCount += 1 + removeDeliveredMessageNotificationsForReceivedRoomID = roomID + DispatchQueue.main.async { + self.removeDeliveredMessageNotificationsForReceivedInvocations.append(roomID) } + await removeDeliveredMessageNotificationsForClosure?(roomID) } - //MARK: - suggestedRole + //MARK: - removeDeliveredInviteNotifications - var suggestedRoleForUnderlyingCallsCount = 0 - var suggestedRoleForCallsCount: Int { + var removeDeliveredInviteNotificationsUnderlyingCallsCount = 0 + var removeDeliveredInviteNotificationsCallsCount: Int { get { if Thread.isMainThread { - return suggestedRoleForUnderlyingCallsCount + return removeDeliveredInviteNotificationsUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = suggestedRoleForUnderlyingCallsCount + returnValue = removeDeliveredInviteNotificationsUnderlyingCallsCount } return returnValue! @@ -10097,29 +9992,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - suggestedRoleForUnderlyingCallsCount = newValue + removeDeliveredInviteNotificationsUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - suggestedRoleForUnderlyingCallsCount = newValue + removeDeliveredInviteNotificationsUnderlyingCallsCount = newValue } } } } - var suggestedRoleForCalled: Bool { - return suggestedRoleForCallsCount > 0 + var removeDeliveredInviteNotificationsCalled: Bool { + return removeDeliveredInviteNotificationsCallsCount > 0 } - var suggestedRoleForReceivedUserID: String? - var suggestedRoleForReceivedInvocations: [String] = [] + var removeDeliveredInviteNotificationsClosure: (() async -> Void)? - var suggestedRoleForUnderlyingReturnValue: Result! - var suggestedRoleForReturnValue: Result! { + func removeDeliveredInviteNotifications() async { + removeDeliveredInviteNotificationsCallsCount += 1 + await removeDeliveredInviteNotificationsClosure?() + } +} +class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol { + var callbacks: PassthroughSubject { + get { return underlyingCallbacks } + set(value) { underlyingCallbacks = value } + } + var underlyingCallbacks: PassthroughSubject! + + //MARK: - getNotificationSettings + + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError: Error? + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = 0 + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount: Int { get { if Thread.isMainThread { - return suggestedRoleForUnderlyingReturnValue + return getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = suggestedRoleForUnderlyingReturnValue + returnValue = getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount } return returnValue! @@ -10127,39 +10036,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - suggestedRoleForUnderlyingReturnValue = newValue + getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - suggestedRoleForUnderlyingReturnValue = newValue + getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } } } } - var suggestedRoleForClosure: ((String) async -> Result)? - - func suggestedRole(for userID: String) async -> Result { - suggestedRoleForCallsCount += 1 - suggestedRoleForReceivedUserID = userID - DispatchQueue.main.async { - self.suggestedRoleForReceivedInvocations.append(userID) - } - if let suggestedRoleForClosure = suggestedRoleForClosure { - return await suggestedRoleForClosure(userID) - } else { - return suggestedRoleForReturnValue - } + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCalled: Bool { + return getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount > 0 } - //MARK: - updatePowerLevelsForUsers + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)? + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = [] - var updatePowerLevelsForUsersUnderlyingCallsCount = 0 - var updatePowerLevelsForUsersCallsCount: Int { + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue: RoomNotificationSettingsProxyProtocol! + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue: RoomNotificationSettingsProxyProtocol! { get { if Thread.isMainThread { - return updatePowerLevelsForUsersUnderlyingCallsCount + return getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: RoomNotificationSettingsProxyProtocol? = nil DispatchQueue.main.sync { - returnValue = updatePowerLevelsForUsersUnderlyingCallsCount + returnValue = getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue } return returnValue! @@ -10167,29 +10066,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - updatePowerLevelsForUsersUnderlyingCallsCount = newValue + getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - updatePowerLevelsForUsersUnderlyingCallsCount = newValue + getNotificationSettingsRoomIdIsEncryptedIsOneToOneUnderlyingReturnValue = newValue } } } } - var updatePowerLevelsForUsersCalled: Bool { - return updatePowerLevelsForUsersCallsCount > 0 + var getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> RoomNotificationSettingsProxyProtocol)? + + func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol { + if let error = getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError { + throw error + } + getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount += 1 + getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne) + DispatchQueue.main.async { + self.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)) + } + if let getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure = getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure { + return try await getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure(roomId, isEncrypted, isOneToOne) + } else { + return getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue + } } - var updatePowerLevelsForUsersReceivedUpdates: [(userID: String, powerLevel: Int64)]? - var updatePowerLevelsForUsersReceivedInvocations: [[(userID: String, powerLevel: Int64)]] = [] + //MARK: - setNotificationMode - var updatePowerLevelsForUsersUnderlyingReturnValue: Result! - var updatePowerLevelsForUsersReturnValue: Result! { + var setNotificationModeRoomIdModeThrowableError: Error? + var setNotificationModeRoomIdModeUnderlyingCallsCount = 0 + var setNotificationModeRoomIdModeCallsCount: Int { get { if Thread.isMainThread { - return updatePowerLevelsForUsersUnderlyingReturnValue + return setNotificationModeRoomIdModeUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = updatePowerLevelsForUsersUnderlyingReturnValue + returnValue = setNotificationModeRoomIdModeUnderlyingCallsCount } return returnValue! @@ -10197,39 +10110,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - updatePowerLevelsForUsersUnderlyingReturnValue = newValue + setNotificationModeRoomIdModeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - updatePowerLevelsForUsersUnderlyingReturnValue = newValue + setNotificationModeRoomIdModeUnderlyingCallsCount = newValue } } } } - var updatePowerLevelsForUsersClosure: (([(userID: String, powerLevel: Int64)]) async -> Result)? + var setNotificationModeRoomIdModeCalled: Bool { + return setNotificationModeRoomIdModeCallsCount > 0 + } + var setNotificationModeRoomIdModeReceivedArguments: (roomId: String, mode: RoomNotificationModeProxy)? + var setNotificationModeRoomIdModeReceivedInvocations: [(roomId: String, mode: RoomNotificationModeProxy)] = [] + var setNotificationModeRoomIdModeClosure: ((String, RoomNotificationModeProxy) async throws -> Void)? - func updatePowerLevelsForUsers(_ updates: [(userID: String, powerLevel: Int64)]) async -> Result { - updatePowerLevelsForUsersCallsCount += 1 - updatePowerLevelsForUsersReceivedUpdates = updates - DispatchQueue.main.async { - self.updatePowerLevelsForUsersReceivedInvocations.append(updates) + func setNotificationMode(roomId: String, mode: RoomNotificationModeProxy) async throws { + if let error = setNotificationModeRoomIdModeThrowableError { + throw error } - if let updatePowerLevelsForUsersClosure = updatePowerLevelsForUsersClosure { - return await updatePowerLevelsForUsersClosure(updates) - } else { - return updatePowerLevelsForUsersReturnValue + setNotificationModeRoomIdModeCallsCount += 1 + setNotificationModeRoomIdModeReceivedArguments = (roomId: roomId, mode: mode) + DispatchQueue.main.async { + self.setNotificationModeRoomIdModeReceivedInvocations.append((roomId: roomId, mode: mode)) } + try await setNotificationModeRoomIdModeClosure?(roomId, mode) } - //MARK: - canUser + //MARK: - getUserDefinedRoomNotificationMode - var canUserUserIDSendStateEventUnderlyingCallsCount = 0 - var canUserUserIDSendStateEventCallsCount: Int { + var getUserDefinedRoomNotificationModeRoomIdThrowableError: Error? + var getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = 0 + var getUserDefinedRoomNotificationModeRoomIdCallsCount: Int { get { if Thread.isMainThread { - return canUserUserIDSendStateEventUnderlyingCallsCount + return getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserUserIDSendStateEventUnderlyingCallsCount + returnValue = getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount } return returnValue! @@ -10237,29 +10155,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserUserIDSendStateEventUnderlyingCallsCount = newValue + getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserUserIDSendStateEventUnderlyingCallsCount = newValue + getUserDefinedRoomNotificationModeRoomIdUnderlyingCallsCount = newValue } } } } - var canUserUserIDSendStateEventCalled: Bool { - return canUserUserIDSendStateEventCallsCount > 0 + var getUserDefinedRoomNotificationModeRoomIdCalled: Bool { + return getUserDefinedRoomNotificationModeRoomIdCallsCount > 0 } - var canUserUserIDSendStateEventReceivedArguments: (userID: String, event: StateEventType)? - var canUserUserIDSendStateEventReceivedInvocations: [(userID: String, event: StateEventType)] = [] + var getUserDefinedRoomNotificationModeRoomIdReceivedRoomId: String? + var getUserDefinedRoomNotificationModeRoomIdReceivedInvocations: [String] = [] - var canUserUserIDSendStateEventUnderlyingReturnValue: Result! - var canUserUserIDSendStateEventReturnValue: Result! { + var getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue: RoomNotificationModeProxy? + var getUserDefinedRoomNotificationModeRoomIdReturnValue: RoomNotificationModeProxy? { get { if Thread.isMainThread { - return canUserUserIDSendStateEventUnderlyingReturnValue + return getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: RoomNotificationModeProxy?? = nil DispatchQueue.main.sync { - returnValue = canUserUserIDSendStateEventUnderlyingReturnValue + returnValue = getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue } return returnValue! @@ -10267,39 +10185,42 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserUserIDSendStateEventUnderlyingReturnValue = newValue + getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canUserUserIDSendStateEventUnderlyingReturnValue = newValue + getUserDefinedRoomNotificationModeRoomIdUnderlyingReturnValue = newValue } } } } - var canUserUserIDSendStateEventClosure: ((String, StateEventType) async -> Result)? + var getUserDefinedRoomNotificationModeRoomIdClosure: ((String) async throws -> RoomNotificationModeProxy?)? - func canUser(userID: String, sendStateEvent event: StateEventType) async -> Result { - canUserUserIDSendStateEventCallsCount += 1 - canUserUserIDSendStateEventReceivedArguments = (userID: userID, event: event) + func getUserDefinedRoomNotificationMode(roomId: String) async throws -> RoomNotificationModeProxy? { + if let error = getUserDefinedRoomNotificationModeRoomIdThrowableError { + throw error + } + getUserDefinedRoomNotificationModeRoomIdCallsCount += 1 + getUserDefinedRoomNotificationModeRoomIdReceivedRoomId = roomId DispatchQueue.main.async { - self.canUserUserIDSendStateEventReceivedInvocations.append((userID: userID, event: event)) + self.getUserDefinedRoomNotificationModeRoomIdReceivedInvocations.append(roomId) } - if let canUserUserIDSendStateEventClosure = canUserUserIDSendStateEventClosure { - return await canUserUserIDSendStateEventClosure(userID, event) + if let getUserDefinedRoomNotificationModeRoomIdClosure = getUserDefinedRoomNotificationModeRoomIdClosure { + return try await getUserDefinedRoomNotificationModeRoomIdClosure(roomId) } else { - return canUserUserIDSendStateEventReturnValue + return getUserDefinedRoomNotificationModeRoomIdReturnValue } } - //MARK: - canUserInvite + //MARK: - getDefaultRoomNotificationMode - var canUserInviteUserIDUnderlyingCallsCount = 0 - var canUserInviteUserIDCallsCount: Int { + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = 0 + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount: Int { get { if Thread.isMainThread { - return canUserInviteUserIDUnderlyingCallsCount + return getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserInviteUserIDUnderlyingCallsCount + returnValue = getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount } return returnValue! @@ -10307,29 +10228,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserInviteUserIDUnderlyingCallsCount = newValue + getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserInviteUserIDUnderlyingCallsCount = newValue + getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } } } } - var canUserInviteUserIDCalled: Bool { - return canUserInviteUserIDCallsCount > 0 + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneCalled: Bool { + return getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount > 0 } - var canUserInviteUserIDReceivedUserID: String? - var canUserInviteUserIDReceivedInvocations: [String] = [] + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool)? + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool)] = [] - var canUserInviteUserIDUnderlyingReturnValue: Result! - var canUserInviteUserIDReturnValue: Result! { + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue: RoomNotificationModeProxy! + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue: RoomNotificationModeProxy! { get { if Thread.isMainThread { - return canUserInviteUserIDUnderlyingReturnValue + return getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: RoomNotificationModeProxy? = nil DispatchQueue.main.sync { - returnValue = canUserInviteUserIDUnderlyingReturnValue + returnValue = getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue } return returnValue! @@ -10337,39 +10258,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserInviteUserIDUnderlyingReturnValue = newValue + getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canUserInviteUserIDUnderlyingReturnValue = newValue + getDefaultRoomNotificationModeIsEncryptedIsOneToOneUnderlyingReturnValue = newValue } } } } - var canUserInviteUserIDClosure: ((String) async -> Result)? + var getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure: ((Bool, Bool) async -> RoomNotificationModeProxy)? - func canUserInvite(userID: String) async -> Result { - canUserInviteUserIDCallsCount += 1 - canUserInviteUserIDReceivedUserID = userID + func getDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy { + getDefaultRoomNotificationModeIsEncryptedIsOneToOneCallsCount += 1 + getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne) DispatchQueue.main.async { - self.canUserInviteUserIDReceivedInvocations.append(userID) + self.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne)) } - if let canUserInviteUserIDClosure = canUserInviteUserIDClosure { - return await canUserInviteUserIDClosure(userID) + if let getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure = getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure { + return await getDefaultRoomNotificationModeIsEncryptedIsOneToOneClosure(isEncrypted, isOneToOne) } else { - return canUserInviteUserIDReturnValue + return getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue } } - //MARK: - canUserRedactOther + //MARK: - setDefaultRoomNotificationMode - var canUserRedactOtherUserIDUnderlyingCallsCount = 0 - var canUserRedactOtherUserIDCallsCount: Int { + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeThrowableError: Error? + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = 0 + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount: Int { get { if Thread.isMainThread { - return canUserRedactOtherUserIDUnderlyingCallsCount + return setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserRedactOtherUserIDUnderlyingCallsCount + returnValue = setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount } return returnValue! @@ -10377,69 +10299,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserRedactOtherUserIDUnderlyingCallsCount = newValue + setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserRedactOtherUserIDUnderlyingCallsCount = newValue + setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeUnderlyingCallsCount = newValue } } } } - var canUserRedactOtherUserIDCalled: Bool { - return canUserRedactOtherUserIDCallsCount > 0 + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCalled: Bool { + return setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount > 0 } - var canUserRedactOtherUserIDReceivedUserID: String? - var canUserRedactOtherUserIDReceivedInvocations: [String] = [] - - var canUserRedactOtherUserIDUnderlyingReturnValue: Result! - var canUserRedactOtherUserIDReturnValue: Result! { - get { - if Thread.isMainThread { - return canUserRedactOtherUserIDUnderlyingReturnValue - } else { - var returnValue: Result? = nil - DispatchQueue.main.sync { - returnValue = canUserRedactOtherUserIDUnderlyingReturnValue - } + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy)? + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy)] = [] + var setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeClosure: ((Bool, Bool, RoomNotificationModeProxy) async throws -> Void)? - return returnValue! - } - } - set { - if Thread.isMainThread { - canUserRedactOtherUserIDUnderlyingReturnValue = newValue - } else { - DispatchQueue.main.sync { - canUserRedactOtherUserIDUnderlyingReturnValue = newValue - } - } + func setDefaultRoomNotificationMode(isEncrypted: Bool, isOneToOne: Bool, mode: RoomNotificationModeProxy) async throws { + if let error = setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeThrowableError { + throw error } - } - var canUserRedactOtherUserIDClosure: ((String) async -> Result)? - - func canUserRedactOther(userID: String) async -> Result { - canUserRedactOtherUserIDCallsCount += 1 - canUserRedactOtherUserIDReceivedUserID = userID + setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeCallsCount += 1 + setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne, mode: mode) DispatchQueue.main.async { - self.canUserRedactOtherUserIDReceivedInvocations.append(userID) - } - if let canUserRedactOtherUserIDClosure = canUserRedactOtherUserIDClosure { - return await canUserRedactOtherUserIDClosure(userID) - } else { - return canUserRedactOtherUserIDReturnValue + self.setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne, mode: mode)) } + try await setDefaultRoomNotificationModeIsEncryptedIsOneToOneModeClosure?(isEncrypted, isOneToOne, mode) } - //MARK: - canUserRedactOwn + //MARK: - restoreDefaultNotificationMode - var canUserRedactOwnUserIDUnderlyingCallsCount = 0 - var canUserRedactOwnUserIDCallsCount: Int { + var restoreDefaultNotificationModeRoomIdThrowableError: Error? + var restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = 0 + var restoreDefaultNotificationModeRoomIdCallsCount: Int { get { if Thread.isMainThread { - return canUserRedactOwnUserIDUnderlyingCallsCount + return restoreDefaultNotificationModeRoomIdUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserRedactOwnUserIDUnderlyingCallsCount + returnValue = restoreDefaultNotificationModeRoomIdUnderlyingCallsCount } return returnValue! @@ -10447,29 +10344,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserRedactOwnUserIDUnderlyingCallsCount = newValue + restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserRedactOwnUserIDUnderlyingCallsCount = newValue + restoreDefaultNotificationModeRoomIdUnderlyingCallsCount = newValue } } } } - var canUserRedactOwnUserIDCalled: Bool { - return canUserRedactOwnUserIDCallsCount > 0 + var restoreDefaultNotificationModeRoomIdCalled: Bool { + return restoreDefaultNotificationModeRoomIdCallsCount > 0 } - var canUserRedactOwnUserIDReceivedUserID: String? - var canUserRedactOwnUserIDReceivedInvocations: [String] = [] + var restoreDefaultNotificationModeRoomIdReceivedRoomId: String? + var restoreDefaultNotificationModeRoomIdReceivedInvocations: [String] = [] + var restoreDefaultNotificationModeRoomIdClosure: ((String) async throws -> Void)? - var canUserRedactOwnUserIDUnderlyingReturnValue: Result! - var canUserRedactOwnUserIDReturnValue: Result! { + func restoreDefaultNotificationMode(roomId: String) async throws { + if let error = restoreDefaultNotificationModeRoomIdThrowableError { + throw error + } + restoreDefaultNotificationModeRoomIdCallsCount += 1 + restoreDefaultNotificationModeRoomIdReceivedRoomId = roomId + DispatchQueue.main.async { + self.restoreDefaultNotificationModeRoomIdReceivedInvocations.append(roomId) + } + try await restoreDefaultNotificationModeRoomIdClosure?(roomId) + } + //MARK: - unmuteRoom + + var unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError: Error? + var unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = 0 + var unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount: Int { get { if Thread.isMainThread { - return canUserRedactOwnUserIDUnderlyingReturnValue + return unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserRedactOwnUserIDUnderlyingReturnValue + returnValue = unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount } return returnValue! @@ -10477,39 +10389,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserRedactOwnUserIDUnderlyingReturnValue = newValue + unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserRedactOwnUserIDUnderlyingReturnValue = newValue + unmuteRoomRoomIdIsEncryptedIsOneToOneUnderlyingCallsCount = newValue } } } } - var canUserRedactOwnUserIDClosure: ((String) async -> Result)? + var unmuteRoomRoomIdIsEncryptedIsOneToOneCalled: Bool { + return unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount > 0 + } + var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)? + var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = [] + var unmuteRoomRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> Void)? - func canUserRedactOwn(userID: String) async -> Result { - canUserRedactOwnUserIDCallsCount += 1 - canUserRedactOwnUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserRedactOwnUserIDReceivedInvocations.append(userID) + func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws { + if let error = unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError { + throw error } - if let canUserRedactOwnUserIDClosure = canUserRedactOwnUserIDClosure { - return await canUserRedactOwnUserIDClosure(userID) - } else { - return canUserRedactOwnUserIDReturnValue + unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount += 1 + unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne) + DispatchQueue.main.async { + self.unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)) } + try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne) } - //MARK: - canUserKick + //MARK: - isRoomMentionEnabled - var canUserKickUserIDUnderlyingCallsCount = 0 - var canUserKickUserIDCallsCount: Int { + var isRoomMentionEnabledThrowableError: Error? + var isRoomMentionEnabledUnderlyingCallsCount = 0 + var isRoomMentionEnabledCallsCount: Int { get { if Thread.isMainThread { - return canUserKickUserIDUnderlyingCallsCount + return isRoomMentionEnabledUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserKickUserIDUnderlyingCallsCount + returnValue = isRoomMentionEnabledUnderlyingCallsCount } return returnValue! @@ -10517,29 +10434,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserKickUserIDUnderlyingCallsCount = newValue + isRoomMentionEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserKickUserIDUnderlyingCallsCount = newValue + isRoomMentionEnabledUnderlyingCallsCount = newValue } } } } - var canUserKickUserIDCalled: Bool { - return canUserKickUserIDCallsCount > 0 + var isRoomMentionEnabledCalled: Bool { + return isRoomMentionEnabledCallsCount > 0 } - var canUserKickUserIDReceivedUserID: String? - var canUserKickUserIDReceivedInvocations: [String] = [] - var canUserKickUserIDUnderlyingReturnValue: Result! - var canUserKickUserIDReturnValue: Result! { + var isRoomMentionEnabledUnderlyingReturnValue: Bool! + var isRoomMentionEnabledReturnValue: Bool! { get { if Thread.isMainThread { - return canUserKickUserIDUnderlyingReturnValue + return isRoomMentionEnabledUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = canUserKickUserIDUnderlyingReturnValue + returnValue = isRoomMentionEnabledUnderlyingReturnValue } return returnValue! @@ -10547,39 +10462,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserKickUserIDUnderlyingReturnValue = newValue + isRoomMentionEnabledUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canUserKickUserIDUnderlyingReturnValue = newValue + isRoomMentionEnabledUnderlyingReturnValue = newValue } } } } - var canUserKickUserIDClosure: ((String) async -> Result)? + var isRoomMentionEnabledClosure: (() async throws -> Bool)? - func canUserKick(userID: String) async -> Result { - canUserKickUserIDCallsCount += 1 - canUserKickUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserKickUserIDReceivedInvocations.append(userID) + func isRoomMentionEnabled() async throws -> Bool { + if let error = isRoomMentionEnabledThrowableError { + throw error } - if let canUserKickUserIDClosure = canUserKickUserIDClosure { - return await canUserKickUserIDClosure(userID) + isRoomMentionEnabledCallsCount += 1 + if let isRoomMentionEnabledClosure = isRoomMentionEnabledClosure { + return try await isRoomMentionEnabledClosure() } else { - return canUserKickUserIDReturnValue + return isRoomMentionEnabledReturnValue } } - //MARK: - canUserBan + //MARK: - setRoomMentionEnabled - var canUserBanUserIDUnderlyingCallsCount = 0 - var canUserBanUserIDCallsCount: Int { + var setRoomMentionEnabledEnabledThrowableError: Error? + var setRoomMentionEnabledEnabledUnderlyingCallsCount = 0 + var setRoomMentionEnabledEnabledCallsCount: Int { get { if Thread.isMainThread { - return canUserBanUserIDUnderlyingCallsCount + return setRoomMentionEnabledEnabledUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserBanUserIDUnderlyingCallsCount + returnValue = setRoomMentionEnabledEnabledUnderlyingCallsCount } return returnValue! @@ -10587,29 +10502,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserBanUserIDUnderlyingCallsCount = newValue + setRoomMentionEnabledEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserBanUserIDUnderlyingCallsCount = newValue + setRoomMentionEnabledEnabledUnderlyingCallsCount = newValue } } } } - var canUserBanUserIDCalled: Bool { - return canUserBanUserIDCallsCount > 0 + var setRoomMentionEnabledEnabledCalled: Bool { + return setRoomMentionEnabledEnabledCallsCount > 0 } - var canUserBanUserIDReceivedUserID: String? - var canUserBanUserIDReceivedInvocations: [String] = [] + var setRoomMentionEnabledEnabledReceivedEnabled: Bool? + var setRoomMentionEnabledEnabledReceivedInvocations: [Bool] = [] + var setRoomMentionEnabledEnabledClosure: ((Bool) async throws -> Void)? - var canUserBanUserIDUnderlyingReturnValue: Result! - var canUserBanUserIDReturnValue: Result! { + func setRoomMentionEnabled(enabled: Bool) async throws { + if let error = setRoomMentionEnabledEnabledThrowableError { + throw error + } + setRoomMentionEnabledEnabledCallsCount += 1 + setRoomMentionEnabledEnabledReceivedEnabled = enabled + DispatchQueue.main.async { + self.setRoomMentionEnabledEnabledReceivedInvocations.append(enabled) + } + try await setRoomMentionEnabledEnabledClosure?(enabled) + } + //MARK: - isCallEnabled + + var isCallEnabledThrowableError: Error? + var isCallEnabledUnderlyingCallsCount = 0 + var isCallEnabledCallsCount: Int { get { if Thread.isMainThread { - return canUserBanUserIDUnderlyingReturnValue + return isCallEnabledUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserBanUserIDUnderlyingReturnValue + returnValue = isCallEnabledUnderlyingCallsCount } return returnValue! @@ -10617,39 +10547,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserBanUserIDUnderlyingReturnValue = newValue + isCallEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserBanUserIDUnderlyingReturnValue = newValue + isCallEnabledUnderlyingCallsCount = newValue } } } } - var canUserBanUserIDClosure: ((String) async -> Result)? - - func canUserBan(userID: String) async -> Result { - canUserBanUserIDCallsCount += 1 - canUserBanUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserBanUserIDReceivedInvocations.append(userID) - } - if let canUserBanUserIDClosure = canUserBanUserIDClosure { - return await canUserBanUserIDClosure(userID) - } else { - return canUserBanUserIDReturnValue - } + var isCallEnabledCalled: Bool { + return isCallEnabledCallsCount > 0 } - //MARK: - canUserTriggerRoomNotification - var canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = 0 - var canUserTriggerRoomNotificationUserIDCallsCount: Int { + var isCallEnabledUnderlyingReturnValue: Bool! + var isCallEnabledReturnValue: Bool! { get { if Thread.isMainThread { - return canUserTriggerRoomNotificationUserIDUnderlyingCallsCount + return isCallEnabledUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = canUserTriggerRoomNotificationUserIDUnderlyingCallsCount + returnValue = isCallEnabledUnderlyingReturnValue } return returnValue! @@ -10657,29 +10575,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = newValue + isCallEnabledUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canUserTriggerRoomNotificationUserIDUnderlyingCallsCount = newValue + isCallEnabledUnderlyingReturnValue = newValue } } } } - var canUserTriggerRoomNotificationUserIDCalled: Bool { - return canUserTriggerRoomNotificationUserIDCallsCount > 0 + var isCallEnabledClosure: (() async throws -> Bool)? + + func isCallEnabled() async throws -> Bool { + if let error = isCallEnabledThrowableError { + throw error + } + isCallEnabledCallsCount += 1 + if let isCallEnabledClosure = isCallEnabledClosure { + return try await isCallEnabledClosure() + } else { + return isCallEnabledReturnValue + } } - var canUserTriggerRoomNotificationUserIDReceivedUserID: String? - var canUserTriggerRoomNotificationUserIDReceivedInvocations: [String] = [] + //MARK: - setCallEnabled - var canUserTriggerRoomNotificationUserIDUnderlyingReturnValue: Result! - var canUserTriggerRoomNotificationUserIDReturnValue: Result! { + var setCallEnabledEnabledThrowableError: Error? + var setCallEnabledEnabledUnderlyingCallsCount = 0 + var setCallEnabledEnabledCallsCount: Int { get { if Thread.isMainThread { - return canUserTriggerRoomNotificationUserIDUnderlyingReturnValue + return setCallEnabledEnabledUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserTriggerRoomNotificationUserIDUnderlyingReturnValue + returnValue = setCallEnabledEnabledUnderlyingCallsCount } return returnValue! @@ -10687,39 +10615,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserTriggerRoomNotificationUserIDUnderlyingReturnValue = newValue + setCallEnabledEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserTriggerRoomNotificationUserIDUnderlyingReturnValue = newValue + setCallEnabledEnabledUnderlyingCallsCount = newValue } } } } - var canUserTriggerRoomNotificationUserIDClosure: ((String) async -> Result)? + var setCallEnabledEnabledCalled: Bool { + return setCallEnabledEnabledCallsCount > 0 + } + var setCallEnabledEnabledReceivedEnabled: Bool? + var setCallEnabledEnabledReceivedInvocations: [Bool] = [] + var setCallEnabledEnabledClosure: ((Bool) async throws -> Void)? - func canUserTriggerRoomNotification(userID: String) async -> Result { - canUserTriggerRoomNotificationUserIDCallsCount += 1 - canUserTriggerRoomNotificationUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserTriggerRoomNotificationUserIDReceivedInvocations.append(userID) + func setCallEnabled(enabled: Bool) async throws { + if let error = setCallEnabledEnabledThrowableError { + throw error } - if let canUserTriggerRoomNotificationUserIDClosure = canUserTriggerRoomNotificationUserIDClosure { - return await canUserTriggerRoomNotificationUserIDClosure(userID) - } else { - return canUserTriggerRoomNotificationUserIDReturnValue + setCallEnabledEnabledCallsCount += 1 + setCallEnabledEnabledReceivedEnabled = enabled + DispatchQueue.main.async { + self.setCallEnabledEnabledReceivedInvocations.append(enabled) } + try await setCallEnabledEnabledClosure?(enabled) } - //MARK: - canUserPinOrUnpin + //MARK: - isInviteForMeEnabled - var canUserPinOrUnpinUserIDUnderlyingCallsCount = 0 - var canUserPinOrUnpinUserIDCallsCount: Int { + var isInviteForMeEnabledThrowableError: Error? + var isInviteForMeEnabledUnderlyingCallsCount = 0 + var isInviteForMeEnabledCallsCount: Int { get { if Thread.isMainThread { - return canUserPinOrUnpinUserIDUnderlyingCallsCount + return isInviteForMeEnabledUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserPinOrUnpinUserIDUnderlyingCallsCount + returnValue = isInviteForMeEnabledUnderlyingCallsCount } return returnValue! @@ -10727,29 +10660,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue + isInviteForMeEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserPinOrUnpinUserIDUnderlyingCallsCount = newValue + isInviteForMeEnabledUnderlyingCallsCount = newValue } } } } - var canUserPinOrUnpinUserIDCalled: Bool { - return canUserPinOrUnpinUserIDCallsCount > 0 + var isInviteForMeEnabledCalled: Bool { + return isInviteForMeEnabledCallsCount > 0 } - var canUserPinOrUnpinUserIDReceivedUserID: String? - var canUserPinOrUnpinUserIDReceivedInvocations: [String] = [] - var canUserPinOrUnpinUserIDUnderlyingReturnValue: Result! - var canUserPinOrUnpinUserIDReturnValue: Result! { + var isInviteForMeEnabledUnderlyingReturnValue: Bool! + var isInviteForMeEnabledReturnValue: Bool! { get { if Thread.isMainThread { - return canUserPinOrUnpinUserIDUnderlyingReturnValue + return isInviteForMeEnabledUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = canUserPinOrUnpinUserIDUnderlyingReturnValue + returnValue = isInviteForMeEnabledUnderlyingReturnValue } return returnValue! @@ -10757,39 +10688,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue + isInviteForMeEnabledUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - canUserPinOrUnpinUserIDUnderlyingReturnValue = newValue + isInviteForMeEnabledUnderlyingReturnValue = newValue } } } } - var canUserPinOrUnpinUserIDClosure: ((String) async -> Result)? + var isInviteForMeEnabledClosure: (() async throws -> Bool)? - func canUserPinOrUnpin(userID: String) async -> Result { - canUserPinOrUnpinUserIDCallsCount += 1 - canUserPinOrUnpinUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserPinOrUnpinUserIDReceivedInvocations.append(userID) + func isInviteForMeEnabled() async throws -> Bool { + if let error = isInviteForMeEnabledThrowableError { + throw error } - if let canUserPinOrUnpinUserIDClosure = canUserPinOrUnpinUserIDClosure { - return await canUserPinOrUnpinUserIDClosure(userID) + isInviteForMeEnabledCallsCount += 1 + if let isInviteForMeEnabledClosure = isInviteForMeEnabledClosure { + return try await isInviteForMeEnabledClosure() } else { - return canUserPinOrUnpinUserIDReturnValue + return isInviteForMeEnabledReturnValue } } - //MARK: - kickUser + //MARK: - setInviteForMeEnabled - var kickUserUnderlyingCallsCount = 0 - var kickUserCallsCount: Int { + var setInviteForMeEnabledEnabledThrowableError: Error? + var setInviteForMeEnabledEnabledUnderlyingCallsCount = 0 + var setInviteForMeEnabledEnabledCallsCount: Int { get { if Thread.isMainThread { - return kickUserUnderlyingCallsCount + return setInviteForMeEnabledEnabledUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = kickUserUnderlyingCallsCount + returnValue = setInviteForMeEnabledEnabledUnderlyingCallsCount } return returnValue! @@ -10797,29 +10728,44 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - kickUserUnderlyingCallsCount = newValue + setInviteForMeEnabledEnabledUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - kickUserUnderlyingCallsCount = newValue + setInviteForMeEnabledEnabledUnderlyingCallsCount = newValue } } } } - var kickUserCalled: Bool { - return kickUserCallsCount > 0 + var setInviteForMeEnabledEnabledCalled: Bool { + return setInviteForMeEnabledEnabledCallsCount > 0 } - var kickUserReceivedUserID: String? - var kickUserReceivedInvocations: [String] = [] + var setInviteForMeEnabledEnabledReceivedEnabled: Bool? + var setInviteForMeEnabledEnabledReceivedInvocations: [Bool] = [] + var setInviteForMeEnabledEnabledClosure: ((Bool) async throws -> Void)? - var kickUserUnderlyingReturnValue: Result! - var kickUserReturnValue: Result! { + func setInviteForMeEnabled(enabled: Bool) async throws { + if let error = setInviteForMeEnabledEnabledThrowableError { + throw error + } + setInviteForMeEnabledEnabledCallsCount += 1 + setInviteForMeEnabledEnabledReceivedEnabled = enabled + DispatchQueue.main.async { + self.setInviteForMeEnabledEnabledReceivedInvocations.append(enabled) + } + try await setInviteForMeEnabledEnabledClosure?(enabled) + } + //MARK: - getRoomsWithUserDefinedRules + + var getRoomsWithUserDefinedRulesThrowableError: Error? + var getRoomsWithUserDefinedRulesUnderlyingCallsCount = 0 + var getRoomsWithUserDefinedRulesCallsCount: Int { get { if Thread.isMainThread { - return kickUserUnderlyingReturnValue + return getRoomsWithUserDefinedRulesUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = kickUserUnderlyingReturnValue + returnValue = getRoomsWithUserDefinedRulesUnderlyingCallsCount } return returnValue! @@ -10827,39 +10773,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - kickUserUnderlyingReturnValue = newValue + getRoomsWithUserDefinedRulesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - kickUserUnderlyingReturnValue = newValue + getRoomsWithUserDefinedRulesUnderlyingCallsCount = newValue } } } } - var kickUserClosure: ((String) async -> Result)? - - func kickUser(_ userID: String) async -> Result { - kickUserCallsCount += 1 - kickUserReceivedUserID = userID - DispatchQueue.main.async { - self.kickUserReceivedInvocations.append(userID) - } - if let kickUserClosure = kickUserClosure { - return await kickUserClosure(userID) - } else { - return kickUserReturnValue - } + var getRoomsWithUserDefinedRulesCalled: Bool { + return getRoomsWithUserDefinedRulesCallsCount > 0 } - //MARK: - banUser - var banUserUnderlyingCallsCount = 0 - var banUserCallsCount: Int { + var getRoomsWithUserDefinedRulesUnderlyingReturnValue: [String]! + var getRoomsWithUserDefinedRulesReturnValue: [String]! { get { if Thread.isMainThread { - return banUserUnderlyingCallsCount + return getRoomsWithUserDefinedRulesUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: [String]? = nil DispatchQueue.main.sync { - returnValue = banUserUnderlyingCallsCount + returnValue = getRoomsWithUserDefinedRulesUnderlyingReturnValue } return returnValue! @@ -10867,29 +10801,38 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - banUserUnderlyingCallsCount = newValue + getRoomsWithUserDefinedRulesUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - banUserUnderlyingCallsCount = newValue + getRoomsWithUserDefinedRulesUnderlyingReturnValue = newValue } } } } - var banUserCalled: Bool { - return banUserCallsCount > 0 + var getRoomsWithUserDefinedRulesClosure: (() async throws -> [String])? + + func getRoomsWithUserDefinedRules() async throws -> [String] { + if let error = getRoomsWithUserDefinedRulesThrowableError { + throw error + } + getRoomsWithUserDefinedRulesCallsCount += 1 + if let getRoomsWithUserDefinedRulesClosure = getRoomsWithUserDefinedRulesClosure { + return try await getRoomsWithUserDefinedRulesClosure() + } else { + return getRoomsWithUserDefinedRulesReturnValue + } } - var banUserReceivedUserID: String? - var banUserReceivedInvocations: [String] = [] + //MARK: - canPushEncryptedEventsToDevice - var banUserUnderlyingReturnValue: Result! - var banUserReturnValue: Result! { + var canPushEncryptedEventsToDeviceUnderlyingCallsCount = 0 + var canPushEncryptedEventsToDeviceCallsCount: Int { get { if Thread.isMainThread { - return banUserUnderlyingReturnValue + return canPushEncryptedEventsToDeviceUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = banUserUnderlyingReturnValue + returnValue = canPushEncryptedEventsToDeviceUnderlyingCallsCount } return returnValue! @@ -10897,39 +10840,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - banUserUnderlyingReturnValue = newValue + canPushEncryptedEventsToDeviceUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - banUserUnderlyingReturnValue = newValue + canPushEncryptedEventsToDeviceUnderlyingCallsCount = newValue } } } } - var banUserClosure: ((String) async -> Result)? - - func banUser(_ userID: String) async -> Result { - banUserCallsCount += 1 - banUserReceivedUserID = userID - DispatchQueue.main.async { - self.banUserReceivedInvocations.append(userID) - } - if let banUserClosure = banUserClosure { - return await banUserClosure(userID) - } else { - return banUserReturnValue - } + var canPushEncryptedEventsToDeviceCalled: Bool { + return canPushEncryptedEventsToDeviceCallsCount > 0 } - //MARK: - unbanUser - var unbanUserUnderlyingCallsCount = 0 - var unbanUserCallsCount: Int { + var canPushEncryptedEventsToDeviceUnderlyingReturnValue: Bool! + var canPushEncryptedEventsToDeviceReturnValue: Bool! { get { if Thread.isMainThread { - return unbanUserUnderlyingCallsCount + return canPushEncryptedEventsToDeviceUnderlyingReturnValue } else { - var returnValue: Int? = nil + var returnValue: Bool? = nil DispatchQueue.main.sync { - returnValue = unbanUserUnderlyingCallsCount + returnValue = canPushEncryptedEventsToDeviceUnderlyingReturnValue } return returnValue! @@ -10937,29 +10868,38 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - unbanUserUnderlyingCallsCount = newValue + canPushEncryptedEventsToDeviceUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - unbanUserUnderlyingCallsCount = newValue + canPushEncryptedEventsToDeviceUnderlyingReturnValue = newValue } } } } - var unbanUserCalled: Bool { - return unbanUserCallsCount > 0 + var canPushEncryptedEventsToDeviceClosure: (() async -> Bool)? + + func canPushEncryptedEventsToDevice() async -> Bool { + canPushEncryptedEventsToDeviceCallsCount += 1 + if let canPushEncryptedEventsToDeviceClosure = canPushEncryptedEventsToDeviceClosure { + return await canPushEncryptedEventsToDeviceClosure() + } else { + return canPushEncryptedEventsToDeviceReturnValue + } } - var unbanUserReceivedUserID: String? - var unbanUserReceivedInvocations: [String] = [] +} +class OrientationManagerMock: OrientationManagerProtocol { - var unbanUserUnderlyingReturnValue: Result! - var unbanUserReturnValue: Result! { + //MARK: - setOrientation + + var setOrientationUnderlyingCallsCount = 0 + var setOrientationCallsCount: Int { get { if Thread.isMainThread { - return unbanUserUnderlyingReturnValue + return setOrientationUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = unbanUserUnderlyingReturnValue + returnValue = setOrientationUnderlyingCallsCount } return returnValue! @@ -10967,39 +10907,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - unbanUserUnderlyingReturnValue = newValue + setOrientationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - unbanUserUnderlyingReturnValue = newValue + setOrientationUnderlyingCallsCount = newValue } } } } - var unbanUserClosure: ((String) async -> Result)? + var setOrientationCalled: Bool { + return setOrientationCallsCount > 0 + } + var setOrientationReceivedOrientation: UIInterfaceOrientationMask? + var setOrientationReceivedInvocations: [UIInterfaceOrientationMask] = [] + var setOrientationClosure: ((UIInterfaceOrientationMask) -> Void)? - func unbanUser(_ userID: String) async -> Result { - unbanUserCallsCount += 1 - unbanUserReceivedUserID = userID + func setOrientation(_ orientation: UIInterfaceOrientationMask) { + setOrientationCallsCount += 1 + setOrientationReceivedOrientation = orientation DispatchQueue.main.async { - self.unbanUserReceivedInvocations.append(userID) - } - if let unbanUserClosure = unbanUserClosure { - return await unbanUserClosure(userID) - } else { - return unbanUserReturnValue + self.setOrientationReceivedInvocations.append(orientation) } + setOrientationClosure?(orientation) } - //MARK: - canUserJoinCall + //MARK: - lockOrientation - var canUserJoinCallUserIDUnderlyingCallsCount = 0 - var canUserJoinCallUserIDCallsCount: Int { + var lockOrientationUnderlyingCallsCount = 0 + var lockOrientationCallsCount: Int { get { if Thread.isMainThread { - return canUserJoinCallUserIDUnderlyingCallsCount + return lockOrientationUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserJoinCallUserIDUnderlyingCallsCount + returnValue = lockOrientationUnderlyingCallsCount } return returnValue! @@ -11007,29 +10948,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserJoinCallUserIDUnderlyingCallsCount = newValue + lockOrientationUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserJoinCallUserIDUnderlyingCallsCount = newValue + lockOrientationUnderlyingCallsCount = newValue } } } } - var canUserJoinCallUserIDCalled: Bool { - return canUserJoinCallUserIDCallsCount > 0 + var lockOrientationCalled: Bool { + return lockOrientationCallsCount > 0 } - var canUserJoinCallUserIDReceivedUserID: String? - var canUserJoinCallUserIDReceivedInvocations: [String] = [] + var lockOrientationReceivedOrientation: UIInterfaceOrientationMask? + var lockOrientationReceivedInvocations: [UIInterfaceOrientationMask] = [] + var lockOrientationClosure: ((UIInterfaceOrientationMask) -> Void)? - var canUserJoinCallUserIDUnderlyingReturnValue: Result! - var canUserJoinCallUserIDReturnValue: Result! { + func lockOrientation(_ orientation: UIInterfaceOrientationMask) { + lockOrientationCallsCount += 1 + lockOrientationReceivedOrientation = orientation + DispatchQueue.main.async { + self.lockOrientationReceivedInvocations.append(orientation) + } + lockOrientationClosure?(orientation) + } +} +class PHGPostHogMock: PHGPostHogProtocol { + + //MARK: - optIn + + var optInUnderlyingCallsCount = 0 + var optInCallsCount: Int { get { if Thread.isMainThread { - return canUserJoinCallUserIDUnderlyingReturnValue + return optInUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = canUserJoinCallUserIDUnderlyingReturnValue + returnValue = optInUnderlyingCallsCount } return returnValue! @@ -11037,39 +10992,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - canUserJoinCallUserIDUnderlyingReturnValue = newValue + optInUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - canUserJoinCallUserIDUnderlyingReturnValue = newValue + optInUnderlyingCallsCount = newValue } } } } - var canUserJoinCallUserIDClosure: ((String) async -> Result)? + var optInCalled: Bool { + return optInCallsCount > 0 + } + var optInClosure: (() -> Void)? - func canUserJoinCall(userID: String) async -> Result { - canUserJoinCallUserIDCallsCount += 1 - canUserJoinCallUserIDReceivedUserID = userID - DispatchQueue.main.async { - self.canUserJoinCallUserIDReceivedInvocations.append(userID) - } - if let canUserJoinCallUserIDClosure = canUserJoinCallUserIDClosure { - return await canUserJoinCallUserIDClosure(userID) - } else { - return canUserJoinCallUserIDReturnValue - } + func optIn() { + optInCallsCount += 1 + optInClosure?() } - //MARK: - elementCallWidgetDriver + //MARK: - optOut - var elementCallWidgetDriverDeviceIDUnderlyingCallsCount = 0 - var elementCallWidgetDriverDeviceIDCallsCount: Int { + var optOutUnderlyingCallsCount = 0 + var optOutCallsCount: Int { get { if Thread.isMainThread { - return elementCallWidgetDriverDeviceIDUnderlyingCallsCount + return optOutUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = elementCallWidgetDriverDeviceIDUnderlyingCallsCount + returnValue = optOutUnderlyingCallsCount } return returnValue! @@ -11077,29 +11027,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - elementCallWidgetDriverDeviceIDUnderlyingCallsCount = newValue + optOutUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - elementCallWidgetDriverDeviceIDUnderlyingCallsCount = newValue + optOutUnderlyingCallsCount = newValue } } } } - var elementCallWidgetDriverDeviceIDCalled: Bool { - return elementCallWidgetDriverDeviceIDCallsCount > 0 + var optOutCalled: Bool { + return optOutCallsCount > 0 } - var elementCallWidgetDriverDeviceIDReceivedDeviceID: String? - var elementCallWidgetDriverDeviceIDReceivedInvocations: [String] = [] + var optOutClosure: (() -> Void)? - var elementCallWidgetDriverDeviceIDUnderlyingReturnValue: ElementCallWidgetDriverProtocol! - var elementCallWidgetDriverDeviceIDReturnValue: ElementCallWidgetDriverProtocol! { + func optOut() { + optOutCallsCount += 1 + optOutClosure?() + } + //MARK: - reset + + var resetUnderlyingCallsCount = 0 + var resetCallsCount: Int { get { if Thread.isMainThread { - return elementCallWidgetDriverDeviceIDUnderlyingReturnValue + return resetUnderlyingCallsCount } else { - var returnValue: ElementCallWidgetDriverProtocol? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = elementCallWidgetDriverDeviceIDUnderlyingReturnValue + returnValue = resetUnderlyingCallsCount } return returnValue! @@ -11107,39 +11062,34 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - elementCallWidgetDriverDeviceIDUnderlyingReturnValue = newValue + resetUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - elementCallWidgetDriverDeviceIDUnderlyingReturnValue = newValue + resetUnderlyingCallsCount = newValue } } } } - var elementCallWidgetDriverDeviceIDClosure: ((String) -> ElementCallWidgetDriverProtocol)? + var resetCalled: Bool { + return resetCallsCount > 0 + } + var resetClosure: (() -> Void)? - func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol { - elementCallWidgetDriverDeviceIDCallsCount += 1 - elementCallWidgetDriverDeviceIDReceivedDeviceID = deviceID - DispatchQueue.main.async { - self.elementCallWidgetDriverDeviceIDReceivedInvocations.append(deviceID) - } - if let elementCallWidgetDriverDeviceIDClosure = elementCallWidgetDriverDeviceIDClosure { - return elementCallWidgetDriverDeviceIDClosure(deviceID) - } else { - return elementCallWidgetDriverDeviceIDReturnValue - } + func reset() { + resetCallsCount += 1 + resetClosure?() } - //MARK: - sendCallNotificationIfNeeded + //MARK: - capture - var sendCallNotificationIfNeededUnderlyingCallsCount = 0 - var sendCallNotificationIfNeededCallsCount: Int { + var capturePropertiesUserPropertiesUnderlyingCallsCount = 0 + var capturePropertiesUserPropertiesCallsCount: Int { get { if Thread.isMainThread { - return sendCallNotificationIfNeededUnderlyingCallsCount + return capturePropertiesUserPropertiesUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = sendCallNotificationIfNeededUnderlyingCallsCount + returnValue = capturePropertiesUserPropertiesUnderlyingCallsCount } return returnValue! @@ -11147,27 +11097,40 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - sendCallNotificationIfNeededUnderlyingCallsCount = newValue + capturePropertiesUserPropertiesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - sendCallNotificationIfNeededUnderlyingCallsCount = newValue + capturePropertiesUserPropertiesUnderlyingCallsCount = newValue } } } } - var sendCallNotificationIfNeededCalled: Bool { - return sendCallNotificationIfNeededCallsCount > 0 + var capturePropertiesUserPropertiesCalled: Bool { + return capturePropertiesUserPropertiesCallsCount > 0 + } + var capturePropertiesUserPropertiesReceivedArguments: (event: String, properties: [String: Any]?, userProperties: [String: Any]?)? + var capturePropertiesUserPropertiesReceivedInvocations: [(event: String, properties: [String: Any]?, userProperties: [String: Any]?)] = [] + var capturePropertiesUserPropertiesClosure: ((String, [String: Any]?, [String: Any]?) -> Void)? + + func capture(_ event: String, properties: [String: Any]?, userProperties: [String: Any]?) { + capturePropertiesUserPropertiesCallsCount += 1 + capturePropertiesUserPropertiesReceivedArguments = (event: event, properties: properties, userProperties: userProperties) + DispatchQueue.main.async { + self.capturePropertiesUserPropertiesReceivedInvocations.append((event: event, properties: properties, userProperties: userProperties)) + } + capturePropertiesUserPropertiesClosure?(event, properties, userProperties) } + //MARK: - screen - var sendCallNotificationIfNeededUnderlyingReturnValue: Result! - var sendCallNotificationIfNeededReturnValue: Result! { + var screenPropertiesUnderlyingCallsCount = 0 + var screenPropertiesCallsCount: Int { get { if Thread.isMainThread { - return sendCallNotificationIfNeededUnderlyingReturnValue + return screenPropertiesUnderlyingCallsCount } else { - var returnValue: Result? = nil + var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = sendCallNotificationIfNeededUnderlyingReturnValue + returnValue = screenPropertiesUnderlyingCallsCount } return returnValue! @@ -11175,35 +11138,43 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - sendCallNotificationIfNeededUnderlyingReturnValue = newValue + screenPropertiesUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - sendCallNotificationIfNeededUnderlyingReturnValue = newValue + screenPropertiesUnderlyingCallsCount = newValue } } } } - var sendCallNotificationIfNeededClosure: (() async -> Result)? + var screenPropertiesCalled: Bool { + return screenPropertiesCallsCount > 0 + } + var screenPropertiesReceivedArguments: (screenTitle: String, properties: [String: Any]?)? + var screenPropertiesReceivedInvocations: [(screenTitle: String, properties: [String: Any]?)] = [] + var screenPropertiesClosure: ((String, [String: Any]?) -> Void)? - func sendCallNotificationIfNeeded() async -> Result { - sendCallNotificationIfNeededCallsCount += 1 - if let sendCallNotificationIfNeededClosure = sendCallNotificationIfNeededClosure { - return await sendCallNotificationIfNeededClosure() - } else { - return sendCallNotificationIfNeededReturnValue + func screen(_ screenTitle: String, properties: [String: Any]?) { + screenPropertiesCallsCount += 1 + screenPropertiesReceivedArguments = (screenTitle: screenTitle, properties: properties) + DispatchQueue.main.async { + self.screenPropertiesReceivedInvocations.append((screenTitle: screenTitle, properties: properties)) } + screenPropertiesClosure?(screenTitle, properties) } - //MARK: - matrixToPermalink +} +class PollInteractionHandlerMock: PollInteractionHandlerProtocol { - var matrixToPermalinkUnderlyingCallsCount = 0 - var matrixToPermalinkCallsCount: Int { + //MARK: - sendPollResponse + + var sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = 0 + var sendPollResponsePollStartIDOptionIDCallsCount: Int { get { if Thread.isMainThread { - return matrixToPermalinkUnderlyingCallsCount + return sendPollResponsePollStartIDOptionIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = matrixToPermalinkUnderlyingCallsCount + returnValue = sendPollResponsePollStartIDOptionIDUnderlyingCallsCount } return returnValue! @@ -11211,27 +11182,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - matrixToPermalinkUnderlyingCallsCount = newValue + sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - matrixToPermalinkUnderlyingCallsCount = newValue + sendPollResponsePollStartIDOptionIDUnderlyingCallsCount = newValue } } } } - var matrixToPermalinkCalled: Bool { - return matrixToPermalinkCallsCount > 0 + var sendPollResponsePollStartIDOptionIDCalled: Bool { + return sendPollResponsePollStartIDOptionIDCallsCount > 0 } + var sendPollResponsePollStartIDOptionIDReceivedArguments: (pollStartID: String, optionID: String)? + var sendPollResponsePollStartIDOptionIDReceivedInvocations: [(pollStartID: String, optionID: String)] = [] - var matrixToPermalinkUnderlyingReturnValue: Result! - var matrixToPermalinkReturnValue: Result! { + var sendPollResponsePollStartIDOptionIDUnderlyingReturnValue: Result! + var sendPollResponsePollStartIDOptionIDReturnValue: Result! { get { if Thread.isMainThread { - return matrixToPermalinkUnderlyingReturnValue + return sendPollResponsePollStartIDOptionIDUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = matrixToPermalinkUnderlyingReturnValue + returnValue = sendPollResponsePollStartIDOptionIDUnderlyingReturnValue } return returnValue! @@ -11239,35 +11212,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - matrixToPermalinkUnderlyingReturnValue = newValue + sendPollResponsePollStartIDOptionIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - matrixToPermalinkUnderlyingReturnValue = newValue + sendPollResponsePollStartIDOptionIDUnderlyingReturnValue = newValue } } } } - var matrixToPermalinkClosure: (() async -> Result)? + var sendPollResponsePollStartIDOptionIDClosure: ((String, String) async -> Result)? - func matrixToPermalink() async -> Result { - matrixToPermalinkCallsCount += 1 - if let matrixToPermalinkClosure = matrixToPermalinkClosure { - return await matrixToPermalinkClosure() + func sendPollResponse(pollStartID: String, optionID: String) async -> Result { + sendPollResponsePollStartIDOptionIDCallsCount += 1 + sendPollResponsePollStartIDOptionIDReceivedArguments = (pollStartID: pollStartID, optionID: optionID) + DispatchQueue.main.async { + self.sendPollResponsePollStartIDOptionIDReceivedInvocations.append((pollStartID: pollStartID, optionID: optionID)) + } + if let sendPollResponsePollStartIDOptionIDClosure = sendPollResponsePollStartIDOptionIDClosure { + return await sendPollResponsePollStartIDOptionIDClosure(pollStartID, optionID) } else { - return matrixToPermalinkReturnValue + return sendPollResponsePollStartIDOptionIDReturnValue } } - //MARK: - matrixToEventPermalink + //MARK: - endPoll - var matrixToEventPermalinkUnderlyingCallsCount = 0 - var matrixToEventPermalinkCallsCount: Int { + var endPollPollStartIDUnderlyingCallsCount = 0 + var endPollPollStartIDCallsCount: Int { get { if Thread.isMainThread { - return matrixToEventPermalinkUnderlyingCallsCount + return endPollPollStartIDUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = matrixToEventPermalinkUnderlyingCallsCount + returnValue = endPollPollStartIDUnderlyingCallsCount } return returnValue! @@ -11275,29 +11252,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - matrixToEventPermalinkUnderlyingCallsCount = newValue + endPollPollStartIDUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - matrixToEventPermalinkUnderlyingCallsCount = newValue + endPollPollStartIDUnderlyingCallsCount = newValue } } } } - var matrixToEventPermalinkCalled: Bool { - return matrixToEventPermalinkCallsCount > 0 + var endPollPollStartIDCalled: Bool { + return endPollPollStartIDCallsCount > 0 } - var matrixToEventPermalinkReceivedEventID: String? - var matrixToEventPermalinkReceivedInvocations: [String] = [] + var endPollPollStartIDReceivedPollStartID: String? + var endPollPollStartIDReceivedInvocations: [String] = [] - var matrixToEventPermalinkUnderlyingReturnValue: Result! - var matrixToEventPermalinkReturnValue: Result! { + var endPollPollStartIDUnderlyingReturnValue: Result! + var endPollPollStartIDReturnValue: Result! { get { if Thread.isMainThread { - return matrixToEventPermalinkUnderlyingReturnValue + return endPollPollStartIDUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = matrixToEventPermalinkUnderlyingReturnValue + returnValue = endPollPollStartIDUnderlyingReturnValue } return returnValue! @@ -11305,39 +11282,47 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - matrixToEventPermalinkUnderlyingReturnValue = newValue + endPollPollStartIDUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - matrixToEventPermalinkUnderlyingReturnValue = newValue + endPollPollStartIDUnderlyingReturnValue = newValue } } } } - var matrixToEventPermalinkClosure: ((String) async -> Result)? + var endPollPollStartIDClosure: ((String) async -> Result)? - func matrixToEventPermalink(_ eventID: String) async -> Result { - matrixToEventPermalinkCallsCount += 1 - matrixToEventPermalinkReceivedEventID = eventID + func endPoll(pollStartID: String) async -> Result { + endPollPollStartIDCallsCount += 1 + endPollPollStartIDReceivedPollStartID = pollStartID DispatchQueue.main.async { - self.matrixToEventPermalinkReceivedInvocations.append(eventID) + self.endPollPollStartIDReceivedInvocations.append(pollStartID) } - if let matrixToEventPermalinkClosure = matrixToEventPermalinkClosure { - return await matrixToEventPermalinkClosure(eventID) + if let endPollPollStartIDClosure = endPollPollStartIDClosure { + return await endPollPollStartIDClosure(pollStartID) } else { - return matrixToEventPermalinkReturnValue + return endPollPollStartIDReturnValue } } - //MARK: - saveDraft +} +class QRCodeLoginServiceMock: QRCodeLoginServiceProtocol { + var qrLoginProgressPublisher: AnyPublisher { + get { return underlyingQrLoginProgressPublisher } + set(value) { underlyingQrLoginProgressPublisher = value } + } + var underlyingQrLoginProgressPublisher: AnyPublisher! - var saveDraftUnderlyingCallsCount = 0 - var saveDraftCallsCount: Int { + //MARK: - loginWithQRCode + + var loginWithQRCodeDataUnderlyingCallsCount = 0 + var loginWithQRCodeDataCallsCount: Int { get { if Thread.isMainThread { - return saveDraftUnderlyingCallsCount + return loginWithQRCodeDataUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = saveDraftUnderlyingCallsCount + returnValue = loginWithQRCodeDataUnderlyingCallsCount } return returnValue! @@ -11345,29 +11330,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - saveDraftUnderlyingCallsCount = newValue + loginWithQRCodeDataUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - saveDraftUnderlyingCallsCount = newValue + loginWithQRCodeDataUnderlyingCallsCount = newValue } } } } - var saveDraftCalled: Bool { - return saveDraftCallsCount > 0 + var loginWithQRCodeDataCalled: Bool { + return loginWithQRCodeDataCallsCount > 0 } - var saveDraftReceivedDraft: ComposerDraft? - var saveDraftReceivedInvocations: [ComposerDraft] = [] + var loginWithQRCodeDataReceivedData: Data? + var loginWithQRCodeDataReceivedInvocations: [Data] = [] - var saveDraftUnderlyingReturnValue: Result! - var saveDraftReturnValue: Result! { + var loginWithQRCodeDataUnderlyingReturnValue: Result! + var loginWithQRCodeDataReturnValue: Result! { get { if Thread.isMainThread { - return saveDraftUnderlyingReturnValue + return loginWithQRCodeDataUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = saveDraftUnderlyingReturnValue + returnValue = loginWithQRCodeDataUnderlyingReturnValue } return returnValue! @@ -11375,39 +11360,47 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - saveDraftUnderlyingReturnValue = newValue + loginWithQRCodeDataUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - saveDraftUnderlyingReturnValue = newValue + loginWithQRCodeDataUnderlyingReturnValue = newValue } } } } - var saveDraftClosure: ((ComposerDraft) async -> Result)? + var loginWithQRCodeDataClosure: ((Data) async -> Result)? - func saveDraft(_ draft: ComposerDraft) async -> Result { - saveDraftCallsCount += 1 - saveDraftReceivedDraft = draft + func loginWithQRCode(data: Data) async -> Result { + loginWithQRCodeDataCallsCount += 1 + loginWithQRCodeDataReceivedData = data DispatchQueue.main.async { - self.saveDraftReceivedInvocations.append(draft) + self.loginWithQRCodeDataReceivedInvocations.append(data) } - if let saveDraftClosure = saveDraftClosure { - return await saveDraftClosure(draft) + if let loginWithQRCodeDataClosure = loginWithQRCodeDataClosure { + return await loginWithQRCodeDataClosure(data) } else { - return saveDraftReturnValue + return loginWithQRCodeDataReturnValue } } - //MARK: - loadDraft +} +class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol { + var resultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never> { + get { return underlyingResultsPublisher } + set(value) { underlyingResultsPublisher = value } + } + var underlyingResultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never>! - var loadDraftUnderlyingCallsCount = 0 - var loadDraftCallsCount: Int { + //MARK: - search + + var searchQueryUnderlyingCallsCount = 0 + var searchQueryCallsCount: Int { get { if Thread.isMainThread { - return loadDraftUnderlyingCallsCount + return searchQueryUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadDraftUnderlyingCallsCount + returnValue = searchQueryUnderlyingCallsCount } return returnValue! @@ -11415,27 +11408,29 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - loadDraftUnderlyingCallsCount = newValue + searchQueryUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadDraftUnderlyingCallsCount = newValue + searchQueryUnderlyingCallsCount = newValue } } } } - var loadDraftCalled: Bool { - return loadDraftCallsCount > 0 + var searchQueryCalled: Bool { + return searchQueryCallsCount > 0 } + var searchQueryReceivedQuery: String? + var searchQueryReceivedInvocations: [String?] = [] - var loadDraftUnderlyingReturnValue: Result! - var loadDraftReturnValue: Result! { + var searchQueryUnderlyingReturnValue: Result! + var searchQueryReturnValue: Result! { get { if Thread.isMainThread { - return loadDraftUnderlyingReturnValue + return searchQueryUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = loadDraftUnderlyingReturnValue + returnValue = searchQueryUnderlyingReturnValue } return returnValue! @@ -11443,35 +11438,39 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - loadDraftUnderlyingReturnValue = newValue + searchQueryUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - loadDraftUnderlyingReturnValue = newValue + searchQueryUnderlyingReturnValue = newValue } } } } - var loadDraftClosure: (() async -> Result)? + var searchQueryClosure: ((String?) async -> Result)? - func loadDraft() async -> Result { - loadDraftCallsCount += 1 - if let loadDraftClosure = loadDraftClosure { - return await loadDraftClosure() + func search(query: String?) async -> Result { + searchQueryCallsCount += 1 + searchQueryReceivedQuery = query + DispatchQueue.main.async { + self.searchQueryReceivedInvocations.append(query) + } + if let searchQueryClosure = searchQueryClosure { + return await searchQueryClosure(query) } else { - return loadDraftReturnValue + return searchQueryReturnValue } } - //MARK: - clearDraft + //MARK: - nextPage - var clearDraftUnderlyingCallsCount = 0 - var clearDraftCallsCount: Int { + var nextPageUnderlyingCallsCount = 0 + var nextPageCallsCount: Int { get { if Thread.isMainThread { - return clearDraftUnderlyingCallsCount + return nextPageUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = clearDraftUnderlyingCallsCount + returnValue = nextPageUnderlyingCallsCount } return returnValue! @@ -11479,27 +11478,27 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - clearDraftUnderlyingCallsCount = newValue + nextPageUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - clearDraftUnderlyingCallsCount = newValue + nextPageUnderlyingCallsCount = newValue } } } } - var clearDraftCalled: Bool { - return clearDraftCallsCount > 0 + var nextPageCalled: Bool { + return nextPageCallsCount > 0 } - var clearDraftUnderlyingReturnValue: Result! - var clearDraftReturnValue: Result! { + var nextPageUnderlyingReturnValue: Result! + var nextPageReturnValue: Result! { get { if Thread.isMainThread { - return clearDraftUnderlyingReturnValue + return nextPageUnderlyingReturnValue } else { - var returnValue: Result? = nil + var returnValue: Result? = nil DispatchQueue.main.sync { - returnValue = clearDraftUnderlyingReturnValue + returnValue = nextPageUnderlyingReturnValue } return returnValue! @@ -11507,25 +11506,115 @@ class RoomProxyMock: RoomProxyProtocol { } set { if Thread.isMainThread { - clearDraftUnderlyingReturnValue = newValue + nextPageUnderlyingReturnValue = newValue } else { DispatchQueue.main.sync { - clearDraftUnderlyingReturnValue = newValue + nextPageUnderlyingReturnValue = newValue } } } } - var clearDraftClosure: (() async -> Result)? + var nextPageClosure: (() async -> Result)? - func clearDraft() async -> Result { - clearDraftCallsCount += 1 - if let clearDraftClosure = clearDraftClosure { - return await clearDraftClosure() + func nextPage() async -> Result { + nextPageCallsCount += 1 + if let nextPageClosure = nextPageClosure { + return await nextPageClosure() } else { - return clearDraftReturnValue + return nextPageReturnValue } } } +class RoomMemberProxyMock: RoomMemberProxyProtocol { + var userID: String { + get { return underlyingUserID } + set(value) { underlyingUserID = value } + } + var underlyingUserID: String! + var displayName: String? + var avatarURL: URL? + var membership: MembershipState { + get { return underlyingMembership } + set(value) { underlyingMembership = value } + } + var underlyingMembership: MembershipState! + var isIgnored: Bool { + get { return underlyingIsIgnored } + set(value) { underlyingIsIgnored = value } + } + var underlyingIsIgnored: Bool! + var powerLevel: Int { + get { return underlyingPowerLevel } + set(value) { underlyingPowerLevel = value } + } + var underlyingPowerLevel: Int! + var role: RoomMemberRole { + get { return underlyingRole } + set(value) { underlyingRole = value } + } + var underlyingRole: RoomMemberRole! + +} +class RoomNotificationSettingsProxyMock: RoomNotificationSettingsProxyProtocol { + var mode: RoomNotificationModeProxy { + get { return underlyingMode } + set(value) { underlyingMode = value } + } + var underlyingMode: RoomNotificationModeProxy! + var isDefault: Bool { + get { return underlyingIsDefault } + set(value) { underlyingIsDefault = value } + } + var underlyingIsDefault: Bool! + +} +class RoomProxyMock: RoomProxyProtocol { + var id: String { + get { return underlyingId } + set(value) { underlyingId = value } + } + var underlyingId: String! + var canonicalAlias: String? + var ownUserID: String { + get { return underlyingOwnUserID } + set(value) { underlyingOwnUserID = value } + } + var underlyingOwnUserID: String! + var name: String? + var topic: String? + var avatar: RoomAvatar { + get { return underlyingAvatar } + set(value) { underlyingAvatar = value } + } + var underlyingAvatar: RoomAvatar! + var avatarURL: URL? + var isPublic: Bool { + get { return underlyingIsPublic } + set(value) { underlyingIsPublic = value } + } + var underlyingIsPublic: Bool! + var isDirect: Bool { + get { return underlyingIsDirect } + set(value) { underlyingIsDirect = value } + } + var underlyingIsDirect: Bool! + var isSpace: Bool { + get { return underlyingIsSpace } + set(value) { underlyingIsSpace = value } + } + var underlyingIsSpace: Bool! + var joinedMembersCount: Int { + get { return underlyingJoinedMembersCount } + set(value) { underlyingJoinedMembersCount = value } + } + var underlyingJoinedMembersCount: Int! + var activeMembersCount: Int { + get { return underlyingActiveMembersCount } + set(value) { underlyingActiveMembersCount = value } + } + var underlyingActiveMembersCount: Int! + +} class RoomSummaryProviderMock: RoomSummaryProviderProtocol { var roomListPublisher: CurrentValuePublisher<[RoomSummary], Never> { get { return underlyingRoomListPublisher } @@ -11693,8 +11782,8 @@ class RoomTimelineControllerFactoryMock: RoomTimelineControllerFactoryProtocol { var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryCalled: Bool { return buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryCallsCount > 0 } - var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReceivedArguments: (roomProxy: RoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol)? - var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReceivedInvocations: [(roomProxy: RoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol)] = [] + var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReceivedArguments: (roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol)? + var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReceivedInvocations: [(roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol)] = [] var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryUnderlyingReturnValue: RoomTimelineControllerProtocol! var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReturnValue: RoomTimelineControllerProtocol! { @@ -11720,9 +11809,9 @@ class RoomTimelineControllerFactoryMock: RoomTimelineControllerFactoryProtocol { } } } - var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryClosure: ((RoomProxyProtocol, String?, RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol)? + var buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryClosure: ((JoinedRoomProxyProtocol, String?, RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol)? - func buildRoomTimelineController(roomProxy: RoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol { + func buildRoomTimelineController(roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol { buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryCallsCount += 1 buildRoomTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryReceivedArguments = (roomProxy: roomProxy, initialFocussedEventID: initialFocussedEventID, timelineItemFactory: timelineItemFactory) DispatchQueue.main.async { @@ -11763,8 +11852,8 @@ class RoomTimelineControllerFactoryMock: RoomTimelineControllerFactoryProtocol { var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryCalled: Bool { return buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryCallsCount > 0 } - var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReceivedArguments: (roomProxy: RoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol)? - var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReceivedInvocations: [(roomProxy: RoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol)] = [] + var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReceivedArguments: (roomProxy: JoinedRoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol)? + var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReceivedInvocations: [(roomProxy: JoinedRoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol)] = [] var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryUnderlyingReturnValue: RoomTimelineControllerProtocol? var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReturnValue: RoomTimelineControllerProtocol? { @@ -11790,9 +11879,9 @@ class RoomTimelineControllerFactoryMock: RoomTimelineControllerFactoryProtocol { } } } - var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryClosure: ((RoomProxyProtocol, RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol?)? + var buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryClosure: ((JoinedRoomProxyProtocol, RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol?)? - func buildRoomPinnedTimelineController(roomProxy: RoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol? { + func buildRoomPinnedTimelineController(roomProxy: JoinedRoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol? { buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryCallsCount += 1 buildRoomPinnedTimelineControllerRoomProxyTimelineItemFactoryReceivedArguments = (roomProxy: roomProxy, timelineItemFactory: timelineItemFactory) DispatchQueue.main.async { @@ -15509,8 +15598,8 @@ class VoiceMessageRecorderMock: VoiceMessageRecorderProtocol { var sendVoiceMessageInRoomAudioConverterCalled: Bool { return sendVoiceMessageInRoomAudioConverterCallsCount > 0 } - var sendVoiceMessageInRoomAudioConverterReceivedArguments: (roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol)? - var sendVoiceMessageInRoomAudioConverterReceivedInvocations: [(roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol)] = [] + var sendVoiceMessageInRoomAudioConverterReceivedArguments: (roomProxy: JoinedRoomProxyProtocol, audioConverter: AudioConverterProtocol)? + var sendVoiceMessageInRoomAudioConverterReceivedInvocations: [(roomProxy: JoinedRoomProxyProtocol, audioConverter: AudioConverterProtocol)] = [] var sendVoiceMessageInRoomAudioConverterUnderlyingReturnValue: Result! var sendVoiceMessageInRoomAudioConverterReturnValue: Result! { @@ -15536,9 +15625,9 @@ class VoiceMessageRecorderMock: VoiceMessageRecorderProtocol { } } } - var sendVoiceMessageInRoomAudioConverterClosure: ((RoomProxyProtocol, AudioConverterProtocol) async -> Result)? + var sendVoiceMessageInRoomAudioConverterClosure: ((JoinedRoomProxyProtocol, AudioConverterProtocol) async -> Result)? - func sendVoiceMessage(inRoom roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result { + func sendVoiceMessage(inRoom roomProxy: JoinedRoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result { sendVoiceMessageInRoomAudioConverterCallsCount += 1 sendVoiceMessageInRoomAudioConverterReceivedArguments = (roomProxy: roomProxy, audioConverter: audioConverter) DispatchQueue.main.async { diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 16157ee58c..4776de6d31 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -9863,6 +9863,82 @@ open class NotificationSettingsSDKMock: MatrixRustSDK.NotificationSettings { try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne) } } +open class OidcAuthorizationDataSDKMock: MatrixRustSDK.OidcAuthorizationData { + init() { + super.init(noPointer: .init()) + } + + public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + fatalError("init(unsafeFromRawPointer:) has not been implemented") + } + + fileprivate var pointer: UnsafeMutableRawPointer! + + //MARK: - loginUrl + + var loginUrlUnderlyingCallsCount = 0 + open var loginUrlCallsCount: Int { + get { + if Thread.isMainThread { + return loginUrlUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = loginUrlUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + loginUrlUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + loginUrlUnderlyingCallsCount = newValue + } + } + } + } + open var loginUrlCalled: Bool { + return loginUrlCallsCount > 0 + } + + var loginUrlUnderlyingReturnValue: String! + open var loginUrlReturnValue: String! { + get { + if Thread.isMainThread { + return loginUrlUnderlyingReturnValue + } else { + var returnValue: String? = nil + DispatchQueue.main.sync { + returnValue = loginUrlUnderlyingReturnValue + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + loginUrlUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + loginUrlUnderlyingReturnValue = newValue + } + } + } + } + open var loginUrlClosure: (() -> String)? + + open override func loginUrl() -> String { + loginUrlCallsCount += 1 + if let loginUrlClosure = loginUrlClosure { + return loginUrlClosure() + } else { + return loginUrlReturnValue + } + } +} open class QrCodeDataSDKMock: MatrixRustSDK.QrCodeData { init() { super.init(noPointer: .init()) diff --git a/ElementX/Sources/Mocks/RoomProxyMock.swift b/ElementX/Sources/Mocks/JoinedRoomProxyMock.swift similarity index 96% rename from ElementX/Sources/Mocks/RoomProxyMock.swift rename to ElementX/Sources/Mocks/JoinedRoomProxyMock.swift index 21725d80af..9f52b90c4d 100644 --- a/ElementX/Sources/Mocks/RoomProxyMock.swift +++ b/ElementX/Sources/Mocks/JoinedRoomProxyMock.swift @@ -17,8 +17,12 @@ import Combine import Foundation +enum RoomProxyMockError: Error { + case generic +} + @MainActor -struct RoomProxyMockConfiguration { +struct JoinedRoomProxyMockConfiguration { var id = UUID().uuidString var name: String? var topic: String? @@ -45,13 +49,9 @@ struct RoomProxyMockConfiguration { var shouldUseAutoUpdatingTimeline = false } -enum RoomProxyMockError: Error { - case generic -} - -extension RoomProxyMock { +extension JoinedRoomProxyMock { @MainActor - convenience init(_ configuration: RoomProxyMockConfiguration) { + convenience init(_ configuration: JoinedRoomProxyMockConfiguration) { self.init() id = configuration.id @@ -86,8 +86,6 @@ extension RoomProxyMock { self.timeline = timeline ownUserID = configuration.ownUserID - membership = .joined - inviterClosure = { configuration.inviter } membersPublisher = CurrentValueSubject(configuration.members).asCurrentValuePublisher() typingMembersPublisher = CurrentValueSubject([]).asCurrentValuePublisher() @@ -96,7 +94,6 @@ extension RoomProxyMock { activeMembersCount = configuration.members.filter { $0.membership == .join || $0.membership == .invite }.count updateMembersClosure = { } - acceptInvitationClosure = { .success(()) } underlyingActionsPublisher = Empty(completeImmediately: false).eraseToAnyPublisher() setNameClosure = { _ in .success(()) } setTopicClosure = { _ in .success(()) } diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index 7803a1f6f3..026ace55fe 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -208,7 +208,7 @@ struct CallScreen_Previews: PreviewProvider { clientProxy.getElementWellKnownReturnValue = .success(nil) clientProxy.deviceID = "call-device-id" - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() roomProxy.sendCallNotificationIfNeededReturnValue = .success(()) let widgetDriver = ElementCallWidgetDriverMock() diff --git a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift index 57020416f5..16bedbfd84 100644 --- a/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift +++ b/ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift @@ -142,9 +142,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol case .showRoomDetails(roomIdentifier: let roomIdentifier): actionsSubject.send(.presentRoomDetails(roomIdentifier: roomIdentifier)) case .leaveRoom(roomIdentifier: let roomIdentifier): - startLeaveRoomProcess(roomId: roomIdentifier) + startLeaveRoomProcess(roomID: roomIdentifier) case .confirmLeaveRoom(roomIdentifier: let roomIdentifier): - leaveRoom(roomId: roomIdentifier) + Task { await leaveRoom(roomID: roomIdentifier) } case .showSettings: actionsSubject.send(.presentSettingsScreen) case .confirmRecoveryKey: @@ -159,7 +159,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol actionsSubject.send(.presentGlobalSearch) case .markRoomAsUnread(let roomIdentifier): Task { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else { MXLog.error("Failed retrieving room for identifier: \(roomIdentifier)") return } @@ -173,7 +173,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol } case .markRoomAsRead(let roomIdentifier): Task { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else { MXLog.error("Failed retrieving room for identifier: \(roomIdentifier)") return } @@ -367,7 +367,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol } private func markRoomAsFavourite(_ roomID: String, isFavourite: Bool) async { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { MXLog.error("Failed retrieving room for identifier: \(roomID)") return } @@ -382,53 +382,47 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol private static let leaveRoomLoadingID = "LeaveRoomLoading" - private func startLeaveRoomProcess(roomId: String) { + private func startLeaveRoomProcess(roomID: String) { Task { defer { userIndicatorController.retractIndicatorWithId(Self.leaveRoomLoadingID) } userIndicatorController.submitIndicator(UserIndicator(id: Self.leaveRoomLoadingID, type: .modal, title: L10n.commonLoading, persistent: true)) - let room = await userSession.clientProxy.roomForIdentifier(roomId) - - guard let room else { + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown) return } - if room.isPublic { - state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomID: roomId, isDM: room.isEncryptedOneToOneRoom, state: .public) + if roomProxy.isPublic { + state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .public) } else { - state.bindings.leaveRoomAlertItem = if room.joinedMembersCount > 1 { - LeaveRoomAlertItem(roomID: roomId, isDM: room.isEncryptedOneToOneRoom, state: .private) + state.bindings.leaveRoomAlertItem = if roomProxy.joinedMembersCount > 1 { + LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .private) } else { - LeaveRoomAlertItem(roomID: roomId, isDM: room.isEncryptedOneToOneRoom, state: .empty) + LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .empty) } } } } - private func leaveRoom(roomId: String) { - Task { - defer { - userIndicatorController.retractIndicatorWithId(Self.leaveRoomLoadingID) - } - userIndicatorController.submitIndicator(UserIndicator(id: Self.leaveRoomLoadingID, type: .modal, title: L10n.commonLeavingRoom, persistent: true)) - - let room = await userSession.clientProxy.roomForIdentifier(roomId) - let result = await room?.leaveRoom() - - switch result { - case .none, .some(.failure): - state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown) - case .some(.success): - userIndicatorController.submitIndicator(UserIndicator(id: UUID().uuidString, - type: .toast, - title: L10n.commonCurrentUserLeftRoom, - iconName: "checkmark")) - actionsSubject.send(.roomLeft(roomIdentifier: roomId)) - } + private func leaveRoom(roomID: String) async { + defer { + userIndicatorController.retractIndicatorWithId(Self.leaveRoomLoadingID) } + userIndicatorController.submitIndicator(UserIndicator(id: Self.leaveRoomLoadingID, type: .modal, title: L10n.commonLeavingRoom, persistent: true)) + + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID), + case .success = await roomProxy.leaveRoom() else { + state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown) + return + } + + userIndicatorController.submitIndicator(UserIndicator(id: UUID().uuidString, + type: .toast, + title: L10n.commonCurrentUserLeftRoom, + iconName: "checkmark")) + actionsSubject.send(.roomLeft(roomIdentifier: roomID)) } // MARK: Invites @@ -440,7 +434,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol userIndicatorController.submitIndicator(UserIndicator(id: roomID, type: .modal, title: L10n.commonLoading, persistent: true)) - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .invited(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { displayError() return } @@ -478,7 +472,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol userIndicatorController.submitIndicator(UserIndicator(id: roomID, type: .modal, title: L10n.commonLoading, persistent: true)) - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomID) else { + guard case let .invited(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else { displayError() return } diff --git a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenModels.swift b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenModels.swift index e52957bb68..5137168637 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenModels.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenModels.swift @@ -31,7 +31,7 @@ enum InviteUsersScreenViewModelAction { enum InviteUsersScreenRoomType { case draft - case room(roomProxy: RoomProxyProtocol) + case room(roomProxy: JoinedRoomProxyProtocol) } struct InviteUsersScreenViewState: BindableState { diff --git a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift index c9ec219168..f77afacae4 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/JoinRoomScreenViewModel.swift @@ -27,7 +27,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo private let userIndicatorController: UserIndicatorControllerProtocol private var roomPreviewDetails: RoomPreviewDetails? - private var roomProxy: RoomProxyProtocol? + private var room: RoomProxyType? private let actionsSubject: PassthroughSubject = .init() var actionsPublisher: AnyPublisher { @@ -89,8 +89,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo // See if we known about the room locally and, if so, have that // take priority over the preview one. - if let roomProxy = await clientProxy.roomForIdentifier(roomID) { - self.roomProxy = roomProxy + if let room = await clientProxy.roomForIdentifier(roomID) { + self.room = room await updateRoomDetails() } @@ -106,8 +106,20 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo } private func updateRoomDetails() async { + var roomProxy: RoomProxyProtocol? + var inviter: RoomInviterDetails? + + switch room { + case .joined(let joinedRoomProxy): + roomProxy = joinedRoomProxy + case .invited(let invitedRoomProxy): + inviter = await invitedRoomProxy.inviter.flatMap(RoomInviterDetails.init) + roomProxy = invitedRoomProxy + default: + break + } + let name = roomProxy?.name ?? roomPreviewDetails?.name - let inviter = await roomProxy?.inviter.flatMap(RoomInviterDetails.init) state.roomDetails = JoinRoomScreenRoomDetails(name: name, topic: roomProxy?.topic ?? roomPreviewDetails?.topic, canonicalAlias: roomProxy?.canonicalAlias ?? roomPreviewDetails?.canonicalAlias, @@ -119,9 +131,18 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo } private func updateMode() { - if roomProxy?.membership == .invited || roomPreviewDetails?.isInvited ?? false { // Check invites first to show Accept/Decline buttons on public rooms. + // Check invites first to show Accept/Decline buttons on public rooms. + if case .invited = room { state.mode = .invited - } else if roomProxy?.isPublic ?? false || roomPreviewDetails?.isPublic ?? false { + return + } + + if roomPreviewDetails?.isInvited ?? false { + state.mode = .invited + return + } + + if roomPreviewDetails?.isPublic ?? false { state.mode = .join } else if roomPreviewDetails?.canKnock ?? false, allowKnocking { // Knocking is not supported yet, the flag is purely for preview tests. state.mode = .knock @@ -180,7 +201,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo userIndicatorController.submitIndicator(UserIndicator(id: roomID, type: .modal, title: L10n.commonLoading, persistent: true)) - guard let roomProxy = await clientProxy.roomForIdentifier(roomID) else { + guard case let .invited(roomProxy) = room else { userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown)) return } diff --git a/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenCoordinator.swift b/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenCoordinator.swift index 253ec3f215..c9dcdc80a2 100644 --- a/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenCoordinator.swift +++ b/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenCoordinator.swift @@ -19,7 +19,7 @@ import SwiftUI struct MediaUploadPreviewScreenCoordinatorParameters { let userIndicatorController: UserIndicatorControllerProtocol - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let mediaUploadingPreprocessor: MediaUploadingPreprocessor let title: String? let url: URL diff --git a/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenViewModel.swift b/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenViewModel.swift index a97369676c..c9b2196c77 100644 --- a/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenViewModel.swift +++ b/ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenViewModel.swift @@ -22,7 +22,7 @@ typealias MediaUploadPreviewScreenViewModelType = StateStoreViewModel = .init() @@ -30,7 +30,7 @@ class ReportContentScreenViewModel: ReportContentScreenViewModelType, ReportCont actionsSubject.eraseToAnyPublisher() } - init(eventID: String, senderID: String, roomProxy: RoomProxyProtocol, clientProxy: ClientProxyProtocol) { + init(eventID: String, senderID: String, roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol) { self.eventID = eventID self.senderID = senderID self.roomProxy = roomProxy diff --git a/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift b/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift index 9d582b67a3..52367b93bc 100644 --- a/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift +++ b/ElementX/Sources/Screens/ReportContentScreen/View/ReportContentScreen.swift @@ -77,7 +77,7 @@ struct ReportContentScreen: View { struct ReportContentScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = ReportContentScreenViewModel(eventID: "", senderID: "", - roomProxy: RoomProxyMock(.init()), + roomProxy: JoinedRoomProxyMock(.init()), clientProxy: ClientProxyMock(.init())) static var previews: some View { diff --git a/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenCoordinator.swift index 2ceb155307..9c60e3b768 100644 --- a/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenCoordinator.swift @@ -20,7 +20,7 @@ import SwiftUI struct RoomChangePermissionsScreenCoordinatorParameters { let permissions: RoomPermissions let permissionsGroup: RoomRolesAndPermissionsScreenPermissionsGroup - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol let analytics: AnalyticsService } diff --git a/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenViewModel.swift b/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenViewModel.swift index b377cf922f..daa54c9357 100644 --- a/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomChangePermissionsScreen/RoomChangePermissionsScreenViewModel.swift @@ -21,7 +21,7 @@ import SwiftUI typealias RoomChangePermissionsScreenViewModelType = StateStoreViewModel class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModelType, RoomChangePermissionsScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let analytics: AnalyticsService @@ -32,7 +32,7 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel init(currentPermissions: RoomPermissions, group: RoomRolesAndPermissionsScreenPermissionsGroup, - roomProxy: RoomProxyProtocol, + roomProxy: JoinedRoomProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, analytics: AnalyticsService) { self.roomProxy = roomProxy diff --git a/ElementX/Sources/Screens/RoomChangePermissionsScreen/View/RoomChangePermissionsScreen.swift b/ElementX/Sources/Screens/RoomChangePermissionsScreen/View/RoomChangePermissionsScreen.swift index b89e2fa85c..12aa80b393 100644 --- a/ElementX/Sources/Screens/RoomChangePermissionsScreen/View/RoomChangePermissionsScreen.swift +++ b/ElementX/Sources/Screens/RoomChangePermissionsScreen/View/RoomChangePermissionsScreen.swift @@ -86,7 +86,7 @@ struct RoomChangePermissionsScreen_Previews: PreviewProvider, TestablePreview { static func makeViewModel(group: RoomRolesAndPermissionsScreenPermissionsGroup) -> RoomChangePermissionsScreenViewModel { RoomChangePermissionsScreenViewModel(currentPermissions: .init(powerLevels: .mock), group: group, - roomProxy: RoomProxyMock(.init()), + roomProxy: JoinedRoomProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock(), analytics: ServiceLocator.shared.analytics) } diff --git a/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenCoordinator.swift b/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenCoordinator.swift index 854fd66399..cb1c573df4 100644 --- a/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenCoordinator.swift @@ -19,7 +19,7 @@ import SwiftUI struct RoomChangeRolesScreenCoordinatorParameters { let mode: RoomMemberDetails.Role - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let mediaProvider: MediaProviderProtocol let userIndicatorController: UserIndicatorControllerProtocol let analytics: AnalyticsService diff --git a/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenViewModel.swift b/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenViewModel.swift index 016c235c1a..a1e3d7b1e2 100644 --- a/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomChangeRolesScreen/RoomChangeRolesScreenViewModel.swift @@ -20,7 +20,7 @@ import SwiftUI typealias RoomChangeRolesScreenViewModelType = StateStoreViewModel class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomChangeRolesScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let analytics: AnalyticsService @@ -30,7 +30,7 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh } init(mode: RoomMemberDetails.Role, - roomProxy: RoomProxyProtocol, + roomProxy: JoinedRoomProxyProtocol, mediaProvider: MediaProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol, analytics: AnalyticsService) { diff --git a/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift b/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift index 11bee0f65a..9cbe4c2853 100644 --- a/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift +++ b/ElementX/Sources/Screens/RoomChangeRolesScreen/View/RoomChangeRolesScreen.swift @@ -130,7 +130,7 @@ struct RoomChangeRolesScreen_Previews: PreviewProvider, TestablePreview { static func makeViewModel(mode: RoomMemberDetails.Role) -> RoomChangeRolesScreenViewModel { RoomChangeRolesScreenViewModel(mode: mode, - roomProxy: RoomProxyMock(.init(members: .allMembersAsAdmin)), + roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)), mediaProvider: MockMediaProvider(), userIndicatorController: UserIndicatorControllerMock(), analytics: ServiceLocator.shared.analytics) diff --git a/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenCoordinator.swift b/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenCoordinator.swift index 11d9a74e35..0d5d9bf30c 100644 --- a/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenCoordinator.swift @@ -18,7 +18,7 @@ import Combine import SwiftUI struct RoomDetailsEditScreenCoordinatorParameters { - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let mediaProvider: MediaProviderProtocol weak var navigationStackCoordinator: NavigationStackCoordinator? let userIndicatorController: UserIndicatorControllerProtocol diff --git a/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenViewModel.swift index 7e65f13bb3..8d2db01d41 100644 --- a/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsEditScreen/RoomDetailsEditScreenViewModel.swift @@ -21,7 +21,7 @@ typealias RoomDetailsEditScreenViewModelType = StateStoreViewModel = .init() - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let mediaPreprocessor: MediaUploadingPreprocessor = .init() @@ -29,7 +29,7 @@ class RoomDetailsEditScreenViewModel: RoomDetailsEditScreenViewModelType, RoomDe actionsSubject.eraseToAnyPublisher() } - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, mediaProvider: MediaProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol) { self.roomProxy = roomProxy diff --git a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift index 67e14224c3..0ffe6aa74a 100644 --- a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift @@ -157,9 +157,9 @@ struct RoomDetailsEditScreen: View { struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview { static let editableViewModel = { - let roomProxy = RoomProxyMock(.init(id: "test_id", - name: "Room", - members: [.mockMeAdmin])) + let roomProxy = JoinedRoomProxyMock(.init(id: "test_id", + name: "Room", + members: [.mockMeAdmin])) return RoomDetailsEditScreenViewModel(roomProxy: roomProxy, mediaProvider: MockMediaProvider(), @@ -167,9 +167,9 @@ struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview { }() static let readOnlyViewModel = { - let roomProxy = RoomProxyMock(.init(id: "test_id", - name: "Room", - members: [.mockAlice])) + let roomProxy = JoinedRoomProxyMock(.init(id: "test_id", + name: "Room", + members: [.mockAlice])) return RoomDetailsEditScreenViewModel(roomProxy: roomProxy, mediaProvider: MockMediaProvider(), diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift index 5a430f3e60..70fa84fc4c 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenCoordinator.swift @@ -18,7 +18,7 @@ import Combine import SwiftUI struct RoomDetailsScreenCoordinatorParameters { - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let clientProxy: ClientProxyProtocol let mediaProvider: MediaProviderProtocol let analyticsService: AnalyticsService diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift index edb9fb96ec..7af502d71b 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift @@ -20,7 +20,7 @@ import SwiftUI typealias RoomDetailsScreenViewModelType = StateStoreViewModel class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let clientProxy: ClientProxyProtocol private let analyticsService: AnalyticsService private let mediaProvider: MediaProviderProtocol @@ -54,7 +54,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr actionsSubject.eraseToAnyPublisher() } - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol, mediaProvider: MediaProviderProtocol, analyticsService: AnalyticsService, diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift index 838a6a504d..3f516e6d57 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift @@ -311,20 +311,20 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { .mockBob, .mockCharlie ] - let roomProxy = RoomProxyMock(.init(id: "room_a_id", - name: "Room A", - topic: """ - Discussions about Element X iOS | https://github.com/vector-im/element-x-ios - - Feature Status: https://github.com/vector-im/element-x-ios/issues/1225 - - App Store: https://apple.co/3r6LJHZ - TestFlight: https://testflight.apple.com/join/uZbeZCOi - """, - isDirect: false, - isEncrypted: true, - canonicalAlias: "#alias:domain.com", - members: members)) + let roomProxy = JoinedRoomProxyMock(.init(id: "room_a_id", + name: "Room A", + topic: """ + Discussions about Element X iOS | https://github.com/vector-im/element-x-ios + + Feature Status: https://github.com/vector-im/element-x-ios/issues/1225 + + App Store: https://apple.co/3r6LJHZ + TestFlight: https://testflight.apple.com/join/uZbeZCOi + """, + isDirect: false, + isEncrypted: true, + canonicalAlias: "#alias:domain.com", + members: members)) var notificationSettingsProxyMockConfiguration = NotificationSettingsProxyMockConfiguration() notificationSettingsProxyMockConfiguration.roomMode.isDefault = false @@ -349,13 +349,13 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { .mockDan ] - let roomProxy = RoomProxyMock(.init(id: "dm_room_id", - name: "DM Room", - topic: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - isDirect: true, - isEncrypted: true, - canonicalAlias: "#alias:domain.com", - members: members)) + let roomProxy = JoinedRoomProxyMock(.init(id: "dm_room_id", + name: "DM Room", + topic: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + isDirect: true, + isEncrypted: true, + canonicalAlias: "#alias:domain.com", + members: members)) let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) let appSettings = AppSettings() appSettings.pinningEnabled = true @@ -378,11 +378,11 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { .mockBob, .mockCharlie ] - let roomProxy = RoomProxyMock(.init(id: "simple_room_id", - name: "Room A", - isDirect: false, - isEncrypted: false, - members: members)) + let roomProxy = JoinedRoomProxyMock(.init(id: "simple_room_id", + name: "Room A", + isDirect: false, + isEncrypted: false, + members: members)) let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) let appSettings = AppSettings() appSettings.pinningEnabled = true diff --git a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenCoordinator.swift index d5c3d5abf0..a095d6f6cd 100644 --- a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenCoordinator.swift @@ -19,7 +19,7 @@ import SwiftUI struct RoomMemberDetailsScreenCoordinatorParameters { let userID: String - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let clientProxy: ClientProxyProtocol let mediaProvider: MediaProviderProtocol let userIndicatorController: UserIndicatorControllerProtocol diff --git a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift index 07a2a64418..1d5193e374 100644 --- a/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomMemberDetailsScreen/RoomMemberDetailsScreenViewModel.swift @@ -20,7 +20,7 @@ import SwiftUI typealias RoomMemberDetailsScreenViewModelType = StateStoreViewModel class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, RoomMemberDetailsScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let clientProxy: ClientProxyProtocol private let mediaProvider: MediaProviderProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -35,7 +35,7 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro } init(userID: String, - roomProxy: RoomProxyProtocol, + roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol, mediaProvider: MediaProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol, diff --git a/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift b/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift index e69e29a873..8c823e2fd2 100644 --- a/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift @@ -143,7 +143,7 @@ struct RoomMemberDetailsScreen_Previews: PreviewProvider, TestablePreview { } static func makeViewModel(member: RoomMemberProxyMock) -> RoomMemberDetailsScreenViewModel { - let roomProxyMock = RoomProxyMock(.init(name: "")) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "")) roomProxyMock.getMemberUserIDReturnValue = .success(member) let clientProxyMock = ClientProxyMock(.init()) diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenCoordinator.swift b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenCoordinator.swift index 44fbeaf5c1..2a0ccffbe2 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenCoordinator.swift @@ -19,7 +19,7 @@ import SwiftUI struct RoomMembersListScreenCoordinatorParameters { let mediaProvider: MediaProviderProtocol - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol let analytics: AnalyticsService } diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift index ab5f3eb2ad..d3717b05be 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift @@ -20,7 +20,7 @@ import SwiftUI typealias RoomMembersListScreenViewModelType = StateStoreViewModel class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMembersListScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let analytics: AnalyticsService @@ -33,7 +33,7 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe } init(initialMode: RoomMembersListScreenMode = .members, - roomProxy: RoomProxyProtocol, + roomProxy: JoinedRoomProxyProtocol, mediaProvider: MediaProviderProtocol, userIndicatorController: UserIndicatorControllerProtocol, analytics: AnalyticsService) { diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListManageMemberSheet.swift b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListManageMemberSheet.swift index f1bd9b04d6..f5b0609ada 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListManageMemberSheet.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListManageMemberSheet.swift @@ -108,7 +108,7 @@ struct RoomMembersListManageMemberSheetLive_Previews: PreviewProvider { private extension RoomMembersListScreenViewModel { static var mock: RoomMembersListScreenViewModel { RoomMembersListScreenViewModel(initialMode: .members, - roomProxy: RoomProxyMock(.init(members: .allMembersAsAdmin)), + roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)), mediaProvider: MockMediaProvider(), userIndicatorController: ServiceLocator.shared.userIndicatorController, analytics: ServiceLocator.shared.analytics) diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreen.swift b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreen.swift index ee2ca9c2a9..382bd89f38 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreen.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreen.swift @@ -179,10 +179,10 @@ struct RoomMembersListScreen_Previews: PreviewProvider, TestablePreview { } return RoomMembersListScreenViewModel(initialMode: initialMode, - roomProxy: RoomProxyMock(.init(name: "Some room", - members: members, - ownUserID: ownUserID, - canUserInvite: false)), + roomProxy: JoinedRoomProxyMock(.init(name: "Some room", + members: members, + ownUserID: ownUserID, + canUserInvite: false)), mediaProvider: MockMediaProvider(), userIndicatorController: ServiceLocator.shared.userIndicatorController, analytics: ServiceLocator.shared.analytics) diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift index 98add929c2..7623366c0d 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift @@ -106,8 +106,8 @@ struct RoomMembersListMemberCell_Previews: PreviewProvider, TestablePreview { .init(with: .init(userID: "@badavatar:matrix.org", avatarURL: .picturesDirectory, membership: .ban)) ] - static let viewModel = RoomMembersListScreenViewModel(roomProxy: RoomProxyMock(.init(name: "Some room", - members: members)), + static let viewModel = RoomMembersListScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Some room", + members: members)), mediaProvider: MockMediaProvider(), userIndicatorController: ServiceLocator.shared.userIndicatorController, analytics: ServiceLocator.shared.analytics) diff --git a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenCoordinator.swift index c0b2330eeb..293c47c332 100644 --- a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenCoordinator.swift @@ -20,7 +20,7 @@ import SwiftUI struct RoomNotificationSettingsScreenCoordinatorParameters { weak var navigationStackCoordinator: NavigationStackCoordinator? let notificationSettingsProxy: NotificationSettingsProxyProtocol - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let displayAsUserDefinedRoomSettings: Bool } diff --git a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenViewModel.swift b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenViewModel.swift index e3fe9b2ca5..e7e146ae5d 100644 --- a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/RoomNotificationSettingsScreenViewModel.swift @@ -22,7 +22,7 @@ typealias RoomNotificationSettingsScreenViewModelType = StateStoreViewModel = .init() private let notificationSettingsProxy: NotificationSettingsProxyProtocol - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol // periphery:ignore - cancellable tasks cancel when reassigned @CancellableTask private var fetchNotificationSettingsTask: Task? @@ -31,7 +31,7 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie actionsSubject.eraseToAnyPublisher() } - init(notificationSettingsProxy: NotificationSettingsProxyProtocol, roomProxy: RoomProxyProtocol, displayAsUserDefinedRoomSettings: Bool) { + init(notificationSettingsProxy: NotificationSettingsProxyProtocol, roomProxy: JoinedRoomProxyProtocol, displayAsUserDefinedRoomSettings: Bool) { let bindings = RoomNotificationSettingsScreenViewStateBindings() self.notificationSettingsProxy = notificationSettingsProxy self.roomProxy = roomProxy diff --git a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsCustomSectionView.swift b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsCustomSectionView.swift index eb70d56af1..d8a038e34e 100644 --- a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsCustomSectionView.swift +++ b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsCustomSectionView.swift @@ -42,7 +42,7 @@ struct RoomNotificationSettingsCustomSectionView_Previews: PreviewProvider, Test static let viewModel = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .allMessages, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: true)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: true)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, @@ -52,7 +52,7 @@ struct RoomNotificationSettingsCustomSectionView_Previews: PreviewProvider, Test static let viewModelUnencrypted = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .allMessages, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: false)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: false)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, diff --git a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsScreen.swift b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsScreen.swift index e9c7bdbf64..75540c2582 100644 --- a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsScreen.swift +++ b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsScreen.swift @@ -83,7 +83,7 @@ struct RoomNotificationSettingsScreen_Previews: PreviewProvider, TestablePreview static let viewModel = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .mentionsAndKeywordsOnly, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: true)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: true)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, @@ -93,7 +93,7 @@ struct RoomNotificationSettingsScreen_Previews: PreviewProvider, TestablePreview static let viewModelCustom = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .allMessages, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: true)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: true)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, diff --git a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsUserDefinedScreen.swift b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsUserDefinedScreen.swift index 932273f916..04fe9f5f95 100644 --- a/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsUserDefinedScreen.swift +++ b/ElementX/Sources/Screens/RoomNotificationSettingsScreen/View/RoomNotificationSettingsUserDefinedScreen.swift @@ -52,7 +52,7 @@ struct RoomNotificationSettingsUserDefinedScreen_Previews: PreviewProvider, Test static let viewModel = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .mentionsAndKeywordsOnly, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: true)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: true)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, @@ -62,7 +62,7 @@ struct RoomNotificationSettingsUserDefinedScreen_Previews: PreviewProvider, Test static let viewModelUnencrypted = { let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init(defaultRoomMode: .mentionsAndKeywordsOnly, roomMode: .mentionsAndKeywordsOnly)) - let roomProxy = RoomProxyMock(.init(name: "Room", isEncrypted: false)) + let roomProxy = JoinedRoomProxyMock(.init(name: "Room", isEncrypted: false)) return RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxy, roomProxy: roomProxy, diff --git a/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift b/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift index 1b8d20313d..d92e55723e 100644 --- a/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift +++ b/ElementX/Sources/Screens/RoomPollsHistoryScreen/View/RoomPollsHistoryScreen.swift @@ -124,7 +124,7 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview { static let viewModelEmpty: RoomPollsHistoryScreenViewModel = { let roomTimelineController = MockRoomTimelineController() roomTimelineController.timelineItems = [] - let roomProxyMockConfiguration = RoomProxyMockConfiguration(name: "Polls") + let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls") let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), roomTimelineController: roomTimelineController, userIndicatorController: UserIndicatorControllerMock()) @@ -146,7 +146,7 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview { roomTimelineController.timelineItemsTimestamp[item.id] = date } - let roomProxyMockConfiguration = RoomProxyMockConfiguration(name: "Polls", timelineStartReached: true) + let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls", timelineStartReached: true) let viewModel = RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(), roomTimelineController: roomTimelineController, userIndicatorController: UserIndicatorControllerMock()) diff --git a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenCoordinator.swift b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenCoordinator.swift index c805b6df47..4590f8dc17 100644 --- a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenCoordinator.swift @@ -18,7 +18,7 @@ import Combine import SwiftUI struct RoomRolesAndPermissionsScreenCoordinatorParameters { - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol let userIndicatorController: UserIndicatorControllerProtocol let analytics: AnalyticsService } diff --git a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenViewModel.swift b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenViewModel.swift index 2bd720f285..13adc9fab3 100644 --- a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/RoomRolesAndPermissionsScreenViewModel.swift @@ -20,7 +20,7 @@ import SwiftUI typealias RoomRolesAndPermissionsScreenViewModelType = StateStoreViewModel class RoomRolesAndPermissionsScreenViewModel: RoomRolesAndPermissionsScreenViewModelType, RoomRolesAndPermissionsScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let userIndicatorController: UserIndicatorControllerProtocol private let analytics: AnalyticsService @@ -29,7 +29,7 @@ class RoomRolesAndPermissionsScreenViewModel: RoomRolesAndPermissionsScreenViewM actionsSubject.eraseToAnyPublisher() } - init(initialPermissions: RoomPermissions? = nil, roomProxy: RoomProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, analytics: AnalyticsService) { + init(initialPermissions: RoomPermissions? = nil, roomProxy: JoinedRoomProxyProtocol, userIndicatorController: UserIndicatorControllerProtocol, analytics: AnalyticsService) { self.roomProxy = roomProxy self.userIndicatorController = userIndicatorController self.analytics = analytics diff --git a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/View/RoomRolesAndPermissionsScreen.swift b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/View/RoomRolesAndPermissionsScreen.swift index cb3aef8276..3fe508c286 100644 --- a/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/View/RoomRolesAndPermissionsScreen.swift +++ b/ElementX/Sources/Screens/RoomRolesAndPermissionsScreen/View/RoomRolesAndPermissionsScreen.swift @@ -127,7 +127,7 @@ struct RoomRolesAndPermissionsScreen: View { struct RoomRolesAndPermissionsScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = RoomRolesAndPermissionsScreenViewModel(initialPermissions: RoomPermissions(powerLevels: .mock), - roomProxy: RoomProxyMock(.init(members: .allMembersAsAdmin)), + roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)), userIndicatorController: UserIndicatorControllerMock(), analytics: ServiceLocator.shared.analytics) static var previews: some View { diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift index 7ffae706c7..6a48db0b77 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/CompletionSuggestionService.swift @@ -22,13 +22,13 @@ private enum SuggestionTriggerPattern: Character { } final class CompletionSuggestionService: CompletionSuggestionServiceProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private var canMentionAllUsers = false private(set) var suggestionsPublisher: AnyPublisher<[SuggestionItem], Never> = Empty().eraseToAnyPublisher() private let suggestionTriggerSubject = CurrentValueSubject(nil) - init(roomProxy: RoomProxyProtocol) { + init(roomProxy: JoinedRoomProxyProtocol) { self.roomProxy = roomProxy suggestionsPublisher = suggestionTriggerSubject diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift index 98b0fb5030..cea9b0c85e 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenCoordinator.swift @@ -20,7 +20,7 @@ import SwiftUI import WysiwygComposer struct RoomScreenCoordinatorParameters { - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol var focussedEventID: String? let timelineController: RoomTimelineControllerProtocol let mediaProvider: MediaProviderProtocol diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index a2fead44e9..b950056558 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -22,7 +22,7 @@ import SwiftUI typealias RoomScreenViewModelType = StateStoreViewModel class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let appMediator: AppMediatorProtocol private let appSettings: AppSettings private let analyticsService: AnalyticsService @@ -51,7 +51,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol } } - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, mediaProvider: MediaProviderProtocol, appMediator: AppMediatorProtocol, appSettings: AppSettings, @@ -183,7 +183,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol } extension RoomScreenViewModel { - static func mock(roomProxyMock: RoomProxyMock) -> RoomScreenViewModel { + static func mock(roomProxyMock: JoinedRoomProxyMock) -> RoomScreenViewModel { RoomScreenViewModel(roomProxy: roomProxyMock, mediaProvider: MockMediaProvider(), appMediator: AppMediatorMock.default, diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index 21ba529013..9f2dae5151 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -210,9 +210,9 @@ struct RoomScreen: View { // MARK: - Previews struct RoomScreen_Previews: PreviewProvider, TestablePreview { - static let roomProxyMock = RoomProxyMock(.init(id: "stable_id", - name: "Preview room", - hasOngoingCall: true)) + static let roomProxyMock = JoinedRoomProxyMock(.init(id: "stable_id", + name: "Preview room", + hasOngoingCall: true)) static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockRoomTimelineController(), diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenCoordinator.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenCoordinator.swift index 7ba042bd9c..0c995ffa9c 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenCoordinator.swift @@ -57,7 +57,7 @@ final class NotificationSettingsEditScreenCoordinator: CoordinatorProtocol { // MARK: - Private private func presentRoomNotificationSettings(roomID: String) async { - guard let roomProxy = await parameters.userSession.clientProxy.roomForIdentifier(roomID) else { return } + guard case let .joined(roomProxy) = await parameters.userSession.clientProxy.roomForIdentifier(roomID) else { return } let roomNotificationSettingsParameters = RoomNotificationSettingsScreenCoordinatorParameters(navigationStackCoordinator: parameters.navigationStackCoordinator, notificationSettingsProxy: parameters.notificationSettings, diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenViewModel.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenViewModel.swift index 58af7aa490..793a36f9fe 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenViewModel.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsEditScreen/NotificationSettingsEditScreenViewModel.swift @@ -138,7 +138,7 @@ class NotificationSettingsEditScreenViewModel: NotificationSettingsEditScreenVie var roomsWithUserDefinedMode: [NotificationSettingsEditScreenRoom] = [] for roomSummary in filteredRoomsSummary { - guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomSummary.id) else { continue } + guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomSummary.id) else { continue } // `isOneToOneRoom` here is not the same as `isDirect` on the room. From the point of view of the push rule, a one-to-one room is a room with exactly two active members. let isOneToOneRoom = roomProxy.activeMembersCount == 2 // display only the rooms we're interested in diff --git a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift index 6241667f39..d74e00b0c1 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift @@ -35,7 +35,7 @@ enum TimelineInteractionHandlerAction { @MainActor class TimelineInteractionHandler { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let timelineController: RoomTimelineControllerProtocol private let mediaProvider: MediaProviderProtocol private let mediaPlayerProvider: MediaPlayerProviderProtocol @@ -60,7 +60,7 @@ class TimelineInteractionHandler { private var resumeVoiceMessagePlaybackAfterScrubbing = false - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, timelineController: RoomTimelineControllerProtocol, mediaProvider: MediaProviderProtocol, mediaPlayerProvider: MediaPlayerProviderProtocol, diff --git a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift index f024735e6b..6d9117ed2a 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift @@ -29,7 +29,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { static let toastErrorID = "RoomScreenToastError" } - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let timelineController: RoomTimelineControllerProtocol private let mediaPlayerProvider: MediaPlayerProviderProtocol private let userIndicatorController: UserIndicatorControllerProtocol @@ -49,7 +49,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol { private var paginateBackwardsTask: Task? private var paginateForwardsTask: Task? - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, focussedEventID: String? = nil, timelineController: RoomTimelineControllerProtocol, mediaProvider: MediaProviderProtocol, @@ -819,7 +819,7 @@ private extension RoomProxyProtocol { // MARK: - Mocks extension TimelineViewModel { - static let mock = TimelineViewModel(roomProxy: RoomProxyMock(.init(name: "Preview room")), + static let mock = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")), focussedEventID: nil, timelineController: MockRoomTimelineController(), mediaProvider: MockMediaProvider(), diff --git a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift index 8e5e9e45c6..ceb018162e 100644 --- a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift +++ b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift @@ -51,7 +51,7 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview { .mockCharlie, .mockDan ] - let roomProxyMock = RoomProxyMock(.init(name: "Room", members: members)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members)) let mock = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockRoomTimelineController(), mediaProvider: MockMediaProvider(), diff --git a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift index 4eeac31e7d..f6a842dd24 100644 --- a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift @@ -90,7 +90,7 @@ struct TimelineReadReceiptsView_Previews: PreviewProvider, TestablePreview { .mockMe ] - static let viewModel = TimelineViewModel(roomProxy: RoomProxyMock(.init(name: "Test", members: members)), + static let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)), timelineController: MockRoomTimelineController(), mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift index dae13fbd26..321a1df9de 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift @@ -93,7 +93,7 @@ struct HighlightedTimelineItemModifier_Previews: PreviewProvider, TestablePrevie /// A preview that allows quick testing of the highlight appearance across various timeline scenarios. struct HighlightedTimelineItemTimeline_Previews: PreviewProvider { - static let roomProxyMock = RoomProxyMock(.init(name: "Preview room")) + static let roomProxyMock = JoinedRoomProxyMock(.init(name: "Preview room")) static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let focussedEventID = "RoomTimelineItemFixtures.default.5" static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift index 7308c17021..574c18f1fe 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift @@ -79,8 +79,8 @@ struct TimelineView: UIViewControllerRepresentable { // MARK: - Previews struct TimelineView_Previews: PreviewProvider, TestablePreview { - static let roomProxyMock = RoomProxyMock(.init(id: "stable_id", - name: "Preview room")) + static let roomProxyMock = JoinedRoomProxyMock(.init(id: "stable_id", + name: "Preview room")) static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockRoomTimelineController(), diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index a44da83625..b212a0cbb7 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -443,23 +443,13 @@ class ClientProxy: ClientProxyProtocol { return result } - func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? { - guard let roomListService else { - MXLog.error("Failed retrieving room, room list service not set up") - return nil - } - + func roomForIdentifier(_ identifier: String) async -> RoomProxyType? { // Try fetching the room from the cold cache (if available) first - var (roomListItem, room) = await roomTupleForIdentifier(identifier) - - if let roomListItem, let room { - return await RoomProxy(roomListService: roomListService, - roomListItem: roomListItem, - room: room) + if let room = await buildRoomForIdentifier(identifier) { + return room } // Else wait for the visible rooms list to go into fully loaded - guard let roomSummaryProvider else { MXLog.error("Rooms summary provider not setup yet") return nil @@ -469,21 +459,7 @@ class ClientProxy: ClientProxyProtocol { _ = await roomSummaryProvider.statePublisher.values.first(where: { $0.isLoaded }) } - (roomListItem, room) = await roomTupleForIdentifier(identifier) - - guard let roomListItem else { - MXLog.error("Invalid roomListItem for identifier \(identifier)") - return nil - } - - guard let room else { - MXLog.error("Invalid roomListItem fullRoom for identifier \(identifier)") - return nil - } - - return await RoomProxy(roomListService: roomListService, - roomListItem: roomListItem, - room: room) + return await buildRoomForIdentifier(identifier) } func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result { @@ -703,9 +679,9 @@ class ClientProxy: ClientProxyProtocol { var users: OrderedSet = [] for roomID in roomIdentifiers { - guard let room = await roomForIdentifier(roomID), - room.isDirect, - let members = await room.members() else { + guard case let .joined(roomProxy) = await roomForIdentifier(roomID), + roomProxy.isDirect, + let members = await roomProxy.members() else { continue } @@ -868,19 +844,46 @@ class ClientProxy: ClientProxyProtocol { return .exclude(eventTypes: stateEventFilters.map { FilterTimelineEventType.state(eventType: $0) }) }() - - private func roomTupleForIdentifier(_ identifier: String) async -> (RoomListItem?, Room?) { - do { - let roomListItem = try roomListService?.room(roomId: identifier) - if roomListItem?.isTimelineInitialized() == false { - try await roomListItem?.initTimeline(eventTypeFilter: eventFilters, internalIdPrefix: nil) + + private func buildRoomForIdentifier(_ identifier: String) async -> RoomProxyType? { + guard let roomListService else { + MXLog.error("Failed retrieving room, room list service not set up") + return nil + } + + guard let roomListItem = try? roomListService.room(roomId: identifier) else { + MXLog.error("Failed retrieving room, invalid room list item") + return nil + } + + if roomListItem.isTimelineInitialized() == false { + do { + try await roomListItem.initTimeline(eventTypeFilter: eventFilters, internalIdPrefix: nil) + } catch { + MXLog.error("Failed initializing room timeline with error: \(error)") + return nil + } + } + + guard let room = try? roomListItem.fullRoom() else { + MXLog.error("Failed retrieving room, invalid room list item full room") + return nil + } + + switch room.membership() { + case .invited: + return .invited(InvitedRoomProxy(roomListItem: roomListItem, + room: room)) + case .joined: + guard let roomProxy = await JoinedRoomProxy(roomListService: roomListService, + roomListItem: roomListItem, + room: room) else { + return nil } - let fullRoom = try roomListItem?.fullRoom() - return (roomListItem, fullRoom) - } catch { - MXLog.error("Failed retrieving/initialising room with identifier: \(identifier)") - return (nil, nil) + return .joined(roomProxy) + case .left: + return .left } } diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 62785e59fc..e041e06d53 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -146,7 +146,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func uploadMedia(_ media: MediaInfo) async -> Result - func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol? + func roomForIdentifier(_ identifier: String) async -> RoomProxyType? func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result diff --git a/ElementX/Sources/Services/ComposerDraft/ComposerDraftService.swift b/ElementX/Sources/Services/ComposerDraft/ComposerDraftService.swift index 615d344e1f..6824912555 100644 --- a/ElementX/Sources/Services/ComposerDraft/ComposerDraftService.swift +++ b/ElementX/Sources/Services/ComposerDraft/ComposerDraftService.swift @@ -19,11 +19,11 @@ import Foundation import MatrixRustSDK final class ComposerDraftService: ComposerDraftServiceProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let timelineItemfactory: RoomTimelineItemFactoryProtocol private var volatileDraft: ComposerDraftProxy? - init(roomProxy: RoomProxyProtocol, timelineItemfactory: RoomTimelineItemFactoryProtocol) { + init(roomProxy: JoinedRoomProxyProtocol, timelineItemfactory: RoomTimelineItemFactoryProtocol) { self.roomProxy = roomProxy self.timelineItemfactory = timelineItemfactory } diff --git a/ElementX/Sources/Services/ElementCall/ElementCallConfiguration.swift b/ElementX/Sources/Services/ElementCall/ElementCallConfiguration.swift index b2b3f992ac..b9be9fc0dd 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallConfiguration.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallConfiguration.swift @@ -25,7 +25,7 @@ private enum GenericCallLinkQueryParameters { struct ElementCallConfiguration { enum Kind { case genericCallLink(URL) - case roomCall(roomProxy: RoomProxyProtocol, + case roomCall(roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol, clientID: String, elementCallBaseURL: URL, @@ -62,7 +62,7 @@ struct ElementCallConfiguration { } /// Creates a configuration for an internal room call. - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, clientProxy: ClientProxyProtocol, clientID: String, elementCallBaseURL: URL, diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index 5accc97d87..db0316152f 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -276,7 +276,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe return } - guard let roomProxy = await clientProxy.roomForIdentifier(incomingCallID.roomID) else { + guard case let .joined(roomProxy) = await clientProxy.roomForIdentifier(incomingCallID.roomID) else { return } diff --git a/ElementX/Sources/Services/Polls/PollInteractionHandler.swift b/ElementX/Sources/Services/Polls/PollInteractionHandler.swift index 507043af9a..2ae0c8b799 100644 --- a/ElementX/Sources/Services/Polls/PollInteractionHandler.swift +++ b/ElementX/Sources/Services/Polls/PollInteractionHandler.swift @@ -18,9 +18,9 @@ import Foundation class PollInteractionHandler: PollInteractionHandlerProtocol { let analyticsService: AnalyticsService - let roomProxy: RoomProxyProtocol + let roomProxy: JoinedRoomProxyProtocol - init(analyticsService: AnalyticsService, roomProxy: RoomProxyProtocol) { + init(analyticsService: AnalyticsService, roomProxy: JoinedRoomProxyProtocol) { self.analyticsService = analyticsService self.roomProxy = roomProxy } diff --git a/ElementX/Sources/Services/Room/InvitedRoomProxy.swift b/ElementX/Sources/Services/Room/InvitedRoomProxy.swift new file mode 100644 index 0000000000..4ed072425a --- /dev/null +++ b/ElementX/Sources/Services/Room/InvitedRoomProxy.swift @@ -0,0 +1,111 @@ +// +// Copyright 2024 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +import MatrixRustSDK +import UIKit + +class InvitedRoomProxy: InvitedRoomProxyProtocol { + private let roomListItem: RoomListItemProtocol + private let room: RoomProtocol + + // A room identifier is constant and lazy stops it from being fetched + // multiple times over FFI + lazy var id: String = room.id() + + var canonicalAlias: String? { + room.canonicalAlias() + } + + var ownUserID: String { + room.ownUserId() + } + + var name: String? { + roomListItem.displayName() + } + + var topic: String? { + room.topic() + } + + var avatarURL: URL? { + roomListItem.avatarUrl().flatMap(URL.init(string:)) + } + + var avatar: RoomAvatar { + if isDirect, avatarURL == nil { + let heroes = room.heroes() + + if heroes.count == 1 { + return .heroes(heroes.map(UserProfileProxy.init)) + } + } + + return .room(id: id, name: name, avatarURL: avatarURL) + } + + var isDirect: Bool { + room.isDirect() + } + + var isPublic: Bool { + room.isPublic() + } + + var isSpace: Bool { + room.isSpace() + } + + var joinedMembersCount: Int { + Int(room.joinedMembersCount()) + } + + var activeMembersCount: Int { + Int(room.activeMembersCount()) + } + + var inviter: RoomMemberProxyProtocol? { + get async { + await (try? roomListItem.roomInfo().inviter).map(RoomMemberProxy.init) + } + } + + init(roomListItem: RoomListItemProtocol, + room: RoomProtocol) { + self.roomListItem = roomListItem + self.room = room + } + + func acceptInvitation() async -> Result { + do { + try await room.join() + return .success(()) + } catch { + MXLog.error("Failed accepting invitation with error: \(error)") + return .failure(.sdkError(error)) + } + } + + func rejectInvitation() async -> Result { + do { + return try await .success(room.leave()) + } catch { + MXLog.error("Failed rejecting invitiation with error: \(error)") + return .failure(.sdkError(error)) + } + } +} diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift similarity index 96% rename from ElementX/Sources/Services/Room/RoomProxy.swift rename to ElementX/Sources/Services/Room/JoinedRoomProxy.swift index 92990a7117..bc1a57b4be 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift @@ -19,7 +19,7 @@ import Foundation import MatrixRustSDK import UIKit -class RoomProxy: RoomProxyProtocol { +class JoinedRoomProxy: JoinedRoomProxyProtocol { private let roomListService: RoomListServiceProtocol private let roomListItem: RoomListItemProtocol private let room: RoomProtocol @@ -77,13 +77,19 @@ class RoomProxy: RoomProxyProtocol { typingMembersSubject.asCurrentValuePublisher() } - private let actionsSubject = PassthroughSubject() - var actionsPublisher: AnyPublisher { + private let actionsSubject = PassthroughSubject() + var actionsPublisher: AnyPublisher { actionsSubject.eraseToAnyPublisher() } + // A room identifier is constant and lazy stops it from being fetched + // multiple times over FFI lazy var id: String = room.id() + var canonicalAlias: String? { + room.canonicalAlias() + } + var ownUserID: String { room.ownUserId() } @@ -96,14 +102,20 @@ class RoomProxy: RoomProxyProtocol { room.topic() } - var membership: Membership { - room.membership() + var avatarURL: URL? { + roomListItem.avatarUrl().flatMap(URL.init(string:)) } - var inviter: RoomMemberProxyProtocol? { - get async { - await (try? roomListItem.roomInfo().inviter).map(RoomMemberProxy.init) + var avatar: RoomAvatar { + if isDirect, avatarURL == nil { + let heroes = room.heroes() + + if heroes.count == 1 { + return .heroes(heroes.map(UserProfileProxy.init)) + } } + + return .room(id: id, name: name, avatarURL: avatarURL) } var isDirect: Bool { @@ -118,6 +130,14 @@ class RoomProxy: RoomProxyProtocol { room.isSpace() } + var joinedMembersCount: Int { + Int(room.joinedMembersCount()) + } + + var activeMembersCount: Int { + Int(room.activeMembersCount()) + } + var isEncrypted: Bool { (try? room.isEncrypted()) ?? false } @@ -145,34 +165,6 @@ class RoomProxy: RoomProxyProtocol { room.activeRoomCallParticipants() } - var canonicalAlias: String? { - room.canonicalAlias() - } - - var avatarURL: URL? { - roomListItem.avatarUrl().flatMap(URL.init(string:)) - } - - var avatar: RoomAvatar { - if isDirect, avatarURL == nil { - let heroes = room.heroes() - - if heroes.count == 1 { - return .heroes(heroes.map(UserProfileProxy.init)) - } - } - - return .room(id: id, name: name, avatarURL: avatarURL) - } - - var joinedMembersCount: Int { - Int(room.joinedMembersCount()) - } - - var activeMembersCount: Int { - Int(room.activeMembersCount()) - } - init?(roomListService: RoomListServiceProtocol, roomListItem: RoomListItemProtocol, room: RoomProtocol) async { @@ -315,25 +307,6 @@ class RoomProxy: RoomProxyProtocol { } } - func rejectInvitation() async -> Result { - do { - return try await .success(room.leave()) - } catch { - MXLog.error("Failed rejecting invitiation with error: \(error)") - return .failure(.sdkError(error)) - } - } - - func acceptInvitation() async -> Result { - do { - try await room.join() - return .success(()) - } catch { - MXLog.error("Failed accepting invitation with error: \(error)") - return .failure(.sdkError(error)) - } - } - func invite(userID: String) async -> Result { do { MXLog.info("Inviting user \(userID)") diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index fdb67b171e..7078272829 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -26,46 +26,62 @@ enum RoomProxyError: Error { case eventNotFound } -enum RoomProxyAction { - case roomInfoUpdate +enum RoomProxyType { + case joined(JoinedRoomProxyProtocol) + case invited(InvitedRoomProxyProtocol) + case left } // sourcery: AutoMockable protocol RoomProxyProtocol { var id: String { get } - var isDirect: Bool { get } - var isPublic: Bool { get } - var isSpace: Bool { get } - var isEncrypted: Bool { get } - var isFavourite: Bool { get async } - var pinnedEventIDs: Set { get async } - var membership: Membership { get } - var inviter: RoomMemberProxyProtocol? { get async } - - var hasOngoingCall: Bool { get } - var activeRoomCallParticipants: [String] { get } - var canonicalAlias: String? { get } + var ownUserID: String { get } var name: String? { get } - var topic: String? { get } /// The room's avatar info for use in a ``RoomAvatarImage``. var avatar: RoomAvatar { get } /// The room's avatar URL. Use this for editing and favour ``avatar`` for display. var avatarURL: URL? { get } - - var membersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> { get } - var typingMembersPublisher: CurrentValuePublisher<[String], Never> { get } + var isPublic: Bool { get } + var isDirect: Bool { get } + var isSpace: Bool { get } var joinedMembersCount: Int { get } var activeMembersCount: Int { get } +} + +// sourcery: AutoMockable +protocol InvitedRoomProxyProtocol: RoomProxyProtocol { + var inviter: RoomMemberProxyProtocol? { get async } - var actionsPublisher: AnyPublisher { get } + func rejectInvitation() async -> Result + func acceptInvitation() async -> Result +} + +enum JoinedRoomProxyAction { + case roomInfoUpdate +} + +// sourcery: AutoMockable +protocol JoinedRoomProxyProtocol: RoomProxyProtocol { + var isEncrypted: Bool { get } + var isFavourite: Bool { get async } + var pinnedEventIDs: Set { get async } + + var hasOngoingCall: Bool { get } + var activeRoomCallParticipants: [String] { get } + + var membersPublisher: CurrentValuePublisher<[RoomMemberProxyProtocol], Never> { get } + + var typingMembersPublisher: CurrentValuePublisher<[String], Never> { get } + + var actionsPublisher: AnyPublisher { get } var timeline: TimelineProxyProtocol { get } @@ -87,10 +103,6 @@ protocol RoomProxyProtocol { func getMember(userID: String) async -> Result - func rejectInvitation() async -> Result - - func acceptInvitation() async -> Result - func invite(userID: String) async -> Result func setName(_ name: String) async -> Result @@ -155,7 +167,7 @@ protocol RoomProxyProtocol { func clearDraft() async -> Result } -extension RoomProxyProtocol { +extension JoinedRoomProxyProtocol { var details: RoomDetails { RoomDetails(id: id, name: name, diff --git a/ElementX/Sources/Services/Timeline/TimelineController/MockRoomTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/MockRoomTimelineController.swift index 1d452481fe..ccaa180f7f 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/MockRoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/MockRoomTimelineController.swift @@ -26,7 +26,7 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol { /// An array of timeline items that will be appended in order when ``simulateIncomingItems()`` is called. var incomingItems: [RoomTimelineItemProtocol] = [] - var roomProxy: RoomProxyProtocol? + var roomProxy: JoinedRoomProxyProtocol? var roomID: String { roomProxy?.id ?? "MockRoomIdentifier" } let callbacks = PassthroughSubject() diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift index ad727a623f..b3a14923b4 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift @@ -20,7 +20,7 @@ import MatrixRustSDK import UIKit class RoomTimelineController: RoomTimelineControllerProtocol { - private let roomProxy: RoomProxyProtocol + private let roomProxy: JoinedRoomProxyProtocol private let liveTimelineProvider: RoomTimelineProviderProtocol private let timelineItemFactory: RoomTimelineItemFactoryProtocol private let appSettings: AppSettings @@ -41,7 +41,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol { roomProxy.id } - init(roomProxy: RoomProxyProtocol, + init(roomProxy: JoinedRoomProxyProtocol, timelineProxy: TimelineProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol, diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactory.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactory.swift index a30ea96a14..456326001b 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactory.swift @@ -17,7 +17,7 @@ import Foundation struct RoomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol { - func buildRoomTimelineController(roomProxy: RoomProxyProtocol, + func buildRoomTimelineController(roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol { RoomTimelineController(roomProxy: roomProxy, @@ -27,7 +27,7 @@ struct RoomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol { appSettings: ServiceLocator.shared.settings) } - func buildRoomPinnedTimelineController(roomProxy: RoomProxyProtocol, + func buildRoomPinnedTimelineController(roomProxy: JoinedRoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol? { guard let pinnedEventsTimeline = await roomProxy.pinnedEventsTimeline else { return nil diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactoryProtocol.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactoryProtocol.swift index c8c79874f9..d1df646f94 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactoryProtocol.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineControllerFactoryProtocol.swift @@ -18,10 +18,10 @@ import Foundation @MainActor protocol RoomTimelineControllerFactoryProtocol { - func buildRoomTimelineController(roomProxy: RoomProxyProtocol, + func buildRoomTimelineController(roomProxy: JoinedRoomProxyProtocol, initialFocussedEventID: String?, timelineItemFactory: RoomTimelineItemFactoryProtocol) -> RoomTimelineControllerProtocol - func buildRoomPinnedTimelineController(roomProxy: RoomProxyProtocol, + func buildRoomPinnedTimelineController(roomProxy: JoinedRoomProxyProtocol, timelineItemFactory: RoomTimelineItemFactoryProtocol) async -> RoomTimelineControllerProtocol? } diff --git a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift index 1d0c641cef..fe15d45d0a 100644 --- a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift +++ b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift @@ -154,7 +154,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol { return .success(waveformData) } - func sendVoiceMessage(inRoom roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result { + func sendVoiceMessage(inRoom roomProxy: JoinedRoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result { guard let url = audioRecorder.audioFileURL else { return .failure(VoiceMessageRecorderError.missingRecordingFile) } diff --git a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorderProtocol.swift b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorderProtocol.swift index ca1d10d978..5c4a99160e 100644 --- a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorderProtocol.swift +++ b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorderProtocol.swift @@ -47,7 +47,7 @@ protocol VoiceMessageRecorderProtocol { func seekPlayback(to progress: Double) async func deleteRecording() async - func sendVoiceMessage(inRoom roomProxy: RoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result + func sendVoiceMessage(inRoom roomProxy: JoinedRoomProxyProtocol, audioConverter: AudioConverterProtocol) async -> Result } // sourcery: AutoMockable diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index 53d5159096..9234c0bf36 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -248,7 +248,7 @@ class MockScreen: Identifiable { return navigationStackCoordinator case .roomPlainNoAvatar: let navigationStackCoordinator = NavigationStackCoordinator() - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Some room name", avatarURL: nil)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Some room name", avatarURL: nil)), timelineController: MockRoomTimelineController(), mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -265,7 +265,7 @@ class MockScreen: Identifiable { let navigationStackCoordinator = NavigationStackCoordinator() let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.smallChunk - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -282,7 +282,7 @@ class MockScreen: Identifiable { let navigationStackCoordinator = NavigationStackCoordinator() let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.default - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -299,7 +299,7 @@ class MockScreen: Identifiable { let navigationStackCoordinator = NavigationStackCoordinator() let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.smallChunkWithReadReceipts - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -319,7 +319,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.smallChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.singleMessageChunk] timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Small timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -339,7 +339,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController(listenForSignals: true) timelineController.timelineItems = RoomTimelineItemFixtures.smallChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Small timeline, paginating", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline, paginating", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -359,7 +359,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController(listenForSignals: true) timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -380,7 +380,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -400,7 +400,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController(listenForSignals: true) timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -419,7 +419,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.permalinkChunk - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Timeline highlight", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Timeline highlight", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -452,7 +452,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.disclosedPolls timelineController.incomingItems = [] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -472,7 +472,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.undisclosedPolls timelineController.incomingItems = [] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -492,7 +492,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.outgoingPolls timelineController.incomingItems = [] - let parameters = RoomScreenCoordinatorParameters(roomProxy: RoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + let parameters = RoomScreenCoordinatorParameters(roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -546,7 +546,7 @@ class MockScreen: Identifiable { let navigationStackCoordinator = NavigationStackCoordinator() let members: [RoomMemberProxyMock] = [.mockInvitedAlice, .mockBob, .mockCharlie] let coordinator = RoomMembersListScreenCoordinator(parameters: .init(mediaProvider: MockMediaProvider(), - roomProxy: RoomProxyMock(.init(name: "test", members: members)), + roomProxy: JoinedRoomProxyMock(.init(name: "test", members: members)), userIndicatorController: ServiceLocator.shared.userIndicatorController, analytics: ServiceLocator.shared.analytics)) navigationStackCoordinator.setRootCoordinator(coordinator) @@ -554,7 +554,7 @@ class MockScreen: Identifiable { case .roomRolesAndPermissionsFlow: let navigationStackCoordinator = NavigationStackCoordinator() navigationStackCoordinator.setRootCoordinator(BlankFormCoordinator()) - let coordinator = RoomRolesAndPermissionsFlowCoordinator(parameters: .init(roomProxy: RoomProxyMock(.init(members: .allMembersAsAdmin)), + let coordinator = RoomRolesAndPermissionsFlowCoordinator(parameters: .init(roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)), mediaProvider: MockMediaProvider(), navigationStackCoordinator: navigationStackCoordinator, userIndicatorController: ServiceLocator.shared.userIndicatorController, @@ -627,9 +627,9 @@ class MockScreen: Identifiable { let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))))) - let roomProxy = RoomProxyMock(.init(id: "whatever", name: "okay", shouldUseAutoUpdatingTimeline: true)) + let roomProxy = JoinedRoomProxyMock(.init(id: "whatever", name: "okay", shouldUseAutoUpdatingTimeline: true)) - clientProxy.roomForIdentifierReturnValue = roomProxy + clientProxy.roomForIdentifierReturnValue = .joined(roomProxy) ServiceLocator.shared.settings.migratedAccounts[clientProxy.userID] = true diff --git a/UnitTests/Sources/CompletionSuggestionServiceTests.swift b/UnitTests/Sources/CompletionSuggestionServiceTests.swift index 26d555726a..ef8ab4f9fb 100644 --- a/UnitTests/Sources/CompletionSuggestionServiceTests.swift +++ b/UnitTests/Sources/CompletionSuggestionServiceTests.swift @@ -30,7 +30,7 @@ final class CompletionSuggestionServiceTests: XCTestCase { func testUserSuggestions() async throws { let alice: RoomMemberProxyMock = .mockAlice let members: [RoomMemberProxyMock] = [alice, .mockBob, .mockCharlie, .mockMe] - let roomProxyMock = RoomProxyMock(.init(name: "test", members: members)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "test", members: members)) let service = CompletionSuggestionService(roomProxy: roomProxyMock) var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in @@ -67,7 +67,7 @@ final class CompletionSuggestionServiceTests: XCTestCase { func testUserSuggestionsIncludingAllUsers() async throws { let alice: RoomMemberProxyMock = .mockAlice let members: [RoomMemberProxyMock] = [alice, .mockBob, .mockCharlie, .mockMe] - let roomProxyMock = RoomProxyMock(.init(name: "test", members: members, canUserTriggerRoomNotification: true)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "test", members: members, canUserTriggerRoomNotification: true)) let service = CompletionSuggestionService(roomProxy: roomProxyMock) var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in @@ -93,7 +93,7 @@ final class CompletionSuggestionServiceTests: XCTestCase { let alice: RoomMemberProxyMock = .mockAlice let bob: RoomMemberProxyMock = .mockBob let members: [RoomMemberProxyMock] = [alice, bob, .mockMe] - let roomProxyMock = RoomProxyMock(.init(name: "test", members: members, canUserTriggerRoomNotification: true)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "test", members: members, canUserTriggerRoomNotification: true)) let service = CompletionSuggestionService(roomProxy: roomProxyMock) var deferred = deferFulfillment(service.suggestionsPublisher) { suggestions in diff --git a/UnitTests/Sources/HomeScreenViewModelTests.swift b/UnitTests/Sources/HomeScreenViewModelTests.swift index f6faa5e956..6be6aee8de 100644 --- a/UnitTests/Sources/HomeScreenViewModelTests.swift +++ b/UnitTests/Sources/HomeScreenViewModelTests.swift @@ -87,7 +87,7 @@ class HomeScreenViewModelTests: XCTestCase { func testLeaveRoomAlert() async throws { let mockRoomId = "1" - clientProxy.roomForIdentifierClosure = { _ in RoomProxyMock(.init(id: mockRoomId, name: "Some room")) } + clientProxy.roomForIdentifierClosure = { _ in .joined(JoinedRoomProxyMock(.init(id: mockRoomId, name: "Some room"))) } let deferred = deferFulfillment(context.$viewState) { value in value.bindings.leaveRoomAlertItem != nil @@ -102,10 +102,10 @@ class HomeScreenViewModelTests: XCTestCase { func testLeaveRoomError() async throws { let mockRoomId = "1" - let room = RoomProxyMock(.init(id: mockRoomId, name: "Some room")) + let room = JoinedRoomProxyMock(.init(id: mockRoomId, name: "Some room")) room.leaveRoomClosure = { .failure(.sdkError(ClientProxyMockError.generic)) } - clientProxy.roomForIdentifierClosure = { _ in room } + clientProxy.roomForIdentifierClosure = { _ in .joined(room) } let deferred = deferFulfillment(context.$viewState) { value in value.bindings.alertInfo != nil @@ -133,10 +133,10 @@ class HomeScreenViewModelTests: XCTestCase { expectation.fulfill() } .store(in: &cancellables) - let room = RoomProxyMock(.init(id: mockRoomId, name: "Some room")) + let room = JoinedRoomProxyMock(.init(id: mockRoomId, name: "Some room")) room.leaveRoomClosure = { .success(()) } - clientProxy.roomForIdentifierClosure = { _ in room } + clientProxy.roomForIdentifierClosure = { _ in .joined(room) } context.send(viewAction: .confirmLeaveRoom(roomIdentifier: mockRoomId)) await fulfillment(of: [expectation]) diff --git a/UnitTests/Sources/InviteUsersViewModelTests.swift b/UnitTests/Sources/InviteUsersViewModelTests.swift index 7deebb12e5..fe8baa45b1 100644 --- a/UnitTests/Sources/InviteUsersViewModelTests.swift +++ b/UnitTests/Sources/InviteUsersViewModelTests.swift @@ -64,7 +64,7 @@ class InviteUsersScreenViewModelTests: XCTestCase { func testInviteButton() async throws { let mockedMembers: [RoomMemberProxyMock] = [.mockAlice, .mockBob] - setupWithRoomType(roomType: .room(roomProxy: RoomProxyMock(.init(name: "test", members: mockedMembers)))) + setupWithRoomType(roomType: .room(roomProxy: JoinedRoomProxyMock(.init(name: "test", members: mockedMembers)))) let deferredState = deferFulfillment(viewModel.context.$viewState) { state in state.isUserSelected(.mockAlice) diff --git a/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift b/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift index dccf8c3c80..07da08d4de 100644 --- a/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift +++ b/UnitTests/Sources/MessageForwardingScreenViewModelTests.swift @@ -32,7 +32,7 @@ class MessageForwardingScreenViewModelTests: XCTestCase { cancellables.removeAll() let clientProxy = ClientProxyMock(.init()) - clientProxy.roomForIdentifierClosure = { RoomProxyMock(.init(id: $0)) } + clientProxy.roomForIdentifierClosure = { .joined(JoinedRoomProxyMock(.init(id: $0))) } viewModel = MessageForwardingScreenViewModel(forwardingItem: forwardingItem, clientProxy: clientProxy, diff --git a/UnitTests/Sources/PillContextTests.swift b/UnitTests/Sources/PillContextTests.swift index 91b61644a1..c5956ef0a8 100644 --- a/UnitTests/Sources/PillContextTests.swift +++ b/UnitTests/Sources/PillContextTests.swift @@ -23,7 +23,7 @@ import XCTest class PillContextTests: XCTestCase { func testUser() async throws { let id = "@test:matrix.org" - let proxyMock = RoomProxyMock(.init(name: "Test")) + let proxyMock = JoinedRoomProxyMock(.init(name: "Test")) let subject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([]) proxyMock.membersPublisher = subject.asCurrentValuePublisher() let mock = TimelineViewModel(roomProxy: proxyMock, @@ -51,7 +51,7 @@ class PillContextTests: XCTestCase { func testOwnUser() async throws { let id = "@test:matrix.org" - let proxyMock = RoomProxyMock(.init(name: "Test", ownUserID: id)) + let proxyMock = JoinedRoomProxyMock(.init(name: "Test", ownUserID: id)) let subject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([]) proxyMock.membersPublisher = subject.asCurrentValuePublisher() let mock = TimelineViewModel(roomProxy: proxyMock, @@ -72,7 +72,7 @@ class PillContextTests: XCTestCase { let avatarURL = URL(string: "https://matrix.jpg") let id = "test_room" let displayName = "Test" - let proxyMock = RoomProxyMock(.init(id: id, name: displayName, avatarURL: avatarURL)) + let proxyMock = JoinedRoomProxyMock(.init(id: id, name: displayName, avatarURL: avatarURL)) let mockController = MockRoomTimelineController() mockController.roomProxy = proxyMock let mock = TimelineViewModel(roomProxy: proxyMock, diff --git a/UnitTests/Sources/ReportContentViewModelTests.swift b/UnitTests/Sources/ReportContentViewModelTests.swift index ceded0d44b..fb6544b460 100644 --- a/UnitTests/Sources/ReportContentViewModelTests.swift +++ b/UnitTests/Sources/ReportContentViewModelTests.swift @@ -25,7 +25,7 @@ class ReportContentScreenViewModelTests: XCTestCase { func testReportContent() async throws { // Given the report content view for some content. - let roomProxy = RoomProxyMock(.init(name: "test")) + let roomProxy = JoinedRoomProxyMock(.init(name: "test")) roomProxy.reportContentReasonReturnValue = .success(()) let clientProxy = ClientProxyMock(.init()) let viewModel = ReportContentScreenViewModel(eventID: eventID, @@ -54,7 +54,7 @@ class ReportContentScreenViewModelTests: XCTestCase { func testReportIgnoringSender() async throws { // Given the report content view for some content. - let roomProxy = RoomProxyMock(.init(name: "test")) + let roomProxy = JoinedRoomProxyMock(.init(name: "test")) roomProxy.reportContentReasonReturnValue = .success(()) let clientProxy = ClientProxyMock(.init()) let viewModel = ReportContentScreenViewModel(eventID: eventID, diff --git a/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift b/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift index 555756bc2b..1cba856256 100644 --- a/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomChangePermissionsScreenViewModelTests.swift @@ -20,7 +20,7 @@ import XCTest @MainActor class RoomChangePermissionsScreenViewModelTests: XCTestCase { - var roomProxy: RoomProxyMock! + var roomProxy: JoinedRoomProxyMock! var viewModel: RoomChangePermissionsScreenViewModelProtocol! var context: RoomChangePermissionsScreenViewModelType.Context { @@ -28,7 +28,7 @@ class RoomChangePermissionsScreenViewModelTests: XCTestCase { } override func setUp() { - roomProxy = RoomProxyMock(.init()) + roomProxy = JoinedRoomProxyMock(.init()) viewModel = RoomChangePermissionsScreenViewModel(currentPermissions: .init(powerLevels: .mock), group: .roomDetails, roomProxy: roomProxy, diff --git a/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift b/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift index ea3a922b0c..3fb6a5f1d5 100644 --- a/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomChangeRolesScreenViewModelTests.swift @@ -21,7 +21,7 @@ import XCTest @MainActor class RoomChangeRolesScreenViewModelTests: XCTestCase { var viewModel: RoomChangeRolesScreenViewModelProtocol! - var roomProxy: RoomProxyMock! + var roomProxy: JoinedRoomProxyMock! var context: RoomChangeRolesScreenViewModelType.Context { viewModel.context @@ -202,7 +202,7 @@ class RoomChangeRolesScreenViewModelTests: XCTestCase { } private func setupViewModel(mode: RoomMemberDetails.Role) { - roomProxy = RoomProxyMock(.init(members: .allMembersAsAdmin)) + roomProxy = JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)) viewModel = RoomChangeRolesScreenViewModel(mode: mode, roomProxy: roomProxy, mediaProvider: MockMediaProvider(), diff --git a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift index 9a2a3a6567..3b769d439f 100644 --- a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift @@ -117,9 +117,9 @@ class RoomDetailsEditScreenViewModelTests: XCTestCase { // MARK: - Private - private func setupViewModel(roomProxyConfiguration: RoomProxyMockConfiguration) { + private func setupViewModel(roomProxyConfiguration: JoinedRoomProxyMockConfiguration) { userIndicatorController = UserIndicatorControllerMock.default - viewModel = .init(roomProxy: RoomProxyMock(roomProxyConfiguration), + viewModel = .init(roomProxy: JoinedRoomProxyMock(roomProxyConfiguration), mediaProvider: MockMediaProvider(), userIndicatorController: userIndicatorController) } diff --git a/UnitTests/Sources/RoomDetailsViewModelTests.swift b/UnitTests/Sources/RoomDetailsViewModelTests.swift index 2759d89e12..66bf259da0 100644 --- a/UnitTests/Sources/RoomDetailsViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsViewModelTests.swift @@ -24,14 +24,14 @@ import XCTest @MainActor class RoomDetailsScreenViewModelTests: XCTestCase { var viewModel: RoomDetailsScreenViewModel! - var roomProxyMock: RoomProxyMock! + var roomProxyMock: JoinedRoomProxyMock! var notificationSettingsProxyMock: NotificationSettingsProxyMock! var context: RoomDetailsScreenViewModelType.Context { viewModel.context } var cancellables = Set() override func setUp() { cancellables.removeAll() - roomProxyMock = RoomProxyMock(.init(name: "Test")) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test")) notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), @@ -48,7 +48,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testLeaveRoomTappedWhenPublic() async throws { let mockedMembers: [RoomMemberProxyMock] = [.mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isPublic: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isPublic: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -71,7 +71,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testLeaveRoomTappedWhenRoomNotPublic() async throws { let mockedMembers: [RoomMemberProxyMock] = [.mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isPublic: false, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -95,7 +95,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testLeaveRoomTappedWithLessThanTwoMembers() async { let mockedMembers: [RoomMemberProxyMock] = [.mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isPublic: false, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -149,7 +149,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testInitialDMDetailsState() async throws { let recipient = RoomMemberProxyMock.mockDan let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -173,7 +173,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { let recipient = RoomMemberProxyMock.mockDan let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -208,7 +208,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient] let clientProxy = ClientProxyMock(.init()) clientProxy.ignoreUserReturnValue = .failure(.sdkError(ClientProxyMockError.generic)) - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: clientProxy, mediaProvider: MockMediaProvider(), @@ -242,7 +242,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testUnignoreSuccess() async throws { let recipient = RoomMemberProxyMock.mockIgnored let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -277,7 +277,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient] let clientProxy = ClientProxyMock(.init()) clientProxy.unignoreUserReturnValue = .failure(.sdkError(ClientProxyMockError.generic)) - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: clientProxy, mediaProvider: MockMediaProvider(), @@ -310,10 +310,10 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCannotInvitePeople() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", - isPublic: true, - members: mockedMembers, - canUserInvite: false)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", + isPublic: true, + members: mockedMembers, + canUserInvite: false)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -331,7 +331,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testInvitePeople() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isPublic: true, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isPublic: true, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -365,7 +365,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCanEditAvatar() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) roomProxyMock.canUserUserIDSendStateEventClosure = { _, event in .success(event == .roomAvatar) } @@ -389,7 +389,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCanEditName() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) roomProxyMock.canUserUserIDSendStateEventClosure = { _, event in .success(event == .roomName) } @@ -413,7 +413,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCanEditTopic() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) roomProxyMock.canUserUserIDSendStateEventClosure = { _, event in .success(event == .roomTopic) } @@ -437,7 +437,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCannotEditRoom() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, isPublic: false, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), @@ -458,7 +458,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase { func testCannotEditDirectRoom() async { let mockedMembers: [RoomMemberProxyMock] = [.mockMeAdmin, .mockBob, .mockAlice] - roomProxyMock = RoomProxyMock(.init(name: "Test", isDirect: true, isPublic: false, members: mockedMembers)) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isPublic: false, members: mockedMembers)) viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock, clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), diff --git a/UnitTests/Sources/RoomFlowCoordinatorTests.swift b/UnitTests/Sources/RoomFlowCoordinatorTests.swift index 5f04315efd..0bbbfeffff 100644 --- a/UnitTests/Sources/RoomFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomFlowCoordinatorTests.swift @@ -171,7 +171,7 @@ class RoomFlowCoordinatorTests: XCTestCase { // "Join" the room clientProxy.roomForIdentifierClosure = { _ in - RoomProxyMock(.init()) + .joined(JoinedRoomProxyMock(.init())) } try await process(route: .room(roomID: "InvitedRoomID", via: [])) @@ -201,7 +201,7 @@ class RoomFlowCoordinatorTests: XCTestCase { // "Join" the room clientProxy.roomForIdentifierClosure = { _ in - RoomProxyMock(.init()) + .joined(JoinedRoomProxyMock(.init())) } try await process(route: .room(roomID: "InvitedRoomID", via: [])) diff --git a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift index 63bd3827fe..e51d5eb75f 100644 --- a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift +++ b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift @@ -21,12 +21,12 @@ import XCTest @MainActor class RoomMemberDetailsViewModelTests: XCTestCase { var viewModel: RoomMemberDetailsScreenViewModelProtocol! - var roomProxyMock: RoomProxyMock! + var roomProxyMock: JoinedRoomProxyMock! var roomMemberProxyMock: RoomMemberProxyMock! var context: RoomMemberDetailsScreenViewModelType.Context { viewModel.context } override func setUp() async throws { - roomProxyMock = RoomProxyMock(.init(name: "")) + roomProxyMock = JoinedRoomProxyMock(.init(name: "")) roomProxyMock.getMemberUserIDClosure = { _ in .success(self.roomMemberProxyMock) diff --git a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift index ae2fd28fdf..0a753aa0f7 100644 --- a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift @@ -21,7 +21,7 @@ import XCTest @MainActor class RoomMembersListScreenViewModelTests: XCTestCase { var viewModel: RoomMembersListScreenViewModel! - var roomProxy: RoomProxyMock! + var roomProxy: JoinedRoomProxyMock! var context: RoomMembersListScreenViewModel.Context { viewModel.context @@ -286,7 +286,7 @@ class RoomMembersListScreenViewModelTests: XCTestCase { } private func setup(with members: [RoomMemberProxyMock]) { - roomProxy = RoomProxyMock(.init(name: "test", members: members)) + roomProxy = JoinedRoomProxyMock(.init(name: "test", members: members)) viewModel = .init(roomProxy: roomProxy, mediaProvider: MockMediaProvider(), userIndicatorController: ServiceLocator.shared.userIndicatorController, diff --git a/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift b/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift index 93a83812bb..313fe63921 100644 --- a/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomNotificationSettingsScreenViewModelTests.swift @@ -22,18 +22,18 @@ import XCTest @MainActor class RoomNotificationSettingsScreenViewModelTests: XCTestCase { - var roomProxyMock: RoomProxyMock! + var roomProxyMock: JoinedRoomProxyMock! var notificationSettingsProxyMock: NotificationSettingsProxyMock! var cancellables = Set() override func setUpWithError() throws { cancellables.removeAll() - roomProxyMock = RoomProxyMock(.init(name: "Test")) + roomProxyMock = JoinedRoomProxyMock(.init(name: "Test")) notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) } func testInitialStateDefaultModeEncryptedRoom() async throws { - let roomProxyMock = RoomProxyMock(.init(name: "Test", isEncrypted: true)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isEncrypted: true)) let notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true)) @@ -55,7 +55,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase { } func testInitialStateDefaultModeEncryptedRoomWithCanPushEncrypted() async throws { - let roomProxyMock = RoomProxyMock(.init(name: "Test", isEncrypted: true)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isEncrypted: true)) let notificationSettingsProxyMock = NotificationSettingsProxyMock(with: .init(canPushEncryptedEvents: true)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true)) @@ -77,7 +77,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase { } func testInitialStateDefaultModeUnencryptedRoom() async throws { - let roomProxyMock = RoomProxyMock(.init(name: "Test", isEncrypted: false)) + let roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isEncrypted: false)) let notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true)) diff --git a/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift b/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift index 1ce826e566..d6c0ffe764 100644 --- a/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomRolesAndPermissionsScreenViewModelTests.swift @@ -21,7 +21,7 @@ import XCTest @MainActor class RoomRolesAndPermissionsScreenViewModelTests: XCTestCase { var viewModel: RoomRolesAndPermissionsScreenViewModelProtocol! - var roomProxy: RoomProxyMock! + var roomProxy: JoinedRoomProxyMock! var context: RoomRolesAndPermissionsScreenViewModelType.Context { viewModel.context @@ -83,7 +83,7 @@ class RoomRolesAndPermissionsScreenViewModelTests: XCTestCase { } private func setupViewModel(members: [RoomMemberProxyMock]) { - roomProxy = RoomProxyMock(.init(members: members)) + roomProxy = JoinedRoomProxyMock(.init(members: members)) viewModel = RoomRolesAndPermissionsScreenViewModel(roomProxy: roomProxy, userIndicatorController: UserIndicatorControllerMock(), analytics: ServiceLocator.shared.analytics) diff --git a/UnitTests/Sources/RoomScreenViewModelTests.swift b/UnitTests/Sources/RoomScreenViewModelTests.swift index 75890e0dac..aaa944f7ce 100644 --- a/UnitTests/Sources/RoomScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomScreenViewModelTests.swift @@ -34,8 +34,8 @@ class RoomScreenViewModelTests: XCTestCase { func testPinnedEventsBanner() async throws { ServiceLocator.shared.settings.pinningEnabled = true let timelineSubject = PassthroughSubject() - let updateSubject = PassthroughSubject() - let roomProxyMock = RoomProxyMock(.init()) + let updateSubject = PassthroughSubject() + let roomProxyMock = JoinedRoomProxyMock(.init()) // setup a way to inject the mock of the pinned events timeline roomProxyMock.pinnedEventsTimelineClosure = { await timelineSubject.values.first() @@ -105,8 +105,8 @@ class RoomScreenViewModelTests: XCTestCase { } func testRoomInfoUpdate() async throws { - let updateSubject = PassthroughSubject() - let roomProxyMock = RoomProxyMock(.init(id: "TestID", name: "StartingName", avatarURL: nil, hasOngoingCall: false)) + let updateSubject = PassthroughSubject() + let roomProxyMock = JoinedRoomProxyMock(.init(id: "TestID", name: "StartingName", avatarURL: nil, hasOngoingCall: false)) // setup the room proxy actions publisher roomProxyMock.canUserJoinCallUserIDReturnValue = .success(false) roomProxyMock.underlyingActionsPublisher = updateSubject.eraseToAnyPublisher() diff --git a/UnitTests/Sources/TimelineViewModelTests.swift b/UnitTests/Sources/TimelineViewModelTests.swift index 6e93190849..64a55ae0fb 100644 --- a/UnitTests/Sources/TimelineViewModelTests.swift +++ b/UnitTests/Sources/TimelineViewModelTests.swift @@ -328,10 +328,10 @@ class TimelineViewModelTests: XCTestCase { // swiftlint:enable force_unwrapping // swiftlint:disable:next large_tuple private func readReceiptsConfiguration(with items: [RoomTimelineItemProtocol]) -> (TimelineViewModel, - RoomProxyMock, + JoinedRoomProxyMock, TimelineProxyMock, MockRoomTimelineController) { - let roomProxy = RoomProxyMock(.init(name: "")) + let roomProxy = JoinedRoomProxyMock(.init(name: "")) let timelineProxy = TimelineProxyMock() @@ -367,7 +367,7 @@ class TimelineViewModelTests: XCTestCase { // When showing them in a timeline. let timelineController = MockRoomTimelineController() timelineController.timelineItems = [message] - let viewModel = TimelineViewModel(roomProxy: RoomProxyMock(.init(name: "", members: [RoomMemberProxyMock.mockAlice, RoomMemberProxyMock.mockCharlie])), + let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "", members: [RoomMemberProxyMock.mockAlice, RoomMemberProxyMock.mockCharlie])), timelineController: timelineController, mediaProvider: MockMediaProvider(), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -388,9 +388,9 @@ class TimelineViewModelTests: XCTestCase { // MARK: - Pins func testPinnedEvents() async throws { - let roomProxyMock = RoomProxyMock(.init(name: "", - pinnedEventIDs: .init(["test1"]))) - let actionsSubject = PassthroughSubject() + let roomProxyMock = JoinedRoomProxyMock(.init(name: "", + pinnedEventIDs: .init(["test1"]))) + let actionsSubject = PassthroughSubject() roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher() let viewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockRoomTimelineController(), @@ -417,8 +417,8 @@ class TimelineViewModelTests: XCTestCase { func testCanUserPinEvents() async throws { ServiceLocator.shared.settings.pinningEnabled = true - let roomProxyMock = RoomProxyMock(.init(name: "", canUserPin: false)) - let actionsSubject = PassthroughSubject() + let roomProxyMock = JoinedRoomProxyMock(.init(name: "", canUserPin: false)) + let actionsSubject = PassthroughSubject() roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher() let viewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockRoomTimelineController(), @@ -445,10 +445,10 @@ class TimelineViewModelTests: XCTestCase { // MARK: - Helpers - private func makeViewModel(roomProxy: RoomProxyProtocol? = nil, + private func makeViewModel(roomProxy: JoinedRoomProxyProtocol? = nil, focussedEventID: String? = nil, timelineController: RoomTimelineControllerProtocol) -> TimelineViewModel { - TimelineViewModel(roomProxy: roomProxy ?? RoomProxyMock(.init(name: "")), + TimelineViewModel(roomProxy: roomProxy ?? JoinedRoomProxyMock(.init(name: "")), focussedEventID: focussedEventID, timelineController: timelineController, mediaProvider: MockMediaProvider(), diff --git a/UnitTests/Sources/VoiceMessageRecorderTests.swift b/UnitTests/Sources/VoiceMessageRecorderTests.swift index e9408bc185..1d3645b418 100644 --- a/UnitTests/Sources/VoiceMessageRecorderTests.swift +++ b/UnitTests/Sources/VoiceMessageRecorderTests.swift @@ -204,7 +204,7 @@ class VoiceMessageRecorderTests: XCTestCase { } func testSendVoiceMessage_NoRecordingFile() async throws { - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() // If there is no recording file, an error is expected audioRecorder.audioFileURL = nil @@ -219,7 +219,7 @@ class VoiceMessageRecorderTests: XCTestCase { // If the converter returns an error audioConverter.convertToOpusOggSourceURLDestinationURLThrowableError = AudioConverterError.conversionFailed(nil) - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() guard case .failure(.failedSendingVoiceMessage) = await voiceMessageRecorder.sendVoiceMessage(inRoom: roomProxy, audioConverter: audioConverter) else { XCTFail("An error is expected") return @@ -237,7 +237,7 @@ class VoiceMessageRecorderTests: XCTestCase { } let timelineProxy = TimelineProxyMock() - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() roomProxy.timeline = timelineProxy timelineProxy.sendVoiceMessageUrlAudioInfoWaveformProgressSubjectRequestHandleReturnValue = .failure(.sdkError(SDKError.generic)) guard case .failure(.failedSendingVoiceMessage) = await voiceMessageRecorder.sendVoiceMessage(inRoom: roomProxy, audioConverter: audioConverter) else { @@ -258,7 +258,7 @@ class VoiceMessageRecorderTests: XCTestCase { } let timelineProxy = TimelineProxyMock() - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() roomProxy.timeline = timelineProxy timelineProxy.sendVoiceMessageUrlAudioInfoWaveformProgressSubjectRequestHandleReturnValue = .failure(.sdkError(SDKError.generic)) guard case .failure(.failedSendingVoiceMessage) = await voiceMessageRecorder.sendVoiceMessage(inRoom: roomProxy, audioConverter: audioConverter) else { @@ -281,7 +281,7 @@ class VoiceMessageRecorderTests: XCTestCase { // If the media upload fails let timelineProxy = TimelineProxyMock() - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() roomProxy.timeline = timelineProxy timelineProxy.sendVoiceMessageUrlAudioInfoWaveformProgressSubjectRequestHandleReturnValue = .failure(.sdkError(SDKError.generic)) guard case .failure(.failedSendingVoiceMessage) = await voiceMessageRecorder.sendVoiceMessage(inRoom: roomProxy, audioConverter: audioConverter) else { @@ -297,7 +297,7 @@ class VoiceMessageRecorderTests: XCTestCase { } let timelineProxy = TimelineProxyMock() - let roomProxy = RoomProxyMock() + let roomProxy = JoinedRoomProxyMock() roomProxy.timeline = timelineProxy audioRecorder.currentTime = 42 audioRecorder.audioFileURL = imageFileURL