From 22d14ff8e4ed6174c63d103de996ff95b993924a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 May 2026 08:14:08 -0500 Subject: [PATCH] AppSettings are Mockable (#5589) * create DependenciesProtocol and replace ServiceLocator registration with it replace mocking calls for ServiceLocator to Dependencies replace ServiceLocator with instance level calls replace ServiceLocator configs with TestDependencies config in Tests replace servicelocator usage in analytics service replace remaining ServiceLocator calls in unit tests that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances fix swiftlint warning remove remaining references to ServiceLocator make dependencies properties consistent in tests delete Dependencies and DependenciesProtocol fix whitespace modifications updates from PR feedback a pass over converting AppSettings and AnalyticsService test instance properties to per test instantiation fix a missed PR feedback Sync up after rebase create DependenciesProtocol and replace ServiceLocator registration with it replace mocking calls for ServiceLocator to Dependencies replace ServiceLocator with instance level calls replace ServiceLocator configs with TestDependencies config in Tests replace servicelocator usage in analytics service replace remaining ServiceLocator calls in unit tests that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances fix swiftlint warning remove remaining references to ServiceLocator make dependencies properties consistent in tests delete Dependencies and DependenciesProtocol * AppSettings is instance level mockable now * replace mocked and preview usages of reset + AppSettings global init with AppSettings(store: UserDefaultsMock()) * AppSettings.UserDefaultsKeys is now a RawRep struct, making it extensible * update tests with new AppSettings so it builds * update remaining AppSettings test/mock inits * AppSettings.UserDefaultsKey conformed to ExpressibleByStringLiteral * addressed issues found in first pass ai review * update AppSettings instantiations after rebase * fix accessibility tests coordinator after rebase * Rename to VolatileUserDefaults * AppSettings init uses mandatory parameter * Revert UserDefaultsKey to enum * Add TrackedUserDefaults to be able to reset the defaults object * Added volatile static func to AppSettings * Use .volatile() static func instead of full init * review fixups * Resolve build issues after rebase * updated enterprise module * remove the static reset settings call from the preview tests --------- Co-authored-by: Mauro Romito --- ElementX.xcodeproj/project.pbxproj | 24 ++ .../AccessibilityTestsAppCoordinator.swift | 3 +- .../Sources/Application/AppCoordinator.swift | 11 +- .../Application/Settings/AppSettings.swift | 224 +++++++++++------- .../Settings/TrackedUserDefaults.swift | 50 ++++ .../Settings/UserDefaultsProtocol.swift | 18 ++ .../Application/Settings/UserPreference.swift | 44 ++-- .../Settings/VolatileUserDefaults.swift | 45 ++++ .../Other/SwiftUI/Views/VisualListItem.swift | 2 +- .../LoginScreen/View/LoginScreen.swift | 2 +- .../View/ServerConfirmationScreen.swift | 2 +- .../View/ServerSelectionScreen.swift | 2 +- .../AuthenticationClassicAppAccountView.swift | 2 +- .../View/AuthenticationStartScreen.swift | 2 +- .../Screens/CallScreen/View/CallScreen.swift | 2 +- .../View/CreateRoomScreen.swift | 3 +- .../View/CreateRoomSpaceSelectionSheet.swift | 3 +- .../View/EmojiPickerScreen.swift | 4 +- .../RoomListFiltersEmptyStateView.swift | 4 +- .../View/Filters/RoomListFiltersView.swift | 6 +- .../Screens/HomeScreen/View/HomeScreen.swift | 2 +- .../View/HomeScreenEmptyStateView.swift | 2 +- .../View/HomeScreenInviteCell.swift | 2 +- .../View/HomeScreenKnockedCell.swift | 2 +- ...eScreenRecoveryKeyConfirmationBanner.swift | 2 +- .../HomeScreen/View/HomeScreenRoomCell.swift | 2 +- .../InviteUsersConfirmationSheetView.swift | 2 +- .../View/InviteUsersScreen.swift | 2 +- .../JoinRoomScreen/View/JoinRoomScreen.swift | 2 +- .../Screens/LabsScreen/View/LabsScreen.swift | 7 +- .../LocationSharingScreenViewModel.swift | 2 +- .../View/MediaEventsTimelineScreen.swift | 2 +- .../View/MediaUploadPreviewScreen.swift | 2 +- .../View/AnalyticsPromptScreen.swift | 2 +- .../View/IdentityConfirmationScreen.swift | 2 +- .../View/SessionVerificationScreen.swift | 2 +- .../View/PinnedEventsTimelineScreen.swift | 5 +- .../View/RoomDetailsEditScreen.swift | 2 +- .../View/RoomDetailsScreen.swift | 6 +- .../View/RoomMemberDetailsScreen.swift | 2 +- .../ComposerToolbarViewModel.swift | 2 +- .../View/RoomAttachmentPicker.swift | 2 +- .../RoomScreen/RoomScreenViewModel.swift | 2 +- .../Screens/RoomScreen/View/RoomScreen.swift | 2 +- .../View/SecurityAndPrivacyScreen.swift | 83 +++---- .../View/AdvancedSettingsScreen.swift | 3 +- .../View/AnalyticsSettingsScreen.swift | 2 +- .../View/DeveloperOptionsScreen.swift | 4 +- .../View/LegalInformationScreen.swift | 2 +- .../View/NotificationSettingsScreen.swift | 4 +- .../SettingsScreen/View/SettingsScreen.swift | 2 +- .../View/UserDetailsEditScreen.swift | 2 +- .../View/SpaceSettingsScreen.swift | 2 +- .../SpacesScreen/View/SpacesScreen.swift | 3 +- .../View/JoinRoomByAddressView.swift | 2 +- .../View/StartChatScreen.swift | 2 +- .../Screens/Timeline/TimelineViewModel.swift | 3 +- .../View/ItemMenu/TimelineItemMenu.swift | 2 +- .../ReadReceiptsSummaryView.swift | 2 +- .../Style/TimelineItemBubbledStylerView.swift | 4 +- .../TimelineReadReceiptsView.swift | 3 +- .../HighlightedTimelineItemModifier.swift | 3 +- .../Screens/Timeline/View/TimelineView.swift | 3 +- .../View/UserProfileScreen.swift | 2 +- .../AuthenticationService.swift | 2 +- .../UITests/UITestsAppCoordinator.swift | 4 +- .../UnitTests/UnitTestsAppCoordinator.swift | 3 - Enterprise | 2 +- .../NotificationServiceExtension.swift | 7 +- .../Sources/GeneratedPreviewTests.swift | 224 ------------------ .../ShareExtensionViewController.swift | 8 +- Tools/Sourcery/PreviewTests.stencil | 1 - ...nalyticsSettingsScreenViewModelTests.swift | 7 +- UnitTests/Sources/AnalyticsTests.swift | 7 +- .../AppLock/AppLockScreenViewModelTests.swift | 7 +- .../Sources/AppLock/AppLockServiceTests.swift | 7 +- .../AppLockSettingsScreenViewModelTests.swift | 2 +- ...kSetupBiometricsScreenViewModelTests.swift | 6 - .../AppLockSetupPINScreenViewModelTests.swift | 7 +- .../Sources/AppRouteURLParserTests.swift | 3 +- .../Sources/AuthenticationServiceTests.swift | 2 +- ...henticationStartScreenViewModelTests.swift | 7 +- UnitTests/Sources/BugReportServiceTests.swift | 3 +- .../ChatsTabFlowCoordinatorTests.swift | 3 +- .../ComposerToolbarViewModelTests.swift | 16 +- .../Sources/CreateRoomViewModelTests.swift | 3 +- .../EmojiPickerScreenViewModelTests.swift | 2 +- UnitTests/Sources/EmojiProviderTests.swift | 8 +- .../Sources/HomeScreenViewModelTests.swift | 7 +- ...tityConfirmationScreenViewModelTests.swift | 2 +- .../Sources/InviteUsersViewModelTests.swift | 12 +- .../JoinRoomScreenViewModelTests.swift | 4 +- ...nockRequestsListScreenViewModelTests.swift | 4 - .../Sources/LiveLocationManagerTests.swift | 10 +- .../LocationSharingScreenViewModelTests.swift | 8 +- .../Sources/LoginScreenViewModelTests.swift | 2 +- ...diaUploadPreviewScreenViewModelTests.swift | 7 +- .../MediaUploadingPreprocessorTests.swift | 7 +- .../NotificationManagerTests.swift | 3 +- ...ficationSettingsScreenViewModelTests.swift | 4 +- .../NotificationToneManagerTests.swift | 3 +- UnitTests/Sources/PillContextTests.swift | 22 +- .../RoomDetailsEditScreenViewModelTests.swift | 2 +- .../RoomDetailsScreenViewModelTests.swift | 45 ++-- .../Sources/RoomFlowCoordinatorTests.swift | 6 +- .../Sources/RoomListFiltersStateTests.swift | 7 +- .../RoomMemberDetailsViewModelTests.swift | 2 +- .../RoomMembersFlowCoordinatorTests.swift | 2 +- .../Sources/RoomScreenViewModelTests.swift | 7 +- .../Sources/RoomSummaryProviderTests.swift | 7 +- ...curityAndPrivacyScreenViewModelTests.swift | 9 +- ...rverConfirmationScreenViewModelTests.swift | 7 +- .../ServerSelectionScreenViewModelTests.swift | 2 +- .../SessionVerificationViewModelTests.swift | 2 +- .../SettingsScreenViewModelTests.swift | 2 +- .../SpaceListScreenViewModelTests.swift | 7 +- .../Sources/StartChatViewModelTests.swift | 2 +- .../Sources/TimelineViewModelTests.swift | 17 +- .../UserDetailsEditScreenViewModelTests.swift | 2 +- UnitTests/Sources/UserPreferenceTests.swift | 101 ++++---- .../UserProfileScreenViewModelTests.swift | 6 +- .../UserSessionFlowCoordinatorTests.swift | 2 +- 122 files changed, 572 insertions(+), 747 deletions(-) create mode 100644 ElementX/Sources/Application/Settings/TrackedUserDefaults.swift create mode 100644 ElementX/Sources/Application/Settings/UserDefaultsProtocol.swift create mode 100644 ElementX/Sources/Application/Settings/VolatileUserDefaults.swift diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index f6fb2911d..08c70daae 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -179,6 +179,7 @@ 1AE4532D92E6ED42BFE87064 /* JoinRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = A566F8F2C27B99E1FB80C69B /* JoinRule.swift */; }; 1AE4AEA0FA8DEF52671832E0 /* RoomTimelineItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED1D792EB82506A19A72C8DE /* RoomTimelineItemProtocol.swift */; }; 1AF4A82B4332CAD2DB3EB5DA /* TopBannerModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78483F0143E185EDC6ECD741 /* TopBannerModifier.swift */; }; + 1B1404DD4BB2C5079B074210 /* UserDefaultsProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */; }; 1B2DADC008EE211AF1DA5292 /* NotificationManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30ED584467DB380E3CEFB1DB /* NotificationManagerTests.swift */; }; 1B2F9F368619FFF8C63C87CC /* BugReportScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EECE8B331CD169790EF284F /* BugReportScreenViewModelTests.swift */; }; 1B5B30839656AE2F957C6B1E /* test_pdf.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BE98688578F8B0541D853695 /* test_pdf.pdf */; }; @@ -253,12 +254,14 @@ 2835FD52F3F618D07F799B3D /* Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7310D8DFE01AF45F0689C3AA /* Publisher.swift */; }; 28426806399E3659BEBC5918 /* NotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6ED50FE104992419310EEB /* NotificationHandler.swift */; }; 288408E6151D7BD3EBAA073A /* RoomScreenHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = B343C5255FB408DDE853CFDF /* RoomScreenHook.swift */; }; + 28A494A66D0F21EC1EC4EB11 /* VolatileUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */; }; 28E8C44DD6E39BEB2A1599C8 /* AccessibilityTestsAppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CABD320DE5566D133890B24 /* AccessibilityTestsAppCoordinator.swift */; }; 291A3E0EECD496D0FCC2ADAA /* TimelineScrollButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4E14E3688FF3532456A656 /* TimelineScrollButton.swift */; }; 2932570AA418974979D16DED /* UserPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E6DE144D887A254F4CAF203 /* UserPreference.swift */; }; 29491EE7AE37E239E839C5A3 /* LocationSharingScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BEBF0E59F25E842EDB6FD11 /* LocationSharingScreenModels.swift */; }; 2955F4C160CFD7794D819C64 /* EffectsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024F7398C5FC12586FB10E9D /* EffectsScene.swift */; }; 298F9EC30E918F12AB7F1EE8 /* TypingIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81F0325E252B057FAEEE1B2D /* TypingIndicatorView.swift */; }; + 29E411E37D3FBF3899B3ED69 /* UserDefaultsProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */; }; 29EE1791E0AFA1ABB7F23D2F /* GZIP in Frameworks */ = {isa = PBXBuildFile; productRef = 1BCD21310B997A6837B854D6 /* GZIP */; }; 2A4F8B76E1F99DE95D5867E6 /* ClassicAppManagerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BAD3D9BB44B2AED7CBB93 /* ClassicAppManagerMock.swift */; }; 2A56B00B070F83E0FE571193 /* TimelineMediaPreviewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = B18A454132A5A5247802821E /* TimelineMediaPreviewDataSource.swift */; }; @@ -645,6 +648,7 @@ 6B61F5B27412ED4BC2F9769C /* test_audio.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 66B96842BF5F8ACA1AC84C55 /* test_audio.mp3 */; }; 6B80C24A52411EAF10E06E96 /* SecurityAndPrivacyScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BBADF8010C813D905C172CE /* SecurityAndPrivacyScreenModels.swift */; }; 6BAE34CFA9821709CFE61E50 /* DeveloperOptionsScreenHook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F60FDB3AEFC60830BD289FE /* DeveloperOptionsScreenHook.swift */; }; + 6BEB10499149444909EBE42F /* TrackedUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */; }; 6C34237AFB808E38FC8776B9 /* RoomStateEventStringBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D55702474F279D910D2D162 /* RoomStateEventStringBuilder.swift */; }; 6C8BAF1E91618D69E7D652B2 /* NotificationServiceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A1AD6389A4659AF0CEAE62 /* NotificationServiceExtension.swift */; }; 6C98153D60FF9B648C166C27 /* TimelineItemMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91FFE1F410969ECB23FE9BB2 /* TimelineItemMenu.swift */; }; @@ -853,6 +857,7 @@ 8C706DA7EAC0974CA2F8F1CD /* MentionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15748C254911E3654C93B0ED /* MentionBuilder.swift */; }; 8C91D242BEEC657FABCC0B95 /* BlockedUsersScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8642512079EEFD622E3AA66B /* BlockedUsersScreenModels.swift */; }; 8CC12086CBF91A7E10CDC205 /* HomeScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D653265D006E708E4E51AD64 /* HomeScreenCoordinator.swift */; }; + 8CFB8BB99F25FA34B6C6BE86 /* UserDefaultsProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */; }; 8CFDA5F1562479CB3A34D277 /* RedactedRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91C8BD78F7B9247AC57FA1A3 /* RedactedRoomTimelineView.swift */; }; 8D24671992A1C1753B211221 /* EncryptionResetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89BB11A792EF6F70B95B467E /* EncryptionResetTests.swift */; }; 8D3E1FADD78E72504DE0E402 /* UserAgentBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB3B237387B8288A5A938F1B /* UserAgentBuilderTests.swift */; }; @@ -889,6 +894,7 @@ 92FE657CDFAFE3031576EB43 /* LinkNewDeviceScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED096460D7F26F10168FA33B /* LinkNewDeviceScreenViewModelProtocol.swift */; }; 9312F5A17AE59A9E910C51D6 /* NotificationItemProxyMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840182D7A61402D5947DE094 /* NotificationItemProxyMock.swift */; }; 9322949BFCA6278921085862 /* DeactivateAccountScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 664D3C710B4A12CE4E623645 /* DeactivateAccountScreenModels.swift */; }; + 9331608392D42EF465A8E710 /* TrackedUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */; }; 934051B17A884AB0635DF81B /* BlockedUsersScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A010B8EAD1A9F6B4686DF2F4 /* BlockedUsersScreenViewModel.swift */; }; 937985546F708339711ECDFC /* ComposerToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85666E40F7E817809B4FD787 /* ComposerToolbar.swift */; }; 93A549135E6C027A0D823BFE /* LRUCache in Frameworks */ = {isa = PBXBuildFile; productRef = 78B28D75FF7AF8E6146DEE2A /* LRUCache */; }; @@ -1051,6 +1057,7 @@ AC90434798E7894370E80E66 /* SecureBackupScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79BB714D28C9F588DD69353 /* SecureBackupScreenViewModelProtocol.swift */; }; AD2A81B65A9F6163012086F1 /* MXLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 111B698739E3410E2CDB7144 /* MXLog.swift */; }; AD55E245FE686D7DB4C86406 /* RoomTimelineItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F2F8998E5632668B0AD848 /* RoomTimelineItemView.swift */; }; + ADC820847A91C9939E269B24 /* TrackedUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */; }; AE066FC93E7B707C826B335A /* AuthenticationClientFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBD19057FDB154A44335CE62 /* AuthenticationClientFactory.swift */; }; AE07F215EBC2B9CBF17AA54B /* TimelineItemMenuAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F1C3CBBC62C566DDF5E84C1 /* TimelineItemMenuAction.swift */; }; AE1160076F663BF14E0E893A /* EffectsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4548A9BDE5CB3AB864BCA9F /* EffectsView.swift */; }; @@ -1232,6 +1239,7 @@ CD6A72B65D3B6076F4045C30 /* PHGPostHogConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = A6B891A6DA826E2461DBB40F /* PHGPostHogConfiguration.swift */; }; CDAE3A37D4DF136F9D07DB61 /* RoomChangeRolesScreenSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF710CB1C31F8938EAA3A7D /* RoomChangeRolesScreenSection.swift */; }; CDCA8A559E098503DDE29477 /* AttributedStringBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A5C6FBF97B6EED3D4FA5EFF /* AttributedStringBuilder.swift */; }; + CDD76A7D42E1B47F7E423AA8 /* VolatileUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */; }; CE1694C7BB93C3311524EF28 /* Untranslated.strings in Resources */ = {isa = PBXBuildFile; fileRef = D2F7194F440375338F8E2487 /* Untranslated.strings */; }; CE23FE7F463AD5C7D80353AA /* RoomThreadListScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 008D864B3F51B41DF483B860 /* RoomThreadListScreenViewModelProtocol.swift */; }; CE3B7FC34FB2C279AAA5EA01 /* AVMetadataMachineReadableCodeObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3339B1DDB1341E833D2555BC /* AVMetadataMachineReadableCodeObject.swift */; }; @@ -1394,6 +1402,7 @@ E9D2ED1C4186931E3D5FDA4E /* QRCodeLoginScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 718D8767035D37E2DB5CC550 /* QRCodeLoginScreenViewModelProtocol.swift */; }; EA01A06EEDFEF4AE7652E5F3 /* NSRegularExpresion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BAC0F6C9644336E9567EE6 /* NSRegularExpresion.swift */; }; EA2FECCD9E00D9784AC6017D /* PhishingDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB07F03461023BC39C730922 /* PhishingDetector.swift */; }; + EA4848108A6FE53A4085C9B1 /* VolatileUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */; }; EA6613B29BA671F39CE1B1D2 /* ConfirmationDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = B383DCD3DCB19E00FD478A5F /* ConfirmationDialog.swift */; }; EA78A7512AFB1E5451744EB1 /* AppRouteURLParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E461B3C8BBBFCA400B268D14 /* AppRouteURLParserTests.swift */; }; EA8D941771E762A5D3D7FA0D /* FileMediaEventsTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430C73079A84654BF46A7FF5 /* FileMediaEventsTimelineView.swift */; }; @@ -1700,6 +1709,7 @@ 0C3E9684DCE6B66BD0B5DF67 /* ReportRoomScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportRoomScreenViewModelTests.swift; sourceTree = ""; }; 0C62E07C1164F5120727A2A8 /* AppLockSetupBiometricsScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockSetupBiometricsScreenCoordinator.swift; sourceTree = ""; }; 0CB569EAA5017B5B23970655 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; + 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsProtocol.swift; sourceTree = ""; }; 0CCC6C31102E1D8B9106DEDE /* AppLockSetupBiometricsScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockSetupBiometricsScreenViewModelProtocol.swift; sourceTree = ""; }; 0D0B159AFFBBD8ECFD0E37FA /* LoginScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreenModels.swift; sourceTree = ""; }; 0D432771B389EC486E7F90C6 /* CreateRoomScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRoomScreenModels.swift; sourceTree = ""; }; @@ -1724,6 +1734,7 @@ 1059E2AE7878CF7820592637 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 105B2A8426404EF66F00CFDB /* RoomTimelineItemFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineItemFactory.swift; sourceTree = ""; }; 10CC626F97AD70FF0420C115 /* RoomSummaryProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomSummaryProviderProtocol.swift; sourceTree = ""; }; + 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackedUserDefaults.swift; sourceTree = ""; }; 10F130DF775CE6BC51A4E392 /* AppLockSetupBiometricsScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLockSetupBiometricsScreenModels.swift; sourceTree = ""; }; 10F32E0B4B83D2A11EE8D011 /* InviteUsersScreenSelectedItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InviteUsersScreenSelectedItem.swift; sourceTree = ""; }; 11151E78D6BB2B04A8FBD389 /* EmojiPickerScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPickerScreenViewModelProtocol.swift; sourceTree = ""; }; @@ -3007,6 +3018,7 @@ F2B94F1B0B5D9D42B15AA6E8 /* ChatsTabFlowCoordinatorStateMachine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsTabFlowCoordinatorStateMachine.swift; sourceTree = ""; }; F2DC502B1A566E99969D34DD /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/InfoPlist.strings; sourceTree = ""; }; F2E4EF80DFB8FE7C4469B15D /* RoomDirectorySearchScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDirectorySearchScreen.swift; sourceTree = ""; }; + F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VolatileUserDefaults.swift; sourceTree = ""; }; F3082001D373607455CB08A1 /* QRCodeErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeErrorView.swift; sourceTree = ""; }; F31F59030205A6F65B057E1A /* MatrixEntityRegexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatrixEntityRegexTests.swift; sourceTree = ""; }; F320003F490B11F808ECC5E9 /* JoinedMembersBadgeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinedMembersBadgeView.swift; sourceTree = ""; }; @@ -6558,7 +6570,10 @@ 8FC598338E7CF41107293AB5 /* RageshakeConfiguration.swift */, 69A05E85E4872C3221C5C287 /* RemotePreference.swift */, A5DA892E8643240C7BC41900 /* RoomListActivityVisibility.swift */, + 10D751743B20B314D84D79FE /* TrackedUserDefaults.swift */, + 0CCA4547BE58E17899E95CDE /* UserDefaultsProtocol.swift */, 5E6DE144D887A254F4CAF203 /* UserPreference.swift */, + F2F56C9FFE8D55375CED9741 /* VolatileUserDefaults.swift */, ); path = Settings; sourceTree = ""; @@ -7865,12 +7880,15 @@ AC3C3D6D4AD31F13EE987390 /* TraceLogPack.swift in Sources */, B81840E45D8746A4692DA774 /* Tracing.swift in Sources */, 2D45A04699BB6BA3B3A0CB9A /* TracingHook.swift in Sources */, + 6BEB10499149444909EBE42F /* TrackedUserDefaults.swift in Sources */, 45D6DC594816288983627484 /* UITestsScreenIdentifier.swift in Sources */, 281BED345D59A9A6A99E9D98 /* UNNotificationContent.swift in Sources */, 06B55882911B4BF5B14E9851 /* URL.swift in Sources */, D98B5EE8C4F5A2CE84687AE8 /* UTType.swift in Sources */, 34357B287357BC0B9715DD51 /* UserAgentBuilder.swift in Sources */, + 1B1404DD4BB2C5079B074210 /* UserDefaultsProtocol.swift in Sources */, 683154AD739245E56F37921E /* UserPreference.swift in Sources */, + 28A494A66D0F21EC1EC4EB11 /* VolatileUserDefaults.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8075,10 +8093,13 @@ A5FD8284744E2FECFC842FC1 /* TraceLogPack.swift in Sources */, 89DF67AECBF9D0EE0DDB7737 /* Tracing.swift in Sources */, 51263FC33CC961A14F5D6BCA /* TracingHook.swift in Sources */, + 9331608392D42EF465A8E710 /* TrackedUserDefaults.swift in Sources */, 03BD83E8BDD23AE059802E0D /* UITestsScreenIdentifier.swift in Sources */, 26252AA9AED64010788F4C26 /* UIView.swift in Sources */, 66E9202BED03B5BB00E812A1 /* URL.swift in Sources */, + 29E411E37D3FBF3899B3ED69 /* UserDefaultsProtocol.swift in Sources */, EF79B9EFD094C17FBB4942C2 /* UserPreference.swift in Sources */, + CDD76A7D42E1B47F7E423AA8 /* VolatileUserDefaults.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -9096,6 +9117,7 @@ 6E44638FDF7D4B0F80EFA7EA /* TraceLogPack.swift in Sources */, 126CBCF5B0145FA1377C1316 /* Tracing.swift in Sources */, E010DDE938032D3B8E84CC35 /* TracingHook.swift in Sources */, + ADC820847A91C9939E269B24 /* TrackedUserDefaults.swift in Sources */, 298F9EC30E918F12AB7F1EE8 /* TypingIndicatorView.swift in Sources */, 36AC963F2F04069B7FF1AA0C /* UIConstants.swift in Sources */, A37EED79941AD3B7140B3822 /* UIDevice.swift in Sources */, @@ -9113,6 +9135,7 @@ 34C752A73717C691582DC6C7 /* UnsupportedRoomTimelineItem.swift in Sources */, D8459AAD6969B1431ECBE990 /* UnsupportedRoomTimelineView.swift in Sources */, 7A71AEF419904209BB8C2833 /* UserAgentBuilder.swift in Sources */, + 8CFB8BB99F25FA34B6C6BE86 /* UserDefaultsProtocol.swift in Sources */, 7D58B4F46CAA9A7C3E4C6A30 /* UserDetailsEditScreen.swift in Sources */, A64B52D9F73F9A6B95AF24FE /* UserDetailsEditScreenCoordinator.swift in Sources */, 3982C505960006B341CFD0C6 /* UserDetailsEditScreenModels.swift in Sources */, @@ -9174,6 +9197,7 @@ 024E70451A7CD9E4E034D8A9 /* VoiceMessageRoomTimelineItem.swift in Sources */, 1224084B7E289E0830BA2C54 /* VoiceMessageRoomTimelineView.swift in Sources */, 1CA094038D4D036A6F0A1314 /* VoiceMessageTrashButton.swift in Sources */, + EA4848108A6FE53A4085C9B1 /* VolatileUserDefaults.swift in Sources */, CA12AE0DCD57D49CD96C699A /* WaveformCursorView.swift in Sources */, 63CDC201A5980F304F6D0A1C /* WaveformInteractionModifier.swift in Sources */, B773ACD8881DB18E876D950C /* WaveformSource.swift in Sources */, diff --git a/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift b/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift index f29ca3c7d..07cd18c9f 100644 --- a/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift +++ b/ElementX/Sources/AccessibilityTests/AccessibilityTestsAppCoordinator.swift @@ -40,8 +40,7 @@ class AccessibilityTestsAppCoordinator: AppCoordinatorProtocol { MXLog.configure(currentTarget: "accessibility-tests") - AppSettings.configureWithSuiteName("io.element.elementx.accessibilitytests") - AppSettings.resetAllSettings() + let appSettings = AppSettings.volatile() guard let name = ProcessInfo.accessibilityViewID, let previewType = TestablePreviewsDictionary.dictionary[name] else { diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index 201dcef5a..c4cdf9ac8 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -78,7 +78,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg let networkMonitor = NetworkMonitor() appMediator = AppMediator(windowManager: windowManager, networkMonitor: networkMonitor) - let appSettings = appHooks.appSettingsHook.configure(AppSettings()) + guard let userDefaults = TrackedUserDefaults(suiteName: AppSettings.suiteName) else { + fatalError("Catastrophic error retrieving user defaults for \(AppSettings.suiteName)") + } + let appSettings = appHooks.appSettingsHook.configure(AppSettings(store: userDefaults)) self.appSettings = appSettings targetConfiguration = Target.mainApp.configure(logLevel: appSettings.logLevel, @@ -93,7 +96,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg MXLog.info("\(appName) \(appVersion) (\(appBuild))") if ProcessInfo.processInfo.environment["RESET_APP_SETTINGS"].map(Bool.init) == true { - AppSettings.resetAllSettings() + appSettings.resetAllSettings() } self.appDelegate = appDelegate @@ -544,7 +547,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg /// - Parameter includingSettings: Whether to additionally wipe the user's app settings too. private func wipeUserData(includingSettings: Bool = false) { if includingSettings { - AppSettings.resetAllSettings() + appSettings.resetAllSettings() appLockFlowCoordinator.appLockService.disable() } userSessionStore.reset() @@ -830,7 +833,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg userSessionStore.logout(userSession: userSession) tearDownUserSession() - AppSettings.resetSessionSpecificSettings() + appSettings.resetSessionSpecificSettings() appHooks.remoteSettingsHook.reset(appSettings) // Reset analytics diff --git a/ElementX/Sources/Application/Settings/AppSettings.swift b/ElementX/Sources/Application/Settings/AppSettings.swift index 9f2575b04..b8154807b 100644 --- a/ElementX/Sources/Application/Settings/AppSettings.swift +++ b/ElementX/Sources/Application/Settings/AppSettings.swift @@ -37,7 +37,7 @@ enum AppBuildType { /// /// State is persisted in `UserDefaults`, which is thread-safe per Apple's documentation, hence `@unchecked`. final class AppSettings: @unchecked Sendable { - private enum UserDefaultsKeys: String { + fileprivate enum UserDefaultsKeys: String, PreferenceKeyable { case lastVersionLaunched case seenInvites case hasSeenNewSoundBanner @@ -94,10 +94,10 @@ final class AppSettings: @unchecked Sendable { case developerOptionsEnabled } - private nonisolated(unsafe) static var suiteName: String = InfoPlistReader.main.appGroupIdentifier + static let suiteName: String = InfoPlistReader.main.appGroupIdentifier - /// UserDefaults to be used on reads and writes. `UserDefaults` is thread-safe per Apple's documentation. - private nonisolated(unsafe) static var store: UserDefaults! = UserDefaults(suiteName: suiteName) + /// UserDefaults to be used on reads and writes. + private let store: UserDefaultsProtocol static var appBuildType: AppBuildType { #if DEBUG @@ -112,26 +112,16 @@ final class AppSettings: @unchecked Sendable { #endif } - static func resetAllSettings() { + func resetAllSettings() { MXLog.warning("Resetting the AppSettings.") - store.removePersistentDomain(forName: suiteName) + store.reset() } - static func resetSessionSpecificSettings() { + func resetSessionSpecificSettings() { MXLog.warning("Resetting the user session specific AppSettings.") store.removeObject(forKey: UserDefaultsKeys.hasRunIdentityConfirmationOnboarding.rawValue) } - static func configureWithSuiteName(_ name: String) { - suiteName = name - - guard let userDefaults = UserDefaults(suiteName: name) else { - fatalError("Fail to load shared UserDefaults") - } - - store = userDefaults - } - // MARK: - Hooks // swiftlint:disable:next function_parameter_count @@ -182,17 +172,17 @@ final class AppSettings: @unchecked Sendable { /// The last known version of the app that was launched on this device, which is /// used to detect when migrations should be run. When `nil` the app may have been /// deleted between runs so should clear data in the shared container and keychain. - @UserPreference(key: UserDefaultsKeys.lastVersionLaunched, storageType: .userDefaults(store)) + @UserPreference var lastVersionLaunched: String? /// The Set of room identifiers of invites that the user already saw in the invites list. /// This Set is being used to implement badges for unread invites. - @UserPreference(key: UserDefaultsKeys.seenInvites, defaultValue: [], storageType: .userDefaults(store)) + @UserPreference var seenInvites: Set /// Defaults to `true` for new users, and we use a migration to set it to `false` for existing users. - @UserPreference(key: UserDefaultsKeys.hasSeenNewSoundBanner, defaultValue: true, storageType: .userDefaults(store)) - var hasSeenNewSoundBanner + @UserPreference + var hasSeenNewSoundBanner: Bool /// The initial set of account providers shown to the user in the authentication flow. /// @@ -236,7 +226,7 @@ final class AppSettings: @unchecked Sendable { /// **Note:** This property isn't overridable as it in unexpected for forks to come across the error (or to even have a "Pro" app). let elementProAppStoreURL: URL = "https://apps.apple.com/app/element-pro-for-work/id6502951615" - @UserPreference(key: UserDefaultsKeys.appAppearance, defaultValue: .system, storageType: .userDefaults(store)) + @UserPreference var appAppearance: AppAppearance // MARK: - Security @@ -248,7 +238,7 @@ final class AppSettings: @unchecked Sendable { /// Any codes that the user isn't allowed to use for their PIN. let appLockPINCodeBlockList = ["0000", "1234"] /// The number of attempts the user has made to unlock the app with a PIN code (resets when unlocked). - @UserPreference(key: UserDefaultsKeys.appLockNumberOfPINAttempts, defaultValue: 0, storageType: .userDefaults(store)) + @UserPreference var appLockNumberOfPINAttempts: Int // MARK: - Authentication @@ -287,33 +277,33 @@ final class AppSettings: @unchecked Sendable { pushGatewayBaseURL.appending(path: "_matrix/push/v1/notify") } - @UserPreference(key: UserDefaultsKeys.enableNotifications, defaultValue: true, storageType: .userDefaults(store)) - var enableNotifications + @UserPreference + var enableNotifications: Bool - @UserPreference(key: UserDefaultsKeys.enableInAppNotifications, defaultValue: true, storageType: .userDefaults(store)) - var enableInAppNotifications + @UserPreference + var enableInAppNotifications: Bool - @UserPreference(key: UserDefaultsKeys.hideQuietNotificationAlerts, defaultValue: false, storageType: .userDefaults(store)) - var hideQuietNotificationAlerts + @UserPreference + var hideQuietNotificationAlerts: Bool /// Tag describing which set of device specific rules a pusher executes. - @UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store)) + @UserPreference var pusherProfileTag: String? /// The device's last boot time as recorded by the NSE. - @UserPreference(key: UserDefaultsKeys.lastNotificationBootTime, storageType: .userDefaults(store)) + @UserPreference var lastNotificationBootTime: TimeInterval? /// The sound played when delivering noisy notifications. If nil, use the ElementX default - @UserPreference(key: UserDefaultsKeys.selectedNotificationTone, defaultValue: nil, storageType: .userDefaults(store)) + @UserPreference var selectedNotificationTone: NotificationTone? // MARK: - Logging - @UserPreference(key: UserDefaultsKeys.logLevel, defaultValue: LogLevel.info, storageType: .userDefaults(store)) - var logLevel + @UserPreference + var logLevel: LogLevel - @UserPreference(key: UserDefaultsKeys.traceLogPacks, defaultValue: [], storageType: .userDefaults(store)) + @UserPreference var traceLogPacks: Set // MARK: - Bug report @@ -341,46 +331,46 @@ final class AppSettings: @unchecked Sendable { } /// Whether the user has opted in to send analytics. - @UserPreference(key: UserDefaultsKeys.analyticsConsentState, defaultValue: AnalyticsConsentState.unknown, storageType: .userDefaults(store)) - var analyticsConsentState + @UserPreference + var analyticsConsentState: AnalyticsConsentState - @UserPreference(key: UserDefaultsKeys.hasRunNotificationPermissionsOnboarding, defaultValue: false, storageType: .userDefaults(store)) - var hasRunNotificationPermissionsOnboarding + @UserPreference + var hasRunNotificationPermissionsOnboarding: Bool - @UserPreference(key: UserDefaultsKeys.hasRunIdentityConfirmationOnboarding, defaultValue: false, storageType: .userDefaults(store)) - var hasRunIdentityConfirmationOnboarding + @UserPreference + var hasRunIdentityConfirmationOnboarding: Bool - @UserPreference(key: UserDefaultsKeys.hasRequestedLocationAlwaysLocationAuthorization, defaultValue: false, storageType: .userDefaults(store)) - var hasRequestedLocationAlwaysLocationAuthorization + @UserPreference + var hasRequestedLocationAlwaysLocationAuthorization: Bool - @UserPreference(key: UserDefaultsKeys.frequentlyUsedSystemEmojis, defaultValue: [FrequentlyUsedEmoji](), storageType: .userDefaults(store)) - var frequentlyUsedSystemEmojis + @UserPreference + var frequentlyUsedSystemEmojis: [FrequentlyUsedEmoji] // MARK: - Live Location - @UserPreference(key: UserDefaultsKeys.liveLocationSharingTimeoutDatesByRoomID, defaultValue: [String: LiveLocationSession](), storageType: .userDefaults(store)) - var liveLocationSharingSessionsByRoomID + @UserPreference + var liveLocationSharingSessionsByRoomID: [String: LiveLocationSession] - @UserPreference(key: UserDefaultsKeys.liveLocationMinimumDistanceUpdate, defaultValue: 10, storageType: .userDefaults(store)) - var liveLocationMinimumDistanceUpdate + @UserPreference + var liveLocationMinimumDistanceUpdate: Int - @UserPreference(key: UserDefaultsKeys.liveLocationDisclaimerDisplayed, defaultValue: false, storageType: .userDefaults(store)) - var liveLocationDisclaimerDisplayed + @UserPreference + var liveLocationDisclaimerDisplayed: Bool // MARK: - Home Screen - @UserPreference(key: UserDefaultsKeys.roomListActivityVisibility, defaultValue: .current, storageType: .userDefaults(store)) + @UserPreference var roomListActivityVisibility: RoomListActivityVisibility // MARK: - Room Screen - @UserPreference(key: UserDefaultsKeys.viewSourceEnabled, defaultValue: appBuildType == .debug, storageType: .userDefaults(store)) - var viewSourceEnabled + @UserPreference + var viewSourceEnabled: Bool - @UserPreference(key: UserDefaultsKeys.optimizeMediaUploads, defaultValue: true, storageType: .userDefaults(store)) - var optimizeMediaUploads + @UserPreference + var optimizeMediaUploads: Bool - @UserPreference(key: UserDefaultsKeys.voiceMessagePlaybackSpeed, defaultValue: AudioPlaybackSpeed.default, storageType: .userDefaults(store)) + @UserPreference var voiceMessagePlaybackSpeed: AudioPlaybackSpeed /// Whether or not to show a warning on the media caption composer so the user knows @@ -399,7 +389,7 @@ final class AppSettings: @unchecked Sendable { let elementCallPosthogAPIKey = "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU" let elementCallPosthogSentryDSN = "https://3bd2f95ba5554d4497da7153b552ffb5@sentry.tools.element.io/41" - @UserPreference(key: UserDefaultsKeys.elementCallBaseURLOverride, defaultValue: nil, storageType: .userDefaults(store)) + @UserPreference var elementCallBaseURLOverride: URL? // MARK: - Users @@ -417,51 +407,111 @@ final class AppSettings: @unchecked Sendable { // MARK: - Presence - @UserPreference(key: UserDefaultsKeys.sharePresence, defaultValue: true, storageType: .userDefaults(store)) - var sharePresence + @UserPreference + var sharePresence: Bool // MARK: - Feature Flags /// Others - @UserPreference(key: UserDefaultsKeys.fuzzyRoomListSearchEnabled, defaultValue: false, storageType: .userDefaults(store)) - var fuzzyRoomListSearchEnabled + @UserPreference + var fuzzyRoomListSearchEnabled: Bool - @UserPreference(key: UserDefaultsKeys.lowPriorityFilterEnabled, defaultValue: false, storageType: .userDefaults(store)) - var lowPriorityFilterEnabled + @UserPreference + var lowPriorityFilterEnabled: Bool /// Configuration to enable only signed device isolation mode for crypto. In this mode only devices signed by their owner will be considered in e2ee rooms. - @UserPreference(key: UserDefaultsKeys.enableOnlySignedDeviceIsolationMode, defaultValue: false, storageType: .userDefaults(store)) - var enableOnlySignedDeviceIsolationMode + @UserPreference + var enableOnlySignedDeviceIsolationMode: Bool - @UserPreference(key: UserDefaultsKeys.knockingEnabled, defaultValue: false, storageType: .userDefaults(store)) - var knockingEnabled + @UserPreference + var knockingEnabled: Bool - @UserPreference(key: UserDefaultsKeys.threadsEnabled, defaultValue: false, storageType: .userDefaults(store)) - var threadsEnabled + @UserPreference + var threadsEnabled: Bool - @UserPreference(key: UserDefaultsKeys.roomThreadListEnabled, defaultValue: false, storageType: .userDefaults(store)) - var roomThreadListEnabled + @UserPreference + var roomThreadListEnabled: Bool - @UserPreference(key: UserDefaultsKeys.focusEventOnNotificationTap, defaultValue: false, storageType: .userDefaults(store)) - var focusEventOnNotificationTap + @UserPreference + var focusEventOnNotificationTap: Bool - @UserPreference(key: UserDefaultsKeys.linkPreviewsEnabled, defaultValue: false, storageType: .userDefaults(store)) - var linkPreviewsEnabled + @UserPreference + var linkPreviewsEnabled: Bool + + @UserPreference + var jumpToReadMarkerEnabled: Bool - @UserPreference(key: UserDefaultsKeys.jumpToReadMarkerEnabled, defaultValue: false, storageType: .userDefaults(store)) - var jumpToReadMarkerEnabled - - @UserPreference(key: UserDefaultsKeys.linkNewDeviceEnabled, defaultValue: false, storageType: .userDefaults(store)) - var linkNewDeviceEnabled + @UserPreference + var linkNewDeviceEnabled: Bool - @UserPreference(key: UserDefaultsKeys.automaticBackPaginationEnabled, defaultValue: false, storageType: .userDefaults(store)) - var automaticBackPaginationEnabled + @UserPreference + var automaticBackPaginationEnabled: Bool - @UserPreference(key: UserDefaultsKeys.clientPausingAndResumingEnabled, defaultValue: appBuildType != .release, storageType: .volatile) - var clientPausingAndResumingEnabled + @UserPreference + var clientPausingAndResumingEnabled: Bool - @UserPreference(key: UserDefaultsKeys.developerOptionsEnabled, defaultValue: appBuildType != .release, storageType: .userDefaults(store)) - var developerOptionsEnabled + @UserPreference + var developerOptionsEnabled: Bool + + init(store: UserDefaultsProtocol) { + // UserDefaults to be used on reads and writes. + self.store = store + + _lastVersionLaunched = UserPreference(key: .lastVersionLaunched, storage: store) + _seenInvites = UserPreference(key: .seenInvites, defaultValue: [], storage: store) + _hasSeenNewSoundBanner = UserPreference(key: .hasSeenNewSoundBanner, defaultValue: true, storage: store) + _appAppearance = UserPreference(key: .appAppearance, defaultValue: .system, storage: store) + _appLockNumberOfPINAttempts = UserPreference(key: .appLockNumberOfPINAttempts, defaultValue: 0, storage: store) + _enableNotifications = UserPreference(key: .enableNotifications, defaultValue: true, storage: store) + _enableInAppNotifications = UserPreference(key: .enableInAppNotifications, defaultValue: true, storage: store) + _hideQuietNotificationAlerts = UserPreference(key: .hideQuietNotificationAlerts, defaultValue: false, storage: store) + _pusherProfileTag = UserPreference(key: .pusherProfileTag, storage: store) + _lastNotificationBootTime = UserPreference(key: .lastNotificationBootTime, storage: store) + _selectedNotificationTone = UserPreference(key: .selectedNotificationTone, storage: store) + _logLevel = UserPreference(key: .logLevel, defaultValue: LogLevel.info, storage: store) + _traceLogPacks = UserPreference(key: .traceLogPacks, defaultValue: [], storage: store) + _analyticsConsentState = UserPreference(key: .analyticsConsentState, defaultValue: AnalyticsConsentState.unknown, storage: store) + _hasRunNotificationPermissionsOnboarding = UserPreference(key: .hasRunNotificationPermissionsOnboarding, defaultValue: false, storage: store) + _hasRunIdentityConfirmationOnboarding = UserPreference(key: .hasRunIdentityConfirmationOnboarding, defaultValue: false, storage: store) + _hasRequestedLocationAlwaysLocationAuthorization = UserPreference(key: .hasRequestedLocationAlwaysLocationAuthorization, defaultValue: false, storage: store) + _frequentlyUsedSystemEmojis = UserPreference(key: .frequentlyUsedSystemEmojis, defaultValue: [FrequentlyUsedEmoji](), storage: store) + _liveLocationSharingSessionsByRoomID = UserPreference(key: .liveLocationSharingTimeoutDatesByRoomID, defaultValue: [String: LiveLocationSession](), storage: store) + _liveLocationMinimumDistanceUpdate = UserPreference(key: .liveLocationMinimumDistanceUpdate, defaultValue: 10, storage: store) + _liveLocationDisclaimerDisplayed = UserPreference(key: .liveLocationDisclaimerDisplayed, defaultValue: false, storage: store) + _roomListActivityVisibility = UserPreference(key: .roomListActivityVisibility, defaultValue: .current, storage: store) + _viewSourceEnabled = UserPreference(key: .viewSourceEnabled, defaultValue: Self.appBuildType == .debug, storage: store) + _optimizeMediaUploads = UserPreference(key: .optimizeMediaUploads, defaultValue: true, storage: store) + _voiceMessagePlaybackSpeed = UserPreference(key: .voiceMessagePlaybackSpeed, defaultValue: AudioPlaybackSpeed.default, storage: store) + _elementCallBaseURLOverride = UserPreference(key: .elementCallBaseURLOverride, defaultValue: nil, storage: store) + _sharePresence = UserPreference(key: .sharePresence, defaultValue: true, storage: store) + _fuzzyRoomListSearchEnabled = UserPreference(key: .fuzzyRoomListSearchEnabled, defaultValue: false, storage: store) + _lowPriorityFilterEnabled = UserPreference(key: .lowPriorityFilterEnabled, defaultValue: false, storage: store) + _enableOnlySignedDeviceIsolationMode = UserPreference(key: .enableOnlySignedDeviceIsolationMode, defaultValue: false, storage: store) + _knockingEnabled = UserPreference(key: .knockingEnabled, defaultValue: false, storage: store) + _threadsEnabled = UserPreference(key: .threadsEnabled, defaultValue: false, storage: store) + _roomThreadListEnabled = UserPreference(key: .roomThreadListEnabled, defaultValue: false, storage: store) + _focusEventOnNotificationTap = UserPreference(key: .focusEventOnNotificationTap, defaultValue: false, storage: store) + _linkPreviewsEnabled = UserPreference(key: .linkPreviewsEnabled, defaultValue: false, storage: store) + _jumpToReadMarkerEnabled = UserPreference(key: .jumpToReadMarkerEnabled, defaultValue: false, storage: store) + _linkNewDeviceEnabled = UserPreference(key: .linkNewDeviceEnabled, defaultValue: false, storage: store) + _automaticBackPaginationEnabled = UserPreference(key: .automaticBackPaginationEnabled, defaultValue: false, storage: store) + _clientPausingAndResumingEnabled = UserPreference(key: .clientPausingAndResumingEnabled, defaultValue: Self.appBuildType != .release, storage: VolatileUserDefaults()) + _developerOptionsEnabled = UserPreference(key: .developerOptionsEnabled, defaultValue: Self.appBuildType != .release, storage: store) + } + + static func volatile() -> AppSettings { + AppSettings(store: VolatileUserDefaults()) + } } extension AppSettings: CommonSettingsProtocol { } + +private extension UserPreference { + convenience init(key: AppSettings.UserDefaultsKeys, defaultValue: T, storage backingStorage: UserDefaultsProtocol, mode: Mode = .localOverRemote) { + self.init(key: key as any PreferenceKeyable, defaultValue: defaultValue, storage: backingStorage, mode: mode) + } + + convenience init(key: AppSettings.UserDefaultsKeys, storage: UserDefaultsProtocol, mode: Mode = .localOverRemote) where T: ExpressibleByNilLiteral { + self.init(key: key as any PreferenceKeyable, defaultValue: nil, storage: storage, mode: mode) + } +} diff --git a/ElementX/Sources/Application/Settings/TrackedUserDefaults.swift b/ElementX/Sources/Application/Settings/TrackedUserDefaults.swift new file mode 100644 index 000000000..2d222fb5d --- /dev/null +++ b/ElementX/Sources/Application/Settings/TrackedUserDefaults.swift @@ -0,0 +1,50 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Foundation + +final class TrackedUserDefaults: UserDefaults, UserDefaultsProtocol { + private let lock = NSLock() + + private nonisolated(unsafe) var _trackedSuites: [String] = [] + private(set) var trackedSuites: [String] { + get { lock.withLock { _trackedSuites } } + set { lock.withLock { _trackedSuites = newValue } } + } + + override init?(suiteName suitename: String?) { + if let suitename { + lock.lock() + _trackedSuites = [suitename] + lock.unlock() + } + + super.init(suiteName: suitename) + } + + override func addSuite(named suiteName: String) { + trackedSuites.append(suiteName) + super.addSuite(named: suiteName) + } + + override func removeSuite(named suiteName: String) { + trackedSuites.removeAll { $0 == suiteName } + super.removeSuite(named: suiteName) + } + + func resetRegisteredDomains() { + lock.withLock { + for suite in _trackedSuites { + removePersistentDomain(forName: suite) + } + } + } + + func reset() { + resetRegisteredDomains() + } +} diff --git a/ElementX/Sources/Application/Settings/UserDefaultsProtocol.swift b/ElementX/Sources/Application/Settings/UserDefaultsProtocol.swift new file mode 100644 index 000000000..35a4b0763 --- /dev/null +++ b/ElementX/Sources/Application/Settings/UserDefaultsProtocol.swift @@ -0,0 +1,18 @@ +// +// Copyright 2025 Element Creations Ltd. +// Copyright 2022-2025 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Foundation + +public protocol UserDefaultsProtocol: AnyObject { + func data(forKey key: String) -> Data? + func object(forKey key: String) -> Any? + func removeObject(forKey key: String) + func set(_ value: Any?, forKey key: String) + + func reset() +} diff --git a/ElementX/Sources/Application/Settings/UserPreference.swift b/ElementX/Sources/Application/Settings/UserPreference.swift index 87a1d9a2a..51a065b7d 100644 --- a/ElementX/Sources/Application/Settings/UserPreference.swift +++ b/ElementX/Sources/Application/Settings/UserPreference.swift @@ -46,11 +46,11 @@ final class UserPreference { /// - defaultValue: The default value to use if no stored value exists or if `forceDefault` is `true`. /// - keyedStorage: The storage instance where the value is saved. /// - forceDefault: A publisher that determines whether the default value should always be used. Defaults to publish `false`. Useful in the context of remote settings that need to override the local value. - init(key: String, + init(key: any PreferenceKeyable, defaultValue: T, keyedStorage: any KeyedStorage, mode: Mode) { - self.key = key + self.key = key.rawValue self.defaultValue = defaultValue self.keyedStorage = keyedStorage self.mode = mode @@ -95,37 +95,21 @@ final class UserPreference { // MARK: - UserPreference convenience initializers extension UserPreference { - enum StorageType { - case userDefaults(UserDefaults) - case volatile - } - - convenience init(key: String, defaultValue: T, storageType: StorageType, mode: Mode = .localOverRemote) { - let storage: any KeyedStorage - - switch storageType { - case .userDefaults(let userDefaults): - storage = UserDefaultsStorage(userDefaults: userDefaults) - case .volatile: - storage = [String: T]() - } - + convenience init(key: any PreferenceKeyable, defaultValue: T, storage backingStorage: UserDefaultsProtocol, mode: Mode = .localOverRemote) { + let storage: any KeyedStorage = UserDefaultsStorage(userDefaults: backingStorage) + self.init(key: key, defaultValue: defaultValue, keyedStorage: storage, mode: mode) } - convenience init(key: R, defaultValue: T, storageType: StorageType, mode: Mode = .localOverRemote) where R.RawValue == String { - self.init(key: key.rawValue, defaultValue: defaultValue, storageType: storageType, mode: mode) - } - - convenience init(key: String, storageType: StorageType, mode: Mode = .localOverRemote) where T: ExpressibleByNilLiteral { - self.init(key: key, defaultValue: nil, storageType: storageType, mode: mode) - } - - convenience init(key: R, storageType: StorageType, mode: Mode = .localOverRemote) where R: RawRepresentable, R.RawValue == String, T: ExpressibleByNilLiteral { - self.init(key: key.rawValue, storageType: storageType, mode: mode) + convenience init(key: any PreferenceKeyable, storage: UserDefaultsProtocol, mode: Mode = .localOverRemote) where T: ExpressibleByNilLiteral { + self.init(key: key, defaultValue: nil, storage: storage, mode: mode) } } +// MARK: - Keys + +protocol PreferenceKeyable: RawRepresentable where RawValue == String { } + // MARK: - Storage protocol KeyedStorage { @@ -139,9 +123,9 @@ protocol KeyedStorage { /// When used with a `Value` that conforms to `PlistRepresentable` the Codable encode/decode /// phase is skipped, and values are stored natively in the plist. final class UserDefaultsStorage: KeyedStorage { - private let userDefaults: UserDefaults + private let userDefaults: UserDefaultsProtocol - init(userDefaults: UserDefaults) { + init(userDefaults: UserDefaultsProtocol) { self.userDefaults = userDefaults } @@ -183,7 +167,7 @@ final class UserDefaultsStorage: KeyedStorage { userDefaults.removeObject(forKey: key) } else { let encodedValue = try? JSONEncoder().encode(value) - userDefaults.setValue(encodedValue, forKey: key) + userDefaults.set(encodedValue, forKey: key) } } diff --git a/ElementX/Sources/Application/Settings/VolatileUserDefaults.swift b/ElementX/Sources/Application/Settings/VolatileUserDefaults.swift new file mode 100644 index 000000000..73adbe42c --- /dev/null +++ b/ElementX/Sources/Application/Settings/VolatileUserDefaults.swift @@ -0,0 +1,45 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. +// Please see LICENSE files in the repository root for full details. +// + +import Foundation + +public final class VolatileUserDefaults: UserDefaultsProtocol, Sendable { + private let lock = NSLock() + + private nonisolated(unsafe) var _storage: [String: Any] + public private(set) var storage: [String: Any] { + get { lock.withLock { _storage } } + set { lock.withLock { _storage = newValue } } + } + + public init(initialValues: [String: Any] = [:]) { + lock.lock() + defer { lock.unlock() } + + _storage = initialValues + } + + public func data(forKey key: String) -> Data? { + storage[key] as? Data + } + + public func object(forKey key: String) -> Any? { + storage[key] + } + + public func removeObject(forKey key: String) { + storage.removeValue(forKey: key) + } + + public func set(_ value: Any?, forKey key: String) { + storage[key] = value + } + + public func reset() { + storage = [:] + } +} diff --git a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift index 397edb2ee..d7b6d9be9 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/VisualListItem.swift @@ -56,7 +56,7 @@ private struct VisualListItemLabelStyle: LabelStyle { // MARK: - Previews struct VisualListItem_Previews: PreviewProvider, TestablePreview { - static let strings = AnalyticsPromptScreenStrings(termsURL: AppSettings().analyticsTermsURL) + static let strings = AnalyticsPromptScreenStrings(termsURL: AppSettings.volatile().analyticsTermsURL) static var testImage1: some View { Image(systemName: "circle") diff --git a/ElementX/Sources/Screens/Authentication/LoginScreen/View/LoginScreen.swift b/ElementX/Sources/Screens/Authentication/LoginScreen/View/LoginScreen.swift index a244cea7c..b29772903 100644 --- a/ElementX/Sources/Screens/Authentication/LoginScreen/View/LoginScreen.swift +++ b/ElementX/Sources/Screens/Authentication/LoginScreen/View/LoginScreen.swift @@ -161,7 +161,7 @@ struct LoginScreen_Previews: PreviewProvider, TestablePreview { let viewModel = LoginScreenViewModel(authenticationService: authenticationService, loginHint: nil, userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings(), + appSettings: .volatile(), analytics: AnalyticsServiceMock.default) if withCredentials { diff --git a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift index 284bbe85e..a34575494 100644 --- a/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Authentication/ServerConfirmationScreen/View/ServerConfirmationScreen.swift @@ -163,7 +163,7 @@ struct ServerConfirmationScreen_Previews: PreviewProvider, TestablePreview { ServerConfirmationScreenViewModel(authenticationService: AuthenticationService.mock, mode: mode, authenticationFlow: flow, - appSettings: AppSettings(), + appSettings: .volatile(), userIndicatorController: UserIndicatorControllerMock.default) } } diff --git a/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/View/ServerSelectionScreen.swift b/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/View/ServerSelectionScreen.swift index af5f32227..e72059e5a 100644 --- a/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/View/ServerSelectionScreen.swift +++ b/ElementX/Sources/Screens/Authentication/ServerSelectionScreen/View/ServerSelectionScreen.swift @@ -116,7 +116,7 @@ struct ServerSelection_Previews: PreviewProvider, TestablePreview { let viewModel = ServerSelectionScreenViewModel(authenticationService: authenticationService, authenticationFlow: .login, - appSettings: AppSettings(), + appSettings: .volatile(), userIndicatorController: UserIndicatorControllerMock.default) viewModel.context.homeserverAddress = homeserverAddress if homeserverAddress == "thisisbad" { diff --git a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationClassicAppAccountView.swift b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationClassicAppAccountView.swift index b163e5196..de053bd4a 100644 --- a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationClassicAppAccountView.swift +++ b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationClassicAppAccountView.swift @@ -151,7 +151,7 @@ struct AuthenticationClassicAppAccountView_Previews: PreviewProvider { // Not Te provisioningParameters: nil, isBugReportServiceEnabled: false, appMediator: AppMediatorMock(), - appSettings: AppSettings(), + appSettings: .volatile(), mediaProvider: MediaProviderMock(configuration: .init()), userIndicatorController: UserIndicatorControllerMock()) } diff --git a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartScreen.swift b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartScreen.swift index d85942bf1..47b799cd4 100644 --- a/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartScreen.swift +++ b/ElementX/Sources/Screens/Authentication/StartScreen/View/AuthenticationStartScreen.swift @@ -195,7 +195,7 @@ struct AuthenticationStartScreen_Previews: PreviewProvider, TestablePreview { provisioningParameters: provisionedServerName.map { .init(accountProvider: $0, loginHint: nil) }, isBugReportServiceEnabled: true, appMediator: AppMediatorMock(), - appSettings: AppSettings(), + appSettings: .volatile(), mediaProvider: MediaProviderMock(configuration: .init()), userIndicatorController: UserIndicatorControllerMock()) } diff --git a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift index d854171d7..0671a36db 100644 --- a/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift +++ b/ElementX/Sources/Screens/CallScreen/View/CallScreen.swift @@ -374,7 +374,7 @@ struct CallScreen_Previews: PreviewProvider { colorScheme: .light), allowPictureInPicture: false, appHooks: AppHooks(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default) }() diff --git a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift index cdf351248..ad17321d3 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomScreen.swift @@ -446,8 +446,7 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview { isSpace: Bool = false, selectionMode: CreateRoomScreenSpaceSelectionMode = .editableSpacesList(preSelectedSpace: nil), isAliasAvailable: Bool = true) -> CreateRoomScreenViewModel { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.knockingEnabled = isKnockingEnabled let clientProxy = ClientProxyMock(.init(userIDServerName: "example.org", diff --git a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift index 1510d92bf..ea6612a7a 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift @@ -67,7 +67,8 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: .mockJoinedSpaces2)) let userSession = UserSessionMock(.init(clientProxy: clientProxy)) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return CreateRoomScreenViewModel(isSpace: false, spaceSelectionMode: .editableSpacesList(preSelectedSpace: nil), shouldShowCancelButton: false, diff --git a/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift b/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift index df466bed1..6eebfe321 100644 --- a/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift +++ b/ElementX/Sources/Screens/EmojiPickerScreen/View/EmojiPickerScreen.swift @@ -103,7 +103,7 @@ struct EmojiPickerScreen: View { struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent, selectedEmojis: ["😀", "😄"], - emojiProvider: EmojiProvider(appSettings: AppSettings()), + emojiProvider: EmojiProvider(appSettings: .volatile()), timelineController: MockTimelineController()) static var previews: some View { @@ -116,7 +116,7 @@ struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview { struct EmojiPickerScreenSheet_Previews: PreviewProvider { static let viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent, selectedEmojis: ["😀", "😄"], - emojiProvider: EmojiProvider(appSettings: AppSettings()), + emojiProvider: EmojiProvider(appSettings: .volatile()), timelineController: MockTimelineController()) static var previews: some View { diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift index 8bfaf2278..c0bde9483 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersEmptyStateView.swift @@ -59,10 +59,10 @@ struct RoomListFiltersEmptyStateView_Previews: PreviewProvider, TestablePreview VStack(spacing: 24) { ForEach(RoomListFilter.allCases) { filter in RoomListFiltersEmptyStateView(state: .init(activeFilters: [filter], - appSettings: AppSettings())) + appSettings: .volatile())) } RoomListFiltersEmptyStateView(state: .init(activeFilters: [.people, .favourites], - appSettings: AppSettings())) + appSettings: .volatile())) } .padding(.bottom) .previewLayout(.sizeThatFits) diff --git a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift index 87f4a8fe5..bfcaeb5ba 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/Filters/RoomListFiltersView.swift @@ -90,10 +90,10 @@ struct RoomListFiltersView: View { struct RoomListFiltersView_Previews: PreviewProvider, TestablePreview { static var previews: some View { - RoomListFiltersView(state: .constant(.init(appSettings: AppSettings()))) + RoomListFiltersView(state: .constant(.init(appSettings: .volatile()))) RoomListFiltersView(state: .constant(.init(activeFilters: [.rooms, .favourites], - appSettings: AppSettings()))) + appSettings: .volatile()))) RoomListFiltersView(state: .constant(.init(activeFilters: [.lowPriority], - appSettings: AppSettings()))) + appSettings: .volatile()))) } } diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift index 28a8b3362..90e702c3f 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift @@ -224,7 +224,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift index e47564bcc..521a89121 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenEmptyStateView.swift @@ -145,7 +145,7 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview { roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))))))) return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift index 3df3c17a8..8ea9fecbc 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift @@ -202,7 +202,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift index ac66bf366..4353589d5 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift @@ -134,7 +134,7 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift index acdf59d02..b3550f876 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRecoveryKeyConfirmationBanner.swift @@ -123,7 +123,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift index fbfc33a2f..b5a854ecb 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift @@ -255,7 +255,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview { return HomeScreenViewModel(userSession: userSession, selectedRoomPublisher: CurrentValueSubject(nil).asCurrentValuePublisher(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, notificationManager: NotificationManagerMock(), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersConfirmationSheetView.swift b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersConfirmationSheetView.swift index 3f79597ae..5472f69db 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersConfirmationSheetView.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersConfirmationSheetView.swift @@ -65,7 +65,7 @@ struct InviteUsersConfirmationSheetView_Previews: PreviewProvider, TestablePrevi isSkippable: true, userDiscoveryService: UserDiscoveryServiceMock(), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) + appSettings: .volatile()) viewModel.state.usersToConfirm = [.mockAlice, .mockCharlie, .mockBob, .mockDan] diff --git a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift index 0db16105d..5ab860a3a 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift @@ -213,7 +213,7 @@ struct InviteUsersScreen_Previews: PreviewProvider, TestablePreview { isSkippable: isSkippable, userDiscoveryService: userDiscoveryService, userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) + appSettings: .volatile()) if let searchQuery { viewModel.context.searchQuery = searchQuery diff --git a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift index de95f59f0..a6eedb47f 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift @@ -403,7 +403,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable { self.isSpace = isSpace self.customPreviewName = customPreviewName - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let clientProxy = ClientProxyMock(.init(hideInviteAvatars: hideInviteAvatars)) clientProxy.canJoinRoomWithReturnValue = canJoinRoom diff --git a/ElementX/Sources/Screens/LabsScreen/View/LabsScreen.swift b/ElementX/Sources/Screens/LabsScreen/View/LabsScreen.swift index 0f6878afa..27f0d55e8 100644 --- a/ElementX/Sources/Screens/LabsScreen/View/LabsScreen.swift +++ b/ElementX/Sources/Screens/LabsScreen/View/LabsScreen.swift @@ -64,11 +64,8 @@ struct LabsScreen: View { // MARK: - Previews struct LabsScreen_Previews: PreviewProvider, TestablePreview { - static let viewModel = { - AppSettings.resetAllSettings() - return LabsScreenViewModel(labsOptions: AppSettings()) - }() - + static let viewModel = LabsScreenViewModel(labsOptions: AppSettings.volatile()) + static var previews: some View { ElementNavigationStack { LabsScreen(context: viewModel.context) diff --git a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift index 662874ad2..d8fd248da 100644 --- a/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift +++ b/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenViewModel.swift @@ -390,7 +390,7 @@ extension LocationSharingScreenViewModel { roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock return LocationSharingScreenViewModel(interactionMode: interactionMode, - mapURLBuilder: AppSettings().mapTilerConfiguration, + mapURLBuilder: AppSettings.volatile().mapTilerConfiguration, roomProxy: roomProxy, timelineController: MockTimelineController(), liveLocationManager: LiveLocationManagerMock(), diff --git a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift index 6de94c208..0b491e1cb 100644 --- a/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/MediaEventsTimelineScreen/View/MediaEventsTimelineScreen.swift @@ -310,7 +310,7 @@ struct MediaEventsTimelineScreen_Previews: PreviewProvider, TestablePreview { MockTimelineController.mediaGallery } - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")), timelineController: timelineController, userSession: UserSessionMock(.init()), diff --git a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift index d2b63518e..205e5ac9a 100644 --- a/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift +++ b/ElementX/Sources/Screens/MediaUploadPreviewScreen/View/MediaUploadPreviewScreen.swift @@ -370,7 +370,7 @@ struct MediaUploadPreviewScreen_Previews: PreviewProvider, TestablePreview { title: "App Icon.png", isRoomEncrypted: true, shouldShowCaptionWarning: true, - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), timelineController: MockTimelineController(), clientProxy: ClientProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift index f3f7390e5..6e45b3d84 100644 --- a/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/AnalyticsPromptScreen/View/AnalyticsPromptScreen.swift @@ -102,6 +102,6 @@ struct AnalyticsPromptScreen_Previews: PreviewProvider, TestablePreview { } static func makeViewModel(showTerms: Bool = true) -> AnalyticsPromptScreenViewModel { - AnalyticsPromptScreenViewModel(termsURL: showTerms ? AppSettings().analyticsTermsURL : nil) + AnalyticsPromptScreenViewModel(termsURL: showTerms ? AppSettings.volatile().analyticsTermsURL : nil) } } diff --git a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift index 3e49707d4..7f07c179c 100644 --- a/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/IdentityConfirmationScreen/View/IdentityConfirmationScreen.swift @@ -140,7 +140,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview { userSession.sessionSecurityStatePublisher = CurrentValuePublisher(.init(verificationState: .unverified, recoveryState: recoveryState)) return IdentityConfirmationScreenViewModel(userSession: userSession, - appSettings: AppSettings(), + appSettings: .volatile(), userIndicatorController: UserIndicatorControllerMock.default) } } diff --git a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift index ea4991737..01eda6c5b 100644 --- a/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift +++ b/ElementX/Sources/Screens/Onboarding/SessionVerificationScreen/View/SessionVerificationScreen.swift @@ -289,7 +289,7 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview { flow: SessionVerificationScreenFlow = .deviceInitiator) -> some View { let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(), flow: flow, - appSettings: AppSettings(), + appSettings: .volatile(), mediaProvider: MediaProviderMock(configuration: .init()), verificationState: state) diff --git a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift index acb87c789..53bb444f3 100644 --- a/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift +++ b/ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift @@ -68,14 +68,15 @@ struct PinnedEventsTimelineScreen: View { struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: JoinedRoomProxyMock(.init()), userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default) static let emptyTimelineViewModel: TimelineViewModel = { let timelineController = MockTimelineController(timelineKind: .pinned) timelineController.timelineItems = [] - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")), timelineController: timelineController, userSession: UserSessionMock(.init()), diff --git a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift index be35983a7..9c5d45b3c 100644 --- a/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsEditScreen/View/RoomDetailsEditScreen.swift @@ -177,7 +177,7 @@ struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview { return RoomDetailsEditScreenViewModel(roomProxy: roomProxy, userSession: UserSessionMock(.init()), - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), userIndicatorController: UserIndicatorControllerMock.default) } } diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift index b0f1d1fc2..c04e4db43 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/View/RoomDetailsScreen.swift @@ -424,7 +424,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxy, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) } private static func makeSimpleRoomViewModel() -> RoomDetailsScreenViewModel { @@ -452,7 +452,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxy, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) } private static func makeDMViewModel(verificationState: UserIdentityVerificationState) -> RoomDetailsScreenViewModel { @@ -490,6 +490,6 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxy, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) } } diff --git a/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift b/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift index 962331403..76bfb3e49 100644 --- a/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomMemberDetailsScreen/View/RoomMemberDetailsScreen.swift @@ -241,6 +241,6 @@ struct RoomMemberDetailsScreen_Previews: PreviewProvider, TestablePreview { userSession: UserSessionMock(.init(clientProxy: clientProxyMock)), userIndicatorController: UserIndicatorControllerMock.default, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) } } diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift index aab185972..f095edc43 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/ComposerToolbarViewModel.swift @@ -826,7 +826,7 @@ extension ComposerToolbarViewModel { completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)), mediaProvider: MediaProviderMock(configuration: .init()), mentionDisplayHelper: ComposerMentionDisplayHelper.mock, - appSettings: AppSettings(), + appSettings: .volatile(), analyticsService: AnalyticsServiceMock.default, composerDraftService: ComposerDraftServiceMock(.init())) viewModel.state.bindings.composerFocused = focused diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift index 35b6ea08d..007823c1c 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/RoomAttachmentPicker.swift @@ -81,7 +81,7 @@ struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview { static let viewModel = makeViewModel() static func makeViewModel() -> ComposerToolbarViewModel { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() return ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()), wysiwygViewModel: WysiwygComposerViewModel(), diff --git a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift index e78723366..7770a7a25 100644 --- a/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomScreen/RoomScreenViewModel.swift @@ -461,7 +461,7 @@ extension RoomScreenViewModel { roomProxy: roomProxyMock, initialSelectedPinnedEventID: nil, ongoingCallRoomIDPublisher: .init(.init(nil)), - appSettings: AppSettings(), + appSettings: .volatile(), appHooks: appHooks, analyticsService: AnalyticsServiceMock.default, userIndicatorController: UserIndicatorControllerMock.default) diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index 8e3017d20..b9d3ea981 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -362,7 +362,7 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview { powerLevelsConfiguration: .init(canUserSendMessage: canSendMessage))) let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockTimelineController(), userSession: UserSessionMock(.init()), diff --git a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift index 4a58c2a68..f8df952e6 100644 --- a/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift +++ b/ElementX/Sources/Screens/SecurityAndPrivacyScreen/View/SecurityAndPrivacyScreen.swift @@ -229,40 +229,30 @@ struct SecurityAndPrivacyScreen: View { // MARK: - Previews struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { - static let inviteOnlyViewModel = { - AppSettings.resetAllSettings() - return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsCreator, - joinRule: .invite)), - clientProxy: ClientProxyMock(.init()), - userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) - }() + static let inviteOnlyViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsCreator, + joinRule: .invite)), + clientProxy: ClientProxyMock(.init()), + userIndicatorController: UserIndicatorControllerMock(), + appSettings: .volatile()) - static let publicViewModel = { - AppSettings.resetAllSettings() - return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, - canonicalAlias: "#room:matrix.org", - members: .allMembersAsCreator, - joinRule: .public, - isVisibleInPublicDirectory: true)), - clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), - userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) - }() + static let publicViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, + canonicalAlias: "#room:matrix.org", + members: .allMembersAsCreator, + joinRule: .public, + isVisibleInPublicDirectory: true)), + clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), + userIndicatorController: UserIndicatorControllerMock(), + appSettings: .volatile()) - static let publicNoAddressViewModel = { - AppSettings.resetAllSettings() - return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, - members: .allMembersAsCreator, - joinRule: .public)), - clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), - userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) - }() + static let publicNoAddressViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, + members: .allMembersAsCreator, + joinRule: .public)), + clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), + userIndicatorController: UserIndicatorControllerMock(), + appSettings: .volatile()) static let singleSpaceMembersViewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let space = [SpaceServiceRoom].mockSingleRoom[0] @@ -278,8 +268,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { }() static let multipleSpacesMembersViewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let spaces = [SpaceServiceRoom].mockJoinedSpaces @@ -295,8 +284,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { }() static let askToJoinViewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.knockingEnabled = true return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false, @@ -310,8 +298,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { }() static let singleAskToJoinSpaceMembersViewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.knockingEnabled = true let space = [SpaceServiceRoom].mockSingleRoom[0] @@ -328,8 +315,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { }() static let multipleAskToJoinSpacesMembersViewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.knockingEnabled = true let spaces = [SpaceServiceRoom].mockJoinedSpaces @@ -345,18 +331,15 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview { appSettings: appSettings) }() - static let publicSpaceViewModel = { - AppSettings.resetAllSettings() - return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isSpace: true, - isEncrypted: false, - canonicalAlias: "#space:matrix.org", - members: .allMembersAsCreator, - joinRule: .public, - isVisibleInPublicDirectory: true)), - clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), - userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) - }() + static let publicSpaceViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isSpace: true, + isEncrypted: false, + canonicalAlias: "#space:matrix.org", + members: .allMembersAsCreator, + joinRule: .public, + isVisibleInPublicDirectory: true)), + clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")), + userIndicatorController: UserIndicatorControllerMock(), + appSettings: .volatile()) static var previews: some View { ElementNavigationStack { diff --git a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift index 7aea59959..dca4b3bd6 100644 --- a/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/AdvancedSettingsScreen/View/AdvancedSettingsScreen.swift @@ -161,8 +161,7 @@ private extension AppAppearance { struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() return AdvancedSettingsScreenViewModel(advancedSettings: appSettings, analytics: AnalyticsServiceMock.default, clientProxy: ClientProxyMock(.init()), diff --git a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/View/AnalyticsSettingsScreen.swift b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/View/AnalyticsSettingsScreen.swift index 04038b59a..6a35c809f 100644 --- a/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/View/AnalyticsSettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/AnalyticsSettingsScreen/View/AnalyticsSettingsScreen.swift @@ -39,7 +39,7 @@ struct AnalyticsSettingsScreen: View { struct AnalyticsSettingsScreen_Previews: PreviewProvider, TestablePreview { static var previews: some View { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings, analytics: AnalyticsServiceMock.default) AnalyticsSettingsScreen(context: viewModel.context) diff --git a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift index dc7c27f00..958e56359 100644 --- a/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift +++ b/ElementX/Sources/Screens/Settings/DeveloperOptionsScreen/View/DeveloperOptionsScreen.swift @@ -249,8 +249,8 @@ private extension Set { // MARK: - Previews struct DeveloperOptionsScreen_Previews: PreviewProvider { - static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: AppSettings(), - elementCallBaseURL: AppSettings().elementCallBaseURL, + static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: AppSettings.volatile(), + elementCallBaseURL: AppSettings.volatile().elementCallBaseURL, appHooks: AppHooks(), clientProxy: ClientProxyMock(.init())) diff --git a/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift b/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift index b16b75319..199b9b4a1 100644 --- a/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift +++ b/ElementX/Sources/Screens/Settings/LegalInformationScreen/View/LegalInformationScreen.swift @@ -33,7 +33,7 @@ struct LegalInformationScreen: View { // MARK: - Previews struct LegalInformationScreen_Previews: PreviewProvider, TestablePreview { - static let viewModel = LegalInformationScreenViewModel(appSettings: AppSettings()) + static let viewModel = LegalInformationScreenViewModel(appSettings: .volatile()) static var previews: some View { LegalInformationScreen(context: viewModel.context) } diff --git a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift index 6175f88c5..1fbf50ba6 100644 --- a/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/NotificationSettingsScreen/View/NotificationSettingsScreen.swift @@ -264,7 +264,7 @@ struct NotificationSettingsScreen: View { struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { static let viewModel: NotificationSettingsScreenViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let notificationCenter = UserNotificationCenterMock() notificationCenter.authorizationStatusReturnValue = .notDetermined let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) @@ -292,7 +292,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview { }() static let viewModelConfigurationMismatch: NotificationSettingsScreenViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let notificationCenter = UserNotificationCenterMock() notificationCenter.authorizationStatusReturnValue = .notDetermined let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) diff --git a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift index db2f31494..fae0089aa 100644 --- a/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift +++ b/ElementX/Sources/Screens/Settings/SettingsScreen/View/SettingsScreen.swift @@ -277,7 +277,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview { let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com", deviceID: "AAAAAAAAAAA")))) return SettingsScreenViewModel(userSession: userSession, - appSettings: AppSettings(), + appSettings: .volatile(), isBugReportServiceEnabled: isBugReportServiceEnabled, isInSecondaryWindow: false) } diff --git a/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift b/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift index cb0717838..82047193f 100644 --- a/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift +++ b/ElementX/Sources/Screens/Settings/UserDetailsEditScreen/View/UserDetailsEditScreen.swift @@ -141,7 +141,7 @@ struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview { UserDetailsEditScreenViewModel(userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@stefan:matrix.org", canChangeAvatar: canChangeProfile, canChangeDisplayName: canChangeProfile)))), - mediaUploadingPreprocessor: .init(appSettings: AppSettings()), + mediaUploadingPreprocessor: .init(appSettings: .volatile()), userIndicatorController: UserIndicatorControllerMock.default) } } diff --git a/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift b/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift index 60f1bf76e..cc03c045b 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceSettingsScreen/View/SpaceSettingsScreen.swift @@ -136,7 +136,7 @@ struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) } static var previews: some View { diff --git a/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift b/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift index a149fe702..ffdb88cec 100644 --- a/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpacesScreen/View/SpacesScreen.swift @@ -144,8 +144,7 @@ struct SpacesScreen_Previews: PreviewProvider, TestablePreview { } static func makeViewModel(isEmpty: Bool = false) -> SpacesScreenViewModel { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let clientProxy = ClientProxyMock(.init()) clientProxy.spaceService = SpaceServiceProxyMock(.init(topLevelSpaces: isEmpty ? [] : .mockJoinedSpaces)) diff --git a/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift b/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift index bbcc6ebc1..24066e0d9 100644 --- a/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift +++ b/ElementX/Sources/Screens/StartChatScreen/View/JoinRoomByAddressView.swift @@ -87,7 +87,7 @@ struct JoinRoomByAddressView_Previews: PreviewProvider, TestablePreview { analytics: AnalyticsServiceMock.default, userIndicatorController: UserIndicatorControllerMock(), userDiscoveryService: userDiscoveryService, - appSettings: AppSettings()) + appSettings: .volatile()) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift index 32e762ecc..e280aad03 100644 --- a/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift +++ b/ElementX/Sources/Screens/StartChatScreen/View/StartChatScreen.swift @@ -154,7 +154,7 @@ struct StartChatScreen: View { struct StartChatScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com")))) let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice]) diff --git a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift index 6daf6a208..d6015c07a 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineViewModel.swift @@ -1121,7 +1121,8 @@ extension TimelineViewModel { clientProxyMock.roomSummaryForIdentifierReturnValue = .mock(id: "!room:matrix.org", name: "Room", canonicalAlias: "#room:matrix.org") let roomProxy = JoinedRoomProxyMock(.init(name: "Preview room", predecessor: hasPredecessor ? .init(roomId: UUID().uuidString) : nil)) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return TimelineViewModel(roomProxy: roomProxy, focussedEventID: nil, timelineController: timelineController ?? MockTimelineController(timelineKind: timelineKind), diff --git a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift index aebd6a080..ee1440d6a 100644 --- a/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift +++ b/ElementX/Sources/Screens/Timeline/View/ItemMenu/TimelineItemMenu.swift @@ -342,7 +342,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview { isViewSourceEnabled: true, areThreadsEnabled: true, timelineKind: .live, - emojiProvider: EmojiProvider(appSettings: AppSettings())) + emojiProvider: EmojiProvider(appSettings: .volatile())) guard let actions = provider.makeActions() else { return nil } if var textItem = item as? TextRoomTimelineItem { diff --git a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift index e47186f26..b57ba5253 100644 --- a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift +++ b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptsSummaryView.swift @@ -45,7 +45,7 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview { ] let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members)) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() return TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockTimelineController(), diff --git a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift index 38ef105b4..0bd21eba0 100644 --- a/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Style/TimelineItemBubbledStylerView.swift @@ -334,7 +334,7 @@ private extension TimelineItemKeyForwarder { struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview { static let viewModel: TimelineViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.threadsEnabled = true let roomProxy = JoinedRoomProxyMock(.init()) @@ -353,7 +353,7 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview }() static let viewModelWithPins: TimelineViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.threadsEnabled = true let roomProxy = JoinedRoomProxyMock(.init(name: "Preview Room", pinnedEventIDs: ["pinned"])) diff --git a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift index 91ca0df23..25b037c12 100644 --- a/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift +++ b/ElementX/Sources/Screens/Timeline/View/Supplementary/TimelineReadReceiptsView.swift @@ -80,7 +80,8 @@ struct TimelineReadReceiptsView_Previews: PreviewProvider, TestablePreview { ] static let viewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)), timelineController: MockTimelineController(), userSession: UserSessionMock(.init()), diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift index 5c10acc71..78f8fabb5 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineItemViews/HighlightedTimelineItemModifier.swift @@ -90,7 +90,8 @@ struct HighlightedTimelineItemTimeline_Previews: PreviewProvider { static let focussedEventID = "RoomTimelineItemFixtures.default.5" static let composerViewModel = ComposerToolbarViewModel.mock() static let timelineViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return TimelineViewModel(roomProxy: roomProxyMock, focussedEventID: focussedEventID, timelineController: MockTimelineController(), diff --git a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift index f7ce7d472..b96a6c488 100644 --- a/ElementX/Sources/Screens/Timeline/View/TimelineView.swift +++ b/ElementX/Sources/Screens/Timeline/View/TimelineView.swift @@ -153,7 +153,8 @@ struct TimelineView_Previews: PreviewProvider { // Not testable as this preview static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock) static let composerViewModel = ComposerToolbarViewModel.mock() static let timelineViewModel = { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + return TimelineViewModel(roomProxy: roomProxyMock, timelineController: MockTimelineController(), userSession: UserSessionMock(.init()), diff --git a/ElementX/Sources/Screens/UserProfileScreen/View/UserProfileScreen.swift b/ElementX/Sources/Screens/UserProfileScreen/View/UserProfileScreen.swift index 2eb1559da..12602193f 100644 --- a/ElementX/Sources/Screens/UserProfileScreen/View/UserProfileScreen.swift +++ b/ElementX/Sources/Screens/UserProfileScreen/View/UserProfileScreen.swift @@ -148,6 +148,6 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview { userSession: UserSessionMock(.init(clientProxy: clientProxyMock)), userIndicatorController: UserIndicatorControllerMock.default, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) } } diff --git a/ElementX/Sources/Services/Authentication/AuthenticationService.swift b/ElementX/Sources/Services/Authentication/AuthenticationService.swift index 3209b7321..ff9ace529 100644 --- a/ElementX/Sources/Services/Authentication/AuthenticationService.swift +++ b/ElementX/Sources/Services/Authentication/AuthenticationService.swift @@ -388,7 +388,7 @@ extension AuthenticationService { encryptionKeyProvider: EncryptionKeyProvider(), classicAppManager: classicAppManager, clientFactory: AuthenticationClientFactoryMock(configuration: .init()), - appSettings: AppSettings(), + appSettings: .volatile(), appHooks: AppHooks()) } } diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index 261b4776f..69fb913fe 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -35,9 +35,7 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate MXLog.configure(currentTarget: "uitests") - AppSettings.configureWithSuiteName("io.element.elementx.uitests") - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() let analyticsClient = AnalyticsClientMock() analyticsClient.isRunning = false diff --git a/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift b/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift index ac04a6905..54d745f73 100644 --- a/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift +++ b/ElementX/Sources/UnitTests/UnitTestsAppCoordinator.swift @@ -18,9 +18,6 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol { init(appDelegate: AppDelegate) { windowManager = WindowManager(appDelegate: appDelegate) - AppSettings.configureWithSuiteName("io.element.elementx.unittests") - AppSettings.resetAllSettings() - // As the tests take advantage of Rust's ability to redirect the log files, there is // often some debris left from the previous run, so we wipe the entire directory. // This is an NOT an advised way to delete logs in production, `Tracing.deleteLogFiles` diff --git a/Enterprise b/Enterprise index 5480892ab..0157e8257 160000 --- a/Enterprise +++ b/Enterprise @@ -1 +1 @@ -Subproject commit 5480892abbb15f72eb3dd3e994d447d601aecd77 +Subproject commit 0157e82576946965e789b943532fba9b02f0340e diff --git a/NSE/Sources/NotificationServiceExtension.swift b/NSE/Sources/NotificationServiceExtension.swift index d8f3b558b..33bb84933 100644 --- a/NSE/Sources/NotificationServiceExtension.swift +++ b/NSE/Sources/NotificationServiceExtension.swift @@ -63,7 +63,7 @@ actor NotificationServiceExtensionActor { private static let firstNotificationThreshold: TimeInterval = 15 * 60 - private let settings: CommonSettingsProtocol = AppSettings() + private let settings: CommonSettingsProtocol private let appHooks: AppHooks /// This is nonisolated just because the expire function needs to be served ASAP so we should not call it from a Task, however this is @@ -79,6 +79,11 @@ actor NotificationServiceExtensionActor { } init() { + guard let userDefaults = TrackedUserDefaults(suiteName: AppSettings.suiteName) else { + fatalError("Catastrophic error retrieving user defaults for \(AppSettings.suiteName)") + } + settings = AppSettings(store: userDefaults) + appHooks = AppHooks() appHooks.setUp() diff --git a/PreviewTests/Sources/GeneratedPreviewTests.swift b/PreviewTests/Sources/GeneratedPreviewTests.swift index be1347561..33bc0e36d 100644 --- a/PreviewTests/Sources/GeneratedPreviewTests.swift +++ b/PreviewTests/Sources/GeneratedPreviewTests.swift @@ -13,7 +13,6 @@ extension PreviewTests { @Test func advancedSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AdvancedSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -21,7 +20,6 @@ extension PreviewTests { @Test func analyticsPromptScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AnalyticsPromptScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -29,7 +27,6 @@ extension PreviewTests { @Test func analyticsSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AnalyticsSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -37,7 +34,6 @@ extension PreviewTests { @Test func appLockScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AppLockScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -45,7 +41,6 @@ extension PreviewTests { @Test func appLockSetupBiometricsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AppLockSetupBiometricsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -53,7 +48,6 @@ extension PreviewTests { @Test func appLockSetupPINScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AppLockSetupPINScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -61,7 +55,6 @@ extension PreviewTests { @Test func appLockSetupSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AppLockSetupSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -69,7 +62,6 @@ extension PreviewTests { @Test func audioMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AudioMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -77,7 +69,6 @@ extension PreviewTests { @Test func audioRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AudioRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -85,7 +76,6 @@ extension PreviewTests { @Test func authenticationClassicAppBackupInstructionsView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AuthenticationClassicAppBackupInstructionsView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -93,7 +83,6 @@ extension PreviewTests { @Test func authenticationStartScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AuthenticationStartScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -101,7 +90,6 @@ extension PreviewTests { @Test func avatarHeaderView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in AvatarHeaderView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -109,7 +97,6 @@ extension PreviewTests { @Test func badgeLabel() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in BadgeLabel_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -117,7 +104,6 @@ extension PreviewTests { @Test func blockedUsersScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in BlockedUsersScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -125,7 +111,6 @@ extension PreviewTests { @Test func bloomModifier() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in BloomModifier_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -133,7 +118,6 @@ extension PreviewTests { @Test func bugReportScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in BugReportScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -141,7 +125,6 @@ extension PreviewTests { @Test func callInviteRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CallInviteRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -149,7 +132,6 @@ extension PreviewTests { @Test func callNotificationRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CallNotificationRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -157,7 +139,6 @@ extension PreviewTests { @Test func chatsSpaceFilterCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ChatsSpaceFilterCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -165,7 +146,6 @@ extension PreviewTests { @Test func chatsSpaceFiltersScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ChatsSpaceFiltersScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -173,7 +153,6 @@ extension PreviewTests { @Test func collapsibleRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CollapsibleRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -181,7 +160,6 @@ extension PreviewTests { @Test func completionSuggestion() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CompletionSuggestion_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -189,7 +167,6 @@ extension PreviewTests { @Test func composerToolbar() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ComposerToolbar_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -197,7 +174,6 @@ extension PreviewTests { @Test func copyTextButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CopyTextButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -205,7 +181,6 @@ extension PreviewTests { @Test func createRoomSpaceSelectionSheet() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CreateRoomSpaceSelectionSheet_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -213,7 +188,6 @@ extension PreviewTests { @Test func createRoom() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in CreateRoom_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -221,7 +195,6 @@ extension PreviewTests { @Test func deactivateAccountScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in DeactivateAccountScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -229,7 +202,6 @@ extension PreviewTests { @Test func declineAndBlockScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in DeclineAndBlockScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -237,7 +209,6 @@ extension PreviewTests { @Test func editRoomAddressScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EditRoomAddressScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -245,7 +216,6 @@ extension PreviewTests { @Test func elementTextFieldStyle() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ElementTextFieldStyle_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -253,7 +223,6 @@ extension PreviewTests { @Test func emojiPickerScreenHeaderView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EmojiPickerScreenHeaderView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -261,7 +230,6 @@ extension PreviewTests { @Test func emojiPickerScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EmojiPickerScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -269,7 +237,6 @@ extension PreviewTests { @Test func emoteRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EmoteRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -277,7 +244,6 @@ extension PreviewTests { @Test func encryptedRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EncryptedRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -285,7 +251,6 @@ extension PreviewTests { @Test func encryptionResetPasswordScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EncryptionResetPasswordScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -293,7 +258,6 @@ extension PreviewTests { @Test func encryptionResetScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EncryptionResetScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -301,7 +265,6 @@ extension PreviewTests { @Test func estimatedWaveformView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in EstimatedWaveformView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -309,7 +272,6 @@ extension PreviewTests { @Test func fileMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FileMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -317,7 +279,6 @@ extension PreviewTests { @Test func fileRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FileRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -325,7 +286,6 @@ extension PreviewTests { @Test func floatingDateBadge() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FloatingDateBadge_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -333,7 +293,6 @@ extension PreviewTests { @Test func formButtonStyles() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FormButtonStyles_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -341,7 +300,6 @@ extension PreviewTests { @Test func formattedBodyText() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FormattedBodyText_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -349,7 +307,6 @@ extension PreviewTests { @Test func formattingToolbar() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FormattingToolbar_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -357,7 +314,6 @@ extension PreviewTests { @Test func fullscreenDialog() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in FullscreenDialog_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -365,7 +321,6 @@ extension PreviewTests { @Test func globalSearchScreenListRow() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in GlobalSearchScreenListRow_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -373,7 +328,6 @@ extension PreviewTests { @Test func globalSearchScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in GlobalSearchScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -381,7 +335,6 @@ extension PreviewTests { @Test func highlightedTimelineItemModifier() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HighlightedTimelineItemModifier_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -389,7 +342,6 @@ extension PreviewTests { @Test func homeScreenEmptyStateView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenEmptyStateView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -397,7 +349,6 @@ extension PreviewTests { @Test func homeScreenInviteCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenInviteCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -405,7 +356,6 @@ extension PreviewTests { @Test func homeScreenKnockedCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenKnockedCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -413,7 +363,6 @@ extension PreviewTests { @Test func homeScreenNewSoundBanner() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenNewSoundBanner_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -421,7 +370,6 @@ extension PreviewTests { @Test func homeScreenRecoveryKeyConfirmationBanner() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenRecoveryKeyConfirmationBanner_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -429,7 +377,6 @@ extension PreviewTests { @Test func homeScreenRoomCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreenRoomCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -437,7 +384,6 @@ extension PreviewTests { @Test func homeScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in HomeScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -445,7 +391,6 @@ extension PreviewTests { @Test func identityConfirmationScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in IdentityConfirmationScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -453,7 +398,6 @@ extension PreviewTests { @Test func identityConfirmedScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in IdentityConfirmedScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -461,7 +405,6 @@ extension PreviewTests { @Test func imageMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ImageMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -469,7 +412,6 @@ extension PreviewTests { @Test func imageRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ImageRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -477,7 +419,6 @@ extension PreviewTests { @Test func inviteUsersConfirmationSheetView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in InviteUsersConfirmationSheetView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -485,7 +426,6 @@ extension PreviewTests { @Test func inviteUsersScreenSelectedItem() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in InviteUsersScreenSelectedItem_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -493,7 +433,6 @@ extension PreviewTests { @Test func inviteUsersScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in InviteUsersScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -501,7 +440,6 @@ extension PreviewTests { @Test func joinRoomByAddressView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in JoinRoomByAddressView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -509,7 +447,6 @@ extension PreviewTests { @Test func joinRoomScreenSpace() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in JoinRoomScreenSpace_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -517,7 +454,6 @@ extension PreviewTests { @Test func joinRoomScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in JoinRoomScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -525,7 +461,6 @@ extension PreviewTests { @Test func joinedMembersBadgeView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in JoinedMembersBadgeView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -533,7 +468,6 @@ extension PreviewTests { @Test func knockRequestCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in KnockRequestCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -541,7 +475,6 @@ extension PreviewTests { @Test func knockRequestsBannerView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in KnockRequestsBannerView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -549,7 +482,6 @@ extension PreviewTests { @Test func knockRequestsListEmptyStateView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in KnockRequestsListEmptyStateView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -557,7 +489,6 @@ extension PreviewTests { @Test func knockRequestsListScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in KnockRequestsListScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -565,7 +496,6 @@ extension PreviewTests { @Test func labsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LabsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -573,7 +503,6 @@ extension PreviewTests { @Test func leaveSpaceRoomDetailsCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LeaveSpaceRoomDetailsCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -581,7 +510,6 @@ extension PreviewTests { @Test func leaveSpaceView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LeaveSpaceView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -589,7 +517,6 @@ extension PreviewTests { @Test func legalInformationScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LegalInformationScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -597,7 +524,6 @@ extension PreviewTests { @Test func linkNewDeviceScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LinkNewDeviceScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -605,7 +531,6 @@ extension PreviewTests { @Test func liveLocationRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LiveLocationRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -613,7 +538,6 @@ extension PreviewTests { @Test func liveLocationSharingBannerView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LiveLocationSharingBannerView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -621,7 +545,6 @@ extension PreviewTests { @Test func liveLocationSheet() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LiveLocationSheet_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -629,7 +552,6 @@ extension PreviewTests { @Test func loadableImage() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LoadableImage_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -637,7 +559,6 @@ extension PreviewTests { @Test func locationMarkerView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LocationMarkerView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -645,7 +566,6 @@ extension PreviewTests { @Test func locationPickerSheet() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LocationPickerSheet_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -653,7 +573,6 @@ extension PreviewTests { @Test func locationRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LocationRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -661,7 +580,6 @@ extension PreviewTests { @Test func locationSharingScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LocationSharingScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -669,7 +587,6 @@ extension PreviewTests { @Test func loginScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LoginScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -677,7 +594,6 @@ extension PreviewTests { @Test func longPressWithFeedback() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in LongPressWithFeedback_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -685,7 +601,6 @@ extension PreviewTests { @Test func manageAuthorizedSpacesScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ManageAuthorizedSpacesScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -693,7 +608,6 @@ extension PreviewTests { @Test func manageRoomMemberSheetView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ManageRoomMemberSheetView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -701,7 +615,6 @@ extension PreviewTests { @Test func mapLibreStaticMapView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MapLibreStaticMapView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -709,7 +622,6 @@ extension PreviewTests { @Test func matrixUserPermalink() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MatrixUserPermalink_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -717,7 +629,6 @@ extension PreviewTests { @Test func mediaEventsTimelineScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MediaEventsTimelineScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -725,7 +636,6 @@ extension PreviewTests { @Test func mediaUploadPreviewScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MediaUploadPreviewScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -733,7 +643,6 @@ extension PreviewTests { @Test func mentionSuggestionItemView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MentionSuggestionItemView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -741,7 +650,6 @@ extension PreviewTests { @Test func messageComposerTextField() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MessageComposerTextField_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -749,7 +657,6 @@ extension PreviewTests { @Test func messageComposer() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MessageComposer_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -757,7 +664,6 @@ extension PreviewTests { @Test func messageForwardingScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MessageForwardingScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -765,7 +671,6 @@ extension PreviewTests { @Test func messageText() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in MessageText_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -773,7 +678,6 @@ extension PreviewTests { @Test func noticeRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in NoticeRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -781,7 +685,6 @@ extension PreviewTests { @Test func notificationPermissionsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in NotificationPermissionsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -789,7 +692,6 @@ extension PreviewTests { @Test func notificationSettingsEditScreenRoomCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in NotificationSettingsEditScreenRoomCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -797,7 +699,6 @@ extension PreviewTests { @Test func notificationSettingsEditScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in NotificationSettingsEditScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -805,7 +706,6 @@ extension PreviewTests { @Test func notificationSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in NotificationSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -813,7 +713,6 @@ extension PreviewTests { @Test func pINTextField() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PINTextField_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -821,7 +720,6 @@ extension PreviewTests { @Test func paginationIndicatorRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PaginationIndicatorRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -829,7 +727,6 @@ extension PreviewTests { @Test func pillViewOnBubble() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PillViewOnBubble_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -837,7 +734,6 @@ extension PreviewTests { @Test func pillView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PillView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -845,7 +741,6 @@ extension PreviewTests { @Test func pinnedEventsTimelineScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PinnedEventsTimelineScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -853,7 +748,6 @@ extension PreviewTests { @Test func pinnedItemsBannerView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PinnedItemsBannerView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -861,7 +755,6 @@ extension PreviewTests { @Test func pinnedItemsIndicatorView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PinnedItemsIndicatorView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -869,7 +762,6 @@ extension PreviewTests { @Test func placeholderAvatarImage() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PlaceholderAvatarImage_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -877,7 +769,6 @@ extension PreviewTests { @Test func placeholderScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PlaceholderScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -885,7 +776,6 @@ extension PreviewTests { @Test func playbackSpeedButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PlaybackSpeedButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -893,7 +783,6 @@ extension PreviewTests { @Test func pollFormScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PollFormScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -901,7 +790,6 @@ extension PreviewTests { @Test func pollOptionView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PollOptionView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -909,7 +797,6 @@ extension PreviewTests { @Test func pollRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PollRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -917,7 +804,6 @@ extension PreviewTests { @Test func pollView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in PollView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -925,7 +811,6 @@ extension PreviewTests { @Test func qRCodeErrorView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in QRCodeErrorView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -933,7 +818,6 @@ extension PreviewTests { @Test func qRCodeLoginScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in QRCodeLoginScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -941,7 +825,6 @@ extension PreviewTests { @Test func reactionsSummaryView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReactionsSummaryView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -949,7 +832,6 @@ extension PreviewTests { @Test func readMarkerRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReadMarkerRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -957,7 +839,6 @@ extension PreviewTests { @Test func readReceiptCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReadReceiptCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -965,7 +846,6 @@ extension PreviewTests { @Test func readReceiptsSummaryView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReadReceiptsSummaryView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -973,7 +853,6 @@ extension PreviewTests { @Test func redactedRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RedactedRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -981,7 +860,6 @@ extension PreviewTests { @Test func reportContentScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReportContentScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -989,7 +867,6 @@ extension PreviewTests { @Test func reportRoomScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ReportRoomScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -997,7 +874,6 @@ extension PreviewTests { @Test func resolveVerifiedUserSendFailureScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ResolveVerifiedUserSendFailureScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1005,7 +881,6 @@ extension PreviewTests { @Test func roomAttachmentPicker() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomAttachmentPicker_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1013,7 +888,6 @@ extension PreviewTests { @Test func roomAvatarImage() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomAvatarImage_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1021,7 +895,6 @@ extension PreviewTests { @Test func roomChangePermissionsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomChangePermissionsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1029,7 +902,6 @@ extension PreviewTests { @Test func roomChangeRolesScreenRow() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomChangeRolesScreenRow_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1037,7 +909,6 @@ extension PreviewTests { @Test func roomChangeRolesScreenSelectedItem() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomChangeRolesScreenSelectedItem_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1045,7 +916,6 @@ extension PreviewTests { @Test func roomChangeRolesScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomChangeRolesScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1053,7 +923,6 @@ extension PreviewTests { @Test func roomDetailsEditScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomDetailsEditScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1061,7 +930,6 @@ extension PreviewTests { @Test func roomDetailsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomDetailsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1069,7 +937,6 @@ extension PreviewTests { @Test func roomDirectorySearchCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomDirectorySearchCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1077,7 +944,6 @@ extension PreviewTests { @Test func roomDirectorySearchScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomDirectorySearchScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1085,7 +951,6 @@ extension PreviewTests { @Test func roomHeaderView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomHeaderView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1093,7 +958,6 @@ extension PreviewTests { @Test func roomInviterLabel() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomInviterLabel_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1101,7 +965,6 @@ extension PreviewTests { @Test func roomListFilterView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomListFilterView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1109,7 +972,6 @@ extension PreviewTests { @Test func roomListFiltersEmptyStateView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomListFiltersEmptyStateView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1117,7 +979,6 @@ extension PreviewTests { @Test func roomListFiltersView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomListFiltersView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1125,7 +986,6 @@ extension PreviewTests { @Test func roomMemberDetailsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomMemberDetailsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1133,7 +993,6 @@ extension PreviewTests { @Test func roomMembersListMemberCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomMembersListMemberCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1141,7 +1000,6 @@ extension PreviewTests { @Test func roomMembersListScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomMembersListScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1149,7 +1007,6 @@ extension PreviewTests { @Test func roomNotificationSettingsCustomSectionView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomNotificationSettingsCustomSectionView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1157,7 +1014,6 @@ extension PreviewTests { @Test func roomNotificationSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomNotificationSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1165,7 +1021,6 @@ extension PreviewTests { @Test func roomNotificationSettingsUserDefinedScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomNotificationSettingsUserDefinedScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1173,7 +1028,6 @@ extension PreviewTests { @Test func roomPollsHistoryScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomPollsHistoryScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1181,7 +1035,6 @@ extension PreviewTests { @Test func roomRolesAndPermissionsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomRolesAndPermissionsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1189,7 +1042,6 @@ extension PreviewTests { @Test func roomScreenFooterView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomScreenFooterView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1197,7 +1049,6 @@ extension PreviewTests { @Test func roomScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1205,7 +1056,6 @@ extension PreviewTests { @Test func roomSelectionScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomSelectionScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1213,7 +1063,6 @@ extension PreviewTests { @Test func roomThreadListScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in RoomThreadListScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1221,7 +1070,6 @@ extension PreviewTests { @Test func sFNumberedListView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SFNumberedListView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1229,7 +1077,6 @@ extension PreviewTests { @Test func secureBackupKeyBackupScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SecureBackupKeyBackupScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1237,7 +1084,6 @@ extension PreviewTests { @Test func secureBackupLogoutConfirmationScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SecureBackupLogoutConfirmationScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1245,7 +1091,6 @@ extension PreviewTests { @Test func secureBackupRecoveryKeyScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SecureBackupRecoveryKeyScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1253,7 +1098,6 @@ extension PreviewTests { @Test func secureBackupScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SecureBackupScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1261,7 +1105,6 @@ extension PreviewTests { @Test func securityAndPrivacyScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SecurityAndPrivacyScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1269,7 +1112,6 @@ extension PreviewTests { @Test func sendInviteConfirmationView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SendInviteConfirmationView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1277,7 +1119,6 @@ extension PreviewTests { @Test func separatorMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SeparatorMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1285,7 +1126,6 @@ extension PreviewTests { @Test func separatorRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SeparatorRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1293,7 +1133,6 @@ extension PreviewTests { @Test func serverConfirmationScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ServerConfirmationScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1301,7 +1140,6 @@ extension PreviewTests { @Test func serverSelection() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ServerSelection_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1309,7 +1147,6 @@ extension PreviewTests { @Test func sessionVerificationRequestDetailsView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SessionVerificationRequestDetailsView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1317,7 +1154,6 @@ extension PreviewTests { @Test func sessionVerification() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SessionVerification_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1325,7 +1161,6 @@ extension PreviewTests { @Test func settingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1333,7 +1168,6 @@ extension PreviewTests { @Test func shimmerOverlay() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ShimmerOverlay_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1341,7 +1175,6 @@ extension PreviewTests { @Test func softLogoutScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SoftLogoutScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1349,7 +1182,6 @@ extension PreviewTests { @Test func spaceAddRoomsScreenSelectedItem() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceAddRoomsScreenSelectedItem_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1357,7 +1189,6 @@ extension PreviewTests { @Test func spaceAddRoomsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceAddRoomsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1365,7 +1196,6 @@ extension PreviewTests { @Test func spaceHeaderTopicSheetView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceHeaderTopicSheetView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1373,7 +1203,6 @@ extension PreviewTests { @Test func spaceHeaderView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceHeaderView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1381,7 +1210,6 @@ extension PreviewTests { @Test func spaceRemoveChildrenConfirmationView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceRemoveChildrenConfirmationView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1389,7 +1217,6 @@ extension PreviewTests { @Test func spaceRoomCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceRoomCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1397,7 +1224,6 @@ extension PreviewTests { @Test func spaceScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1405,7 +1231,6 @@ extension PreviewTests { @Test func spaceSettingsScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpaceSettingsScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1413,7 +1238,6 @@ extension PreviewTests { @Test func spacesScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SpacesScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1421,7 +1245,6 @@ extension PreviewTests { @Test func splashScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SplashScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1429,7 +1252,6 @@ extension PreviewTests { @Test func stackedAvatarsView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in StackedAvatarsView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1437,7 +1259,6 @@ extension PreviewTests { @Test func startChatScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in StartChatScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1445,7 +1266,6 @@ extension PreviewTests { @Test func stateRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in StateRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1453,7 +1273,6 @@ extension PreviewTests { @Test func staticLocationSheet() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in StaticLocationSheet_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1461,7 +1280,6 @@ extension PreviewTests { @Test func stickerRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in StickerRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1469,7 +1287,6 @@ extension PreviewTests { @Test func swipeRightAction() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SwipeRightAction_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1477,7 +1294,6 @@ extension PreviewTests { @Test func swipeToReplyView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in SwipeToReplyView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1485,7 +1301,6 @@ extension PreviewTests { @Test func textRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TextRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1493,7 +1308,6 @@ extension PreviewTests { @Test func threadDecorator() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ThreadDecorator_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1501,7 +1315,6 @@ extension PreviewTests { @Test func timelineDeliveryStatusView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineDeliveryStatusView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1509,7 +1322,6 @@ extension PreviewTests { @Test func timelineItemBubbledStylerView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineItemBubbledStylerView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1517,7 +1329,6 @@ extension PreviewTests { @Test func timelineItemDebugView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineItemDebugView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1525,7 +1336,6 @@ extension PreviewTests { @Test func timelineItemMenu() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineItemMenu_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1533,7 +1343,6 @@ extension PreviewTests { @Test func timelineItemSendInfoLabel() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineItemSendInfoLabel_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1541,7 +1350,6 @@ extension PreviewTests { @Test func timelineItemStyler() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineItemStyler_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1549,7 +1357,6 @@ extension PreviewTests { @Test func timelineMediaPreviewDetailsView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineMediaPreviewDetailsView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1557,7 +1364,6 @@ extension PreviewTests { @Test func timelineMediaPreviewRedactConfirmationView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineMediaPreviewRedactConfirmationView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1565,7 +1371,6 @@ extension PreviewTests { @Test func timelineReactionView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineReactionView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1573,7 +1378,6 @@ extension PreviewTests { @Test func timelineReadReceiptsView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineReadReceiptsView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1581,7 +1385,6 @@ extension PreviewTests { @Test func timelineReplyView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineReplyView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1589,7 +1392,6 @@ extension PreviewTests { @Test func timelineScrollButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineScrollButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1597,7 +1399,6 @@ extension PreviewTests { @Test func timelineStartRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineStartRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1605,7 +1406,6 @@ extension PreviewTests { @Test func timelineThreadSummaryView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TimelineThreadSummaryView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1613,7 +1413,6 @@ extension PreviewTests { @Test func tombstonedAvatarImage() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TombstonedAvatarImage_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1621,7 +1420,6 @@ extension PreviewTests { @Test func toolbarButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in ToolbarButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1629,7 +1427,6 @@ extension PreviewTests { @Test func typingIndicatorView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in TypingIndicatorView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1637,7 +1434,6 @@ extension PreviewTests { @Test func unsupportedRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UnsupportedRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1645,7 +1441,6 @@ extension PreviewTests { @Test func userDetailsEditScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserDetailsEditScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1653,7 +1448,6 @@ extension PreviewTests { @Test func userIndicatorModalView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserIndicatorModalView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1661,7 +1455,6 @@ extension PreviewTests { @Test func userIndicatorToastView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserIndicatorToastView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1669,7 +1462,6 @@ extension PreviewTests { @Test func userLocationCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserLocationCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1677,7 +1469,6 @@ extension PreviewTests { @Test func userProfileCell() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserProfileCell_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1685,7 +1476,6 @@ extension PreviewTests { @Test func userProfileScreen() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in UserProfileScreen_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1693,7 +1483,6 @@ extension PreviewTests { @Test func verificationBadge() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VerificationBadge_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1701,7 +1490,6 @@ extension PreviewTests { @Test func videoMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VideoMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1709,7 +1497,6 @@ extension PreviewTests { @Test func videoRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VideoRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1717,7 +1504,6 @@ extension PreviewTests { @Test func visualListItem() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VisualListItem_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1725,7 +1511,6 @@ extension PreviewTests { @Test func voiceMessageButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1733,7 +1518,6 @@ extension PreviewTests { @Test func voiceMessageMediaEventsTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageMediaEventsTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1741,7 +1525,6 @@ extension PreviewTests { @Test func voiceMessagePreviewComposer() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessagePreviewComposer_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1749,7 +1532,6 @@ extension PreviewTests { @Test func voiceMessageRecordingButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageRecordingButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1757,7 +1539,6 @@ extension PreviewTests { @Test func voiceMessageRecordingComposer() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageRecordingComposer_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1765,7 +1546,6 @@ extension PreviewTests { @Test func voiceMessageRecordingView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageRecordingView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1773,7 +1553,6 @@ extension PreviewTests { @Test func voiceMessageRoomPlaybackView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageRoomPlaybackView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1781,7 +1560,6 @@ extension PreviewTests { @Test func voiceMessageRoomTimelineView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageRoomTimelineView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1789,7 +1567,6 @@ extension PreviewTests { @Test func voiceMessageTrashButton() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in VoiceMessageTrashButton_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } @@ -1797,7 +1574,6 @@ extension PreviewTests { @Test func waveformCursorView() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in WaveformCursorView_Previews._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } diff --git a/ShareExtension/Sources/ShareExtensionViewController.swift b/ShareExtension/Sources/ShareExtensionViewController.swift index e0498fc2c..286912161 100644 --- a/ShareExtension/Sources/ShareExtensionViewController.swift +++ b/ShareExtension/Sources/ShareExtensionViewController.swift @@ -12,7 +12,13 @@ import SwiftUI class ShareExtensionViewController: UIViewController { private static var targetConfiguration: Target.ConfigurationResult? - private let appSettings: CommonSettingsProtocol = AppSettings() + private let appSettings: CommonSettingsProtocol = { + guard let userDefaults = TrackedUserDefaults(suiteName: AppSettings.suiteName) else { + fatalError("Catastrophic error retrieving user defaults for \(AppSettings.suiteName)") + } + return AppSettings(store: userDefaults) + }() + private var appHooks: AppHooks! private let keychainController = KeychainController(service: .sessions, diff --git a/Tools/Sourcery/PreviewTests.stencil b/Tools/Sourcery/PreviewTests.stencil index a4d23b096..2cc991920 100644 --- a/Tools/Sourcery/PreviewTests.stencil +++ b/Tools/Sourcery/PreviewTests.stencil @@ -28,7 +28,6 @@ extension PreviewTests { {% for type in types.types where (type.implements.TestablePreview or type.based.TestablePreview or type|annotated:"TestablePreview") and type.name != "TestablePreview" %} @Test func {{ type.name|replace:"_Previews", ""| lowerFirstLetter }}() async throws { - AppSettings.resetAllSettings() // Ensure this test's previews start with fresh settings. for (index, preview) in {{ type.name }}._allPreviews.enumerated() { try await assertSnapshots(matching: preview, step: index) } diff --git a/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift b/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift index 19910293b..9572ce333 100644 --- a/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/AnalyticsSettingsScreenViewModelTests.swift @@ -18,8 +18,7 @@ final class AnalyticsSettingsScreenViewModelTests { private var context: AnalyticsSettingsScreenViewModelType.Context! init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() let client = AnalyticsClientMock() client.isRunning = false analytics = AnalyticsService(client: client, appSettings: appSettings) @@ -29,10 +28,6 @@ final class AnalyticsSettingsScreenViewModelTests { context = viewModel.context } - deinit { - AppSettings.resetAllSettings() - } - @Test func initialState() { #expect(!context.enableAnalytics) diff --git a/UnitTests/Sources/AnalyticsTests.swift b/UnitTests/Sources/AnalyticsTests.swift index f079300c6..af12b5970 100644 --- a/UnitTests/Sources/AnalyticsTests.swift +++ b/UnitTests/Sources/AnalyticsTests.swift @@ -19,8 +19,7 @@ final class AnalyticsTests { @MainActor init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() analyticsClient = AnalyticsClientMock() analyticsClient.isRunning = false @@ -30,10 +29,6 @@ final class AnalyticsTests { posthogMock.configureMockBehavior() } - deinit { - AppSettings.resetAllSettings() - } - @Test func analyticsPromptNewUser() { // Given a fresh install of the app (without PostHog analytics having been set). diff --git a/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift index e5a4a143d..e673d7515 100644 --- a/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockScreenViewModelTests.swift @@ -21,17 +21,12 @@ final class AppLockScreenViewModelTests { } init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() keychainController = KeychainControllerMock() appLockService = AppLockService(keychainController: keychainController, appSettings: appSettings) viewModel = AppLockScreenViewModel(appLockService: appLockService) } - deinit { - AppSettings.resetAllSettings() - } - @Test func unlock() async throws { // Given a valid PIN code. diff --git a/UnitTests/Sources/AppLock/AppLockServiceTests.swift b/UnitTests/Sources/AppLock/AppLockServiceTests.swift index 628e7255c..fdeb86e62 100644 --- a/UnitTests/Sources/AppLock/AppLockServiceTests.swift +++ b/UnitTests/Sources/AppLock/AppLockServiceTests.swift @@ -17,8 +17,7 @@ final class AppLockServiceTests { private var service: AppLockService init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() keychainController = KeychainController(service: .tests, accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier) keychainController.resetSecrets() @@ -27,10 +26,6 @@ final class AppLockServiceTests { service.disable() } - deinit { - AppSettings.resetAllSettings() - } - // MARK: - PIN Code @Test diff --git a/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift index 69169ec54..169ae4f82 100644 --- a/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSettingsScreenViewModelTests.swift @@ -21,7 +21,7 @@ struct AppLockSetupSettingsScreenViewModelTests { init() { keychainController = KeychainControllerMock() - appLockService = AppLockService(keychainController: keychainController, appSettings: AppSettings()) + appLockService = AppLockService(keychainController: keychainController, appSettings: .volatile()) viewModel = AppLockSetupSettingsScreenViewModel(appLockService: AppLockServiceMock.mock()) } diff --git a/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift index 2d2d815e5..1898b2f31 100644 --- a/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSetupBiometricsScreenViewModelTests.swift @@ -19,8 +19,6 @@ final class AppLockSetupBiometricsScreenViewModelTests { } init() { - AppSettings.resetAllSettings() - appLockService = AppLockServiceMock() appLockService.underlyingIsEnabled = true appLockService.underlyingBiometryType = .touchID @@ -28,10 +26,6 @@ final class AppLockSetupBiometricsScreenViewModelTests { viewModel = AppLockSetupBiometricsScreenViewModel(appLockService: appLockService) } - deinit { - AppSettings.resetAllSettings() - } - @Test func allow() async throws { // When allowing Touch/Face ID. diff --git a/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift b/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift index d7e650668..fde9f4007 100644 --- a/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift +++ b/UnitTests/Sources/AppLock/AppLockSetupPINScreenViewModelTests.swift @@ -19,10 +19,6 @@ final class AppLockSetupPINScreenViewModelTests { viewModel.context } - deinit { - AppSettings.resetAllSettings() - } - @Test func createPIN() async throws { setup(mode: .create) @@ -187,9 +183,8 @@ final class AppLockSetupPINScreenViewModelTests { // MARK: - Helpers private func setup(mode: AppLockSetupPINScreenMode) { - AppSettings.resetAllSettings() keychainController = KeychainControllerMock() - appLockService = AppLockService(keychainController: keychainController, appSettings: AppSettings()) + appLockService = AppLockService(keychainController: keychainController, appSettings: .volatile()) viewModel = AppLockSetupPINScreenViewModel(initialMode: mode, isMandatory: false, appLockService: appLockService) } } diff --git a/UnitTests/Sources/AppRouteURLParserTests.swift b/UnitTests/Sources/AppRouteURLParserTests.swift index e1912810e..6f70edf3c 100644 --- a/UnitTests/Sources/AppRouteURLParserTests.swift +++ b/UnitTests/Sources/AppRouteURLParserTests.swift @@ -15,8 +15,7 @@ struct AppRouteURLParserTests { var appRouteURLParser: AppRouteURLParser init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() appRouteURLParser = AppRouteURLParser(appSettings: appSettings) } diff --git a/UnitTests/Sources/AuthenticationServiceTests.swift b/UnitTests/Sources/AuthenticationServiceTests.swift index 05b0e0702..046e5f60a 100644 --- a/UnitTests/Sources/AuthenticationServiceTests.swift +++ b/UnitTests/Sources/AuthenticationServiceTests.swift @@ -153,7 +153,7 @@ struct AuthenticationServiceTests { encryptionKeyProvider: encryptionKeyProvider, classicAppManager: classicAppManager, clientFactory: clientFactory, - appSettings: AppSettings(), + appSettings: .volatile(), appHooks: AppHooks()) if let classicAppAccount = service.classicAppAccount { diff --git a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift index 3ea882e34..de4953553 100644 --- a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift +++ b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift @@ -26,12 +26,7 @@ final class AuthenticationStartScreenViewModelTests { } init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() - } - - deinit { - AppSettings.resetAllSettings() + appSettings = AppSettings.volatile() } @Test diff --git a/UnitTests/Sources/BugReportServiceTests.swift b/UnitTests/Sources/BugReportServiceTests.swift index cba5c0988..07cee1365 100644 --- a/UnitTests/Sources/BugReportServiceTests.swift +++ b/UnitTests/Sources/BugReportServiceTests.swift @@ -16,8 +16,7 @@ final class BugReportServiceTests { var bugReportService: BugReportServiceProtocol! init() throws { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() appSettings.bugReportRageshakeURL.reset() let bugReportServiceMock = BugReportServiceMock() diff --git a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift index bbf418b49..c4fb079d2 100644 --- a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift +++ b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift @@ -31,7 +31,8 @@ struct ChatsTabFlowCoordinatorTests { } init() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() + clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))))) timelineControllerFactory = TimelineControllerFactoryMock(.init()) diff --git a/UnitTests/Sources/ComposerToolbarViewModelTests.swift b/UnitTests/Sources/ComposerToolbarViewModelTests.swift index bb2fa2fcf..fd6f03d98 100644 --- a/UnitTests/Sources/ComposerToolbarViewModelTests.swift +++ b/UnitTests/Sources/ComposerToolbarViewModelTests.swift @@ -21,15 +21,9 @@ final class ComposerToolbarViewModelTests { private var draftServiceMock: ComposerDraftServiceMock! init() { - AppSettings.resetAllSettings() - setUpViewModel() } - deinit { - AppSettings.resetAllSettings() - } - @Test func composerFocus() { viewModel.process(timelineAction: .setMode(mode: .edit(originalEventOrTransactionID: .eventID("mock"), type: .default))) @@ -89,7 +83,7 @@ final class ComposerToolbarViewModelTests { .init(suggestionType: .user(.init(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: nil)), range: .init(), rawSuggestionText: "")] let mockCompletionSuggestionService = CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()), wysiwygViewModel: wysiwygViewModel, @@ -708,7 +702,7 @@ final class ComposerToolbarViewModelTests { let mockSubject = CurrentValueSubject<[IdentityStatusChange], Never>([]) roomProxyMock.underlyingIdentityStatusChangesPublisher = mockSubject.asCurrentValuePublisher() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock, wysiwygViewModel: wysiwygViewModel, @@ -755,7 +749,7 @@ final class ComposerToolbarViewModelTests { roomProxyMock.underlyingIdentityStatusChangesPublisher = mockSubject.asCurrentValuePublisher() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock, wysiwygViewModel: wysiwygViewModel, @@ -791,7 +785,7 @@ final class ComposerToolbarViewModelTests { } roomProxyMock.underlyingIdentityStatusChangesPublisher = CurrentValueSubject([IdentityStatusChange(userId: "@alice:localhost", changedTo: .pinViolation)]).asCurrentValuePublisher() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock, wysiwygViewModel: wysiwygViewModel, @@ -816,7 +810,7 @@ final class ComposerToolbarViewModelTests { draftServiceMock.loadDraftClosure = loadDraftClosure } - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = ComposerToolbarViewModel(initialText: initialText, roomProxy: JoinedRoomProxyMock(.init()), diff --git a/UnitTests/Sources/CreateRoomViewModelTests.swift b/UnitTests/Sources/CreateRoomViewModelTests.swift index 5c7b2dcd0..b0cd0c85e 100644 --- a/UnitTests/Sources/CreateRoomViewModelTests.swift +++ b/UnitTests/Sources/CreateRoomViewModelTests.swift @@ -26,11 +26,10 @@ final class CreateRoomScreenViewModelTests { } init() { - appSettings = AppSettings() + appSettings = AppSettings.volatile() } deinit { - AppSettings.resetAllSettings() viewModel = nil clientProxy = nil spaceService = nil diff --git a/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift b/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift index bc0c2bb38..0d677280e 100644 --- a/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift +++ b/UnitTests/Sources/EmojiPickerScreenViewModelTests.swift @@ -45,7 +45,7 @@ struct EmojiPickerScreenViewModelTests { viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent, selectedEmojis: selectedEmojis, - emojiProvider: EmojiProvider(appSettings: AppSettings()), + emojiProvider: EmojiProvider(appSettings: .volatile()), timelineController: MockTimelineController(timelineProxy: timelineProxy)) } } diff --git a/UnitTests/Sources/EmojiProviderTests.swift b/UnitTests/Sources/EmojiProviderTests.swift index 7c599cbf7..c0d129231 100644 --- a/UnitTests/Sources/EmojiProviderTests.swift +++ b/UnitTests/Sources/EmojiProviderTests.swift @@ -19,7 +19,7 @@ struct EmojiProviderTests { let emojiLoaderMock = EmojiLoaderMock() emojiLoaderMock.categories = [category] - let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings()) + let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: .volatile()) let categories = await emojiProvider.categories() #expect(emojiLoaderMock.categories == categories) @@ -33,7 +33,7 @@ struct EmojiProviderTests { let emojiLoaderMock = EmojiLoaderMock() emojiLoaderMock.categories = [category] - let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings()) + let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: .volatile()) let categories = await emojiProvider.categories(searchString: "") #expect(emojiLoaderMock.categories == categories) @@ -51,7 +51,7 @@ struct EmojiProviderTests { let emojiLoaderMock = EmojiLoaderMock() emojiLoaderMock.categories = categoriesForFirstLoad - let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings()) + let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: .volatile()) _ = await emojiProvider.categories() emojiLoaderMock.categories = categoriesForSecondLoad @@ -82,7 +82,7 @@ struct EmojiProviderTests { let emojiLoaderMock = EmojiLoaderMock() emojiLoaderMock.categories = categories - let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings()) + let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: .volatile()) _ = await emojiProvider.categories() let result = await emojiProvider.categories(searchString: searchString) diff --git a/UnitTests/Sources/HomeScreenViewModelTests.swift b/UnitTests/Sources/HomeScreenViewModelTests.swift index b41ad8dde..99946d5c2 100644 --- a/UnitTests/Sources/HomeScreenViewModelTests.swift +++ b/UnitTests/Sources/HomeScreenViewModelTests.swift @@ -25,12 +25,7 @@ final class HomeScreenViewModelTests { var cancellables = Set() init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() - } - - deinit { - AppSettings.resetAllSettings() + appSettings = AppSettings.volatile() } @Test diff --git a/UnitTests/Sources/IdentityConfirmationScreenViewModelTests.swift b/UnitTests/Sources/IdentityConfirmationScreenViewModelTests.swift index 5b5f2f07c..f49d41aa9 100644 --- a/UnitTests/Sources/IdentityConfirmationScreenViewModelTests.swift +++ b/UnitTests/Sources/IdentityConfirmationScreenViewModelTests.swift @@ -109,7 +109,7 @@ struct IdentityConfirmationScreenViewModelTests { userSession.sessionSecurityStatePublisher = securityStateSubject.asCurrentValuePublisher() viewModel = IdentityConfirmationScreenViewModel(userSession: userSession, - appSettings: AppSettings(), + appSettings: .volatile(), userIndicatorController: UserIndicatorControllerMock()) } } diff --git a/UnitTests/Sources/InviteUsersViewModelTests.swift b/UnitTests/Sources/InviteUsersViewModelTests.swift index 7eae02263..d724fa31b 100644 --- a/UnitTests/Sources/InviteUsersViewModelTests.swift +++ b/UnitTests/Sources/InviteUsersViewModelTests.swift @@ -15,14 +15,6 @@ final class InviteUsersScreenViewModelTests { var viewModel: InviteUsersScreenViewModelProtocol! var userDiscoveryService: UserDiscoveryServiceMock! var clientProxy: ClientProxyMock! - - init() { - AppSettings.resetAllSettings() - } - - deinit { - AppSettings.resetAllSettings() - } var context: InviteUsersScreenViewModel.Context { viewModel.context @@ -179,7 +171,7 @@ final class InviteUsersScreenViewModelTests { isSkippable: false, userDiscoveryService: userDiscoveryService, userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) + appSettings: .volatile()) // The locked invitee starts pre-selected and locked. #expect(context.viewState.selectedUsers.map(\.userID) == [UserProfileProxy.mockAlice.userID]) @@ -244,7 +236,7 @@ final class InviteUsersScreenViewModelTests { isSkippable: isSkippable, userDiscoveryService: userDiscoveryService, userIndicatorController: UserIndicatorControllerMock(), - appSettings: AppSettings()) + appSettings: .volatile()) viewModel.state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie]) self.viewModel = viewModel } diff --git a/UnitTests/Sources/JoinRoomScreenViewModelTests.swift b/UnitTests/Sources/JoinRoomScreenViewModelTests.swift index 1a4025252..509fd631b 100644 --- a/UnitTests/Sources/JoinRoomScreenViewModelTests.swift +++ b/UnitTests/Sources/JoinRoomScreenViewModelTests.swift @@ -29,14 +29,12 @@ final class JoinRoomScreenViewModelTests { private let appSettings: AppSettings init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() } deinit { viewModel = nil clientProxy = nil - AppSettings.resetAllSettings() } @Test diff --git a/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift b/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift index 14b5db4b4..e1a9588bf 100644 --- a/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift +++ b/UnitTests/Sources/KnockRequestsListScreenViewModelTests.swift @@ -11,10 +11,6 @@ import Testing @MainActor struct KnockRequestsListScreenViewModelTests { - init() { - AppSettings.resetAllSettings() - } - @Test func loadingState() async throws { let roomProxyMock = JoinedRoomProxyMock(.init(knockRequestsState: .loading, joinRule: .knock)) diff --git a/UnitTests/Sources/LiveLocationManagerTests.swift b/UnitTests/Sources/LiveLocationManagerTests.swift index eee05c3c0..548d2c05a 100644 --- a/UnitTests/Sources/LiveLocationManagerTests.swift +++ b/UnitTests/Sources/LiveLocationManagerTests.swift @@ -19,14 +19,6 @@ final class LiveLocationManagerTests { private var appSettings: AppSettings! private var beaconInfoSubject: PassthroughSubject! - init() { - AppSettings.resetAllSettings() - } - - deinit { - AppSettings.resetAllSettings() - } - // MARK: - startLiveLocation @Test @@ -236,7 +228,7 @@ final class LiveLocationManagerTests { } private func setUp(accuracyAuthorization: CLAccuracyAuthorization = .fullAccuracy) { - appSettings = AppSettings() + appSettings = AppSettings.volatile() clientProxy = ClientProxyMock(.init()) beaconInfoSubject = PassthroughSubject() clientProxy.liveLocationOwnInfoUpdatesPublisher = beaconInfoSubject.eraseToAnyPublisher() diff --git a/UnitTests/Sources/LocationSharingScreenViewModelTests.swift b/UnitTests/Sources/LocationSharingScreenViewModelTests.swift index 9ef2b2b20..878720a46 100644 --- a/UnitTests/Sources/LocationSharingScreenViewModelTests.swift +++ b/UnitTests/Sources/LocationSharingScreenViewModelTests.swift @@ -394,7 +394,7 @@ struct LocationSharingScreenViewModelTests { let roomProxyMock = JoinedRoomProxyMock(.init(members: .allMembers)) roomProxyMock.makeLiveLocationServiceReturnValue = liveLocationServiceMock - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() viewModel = LocationSharingScreenViewModel(interactionMode: .viewLive(sender: nil, initialLiveLocationShare: nil), mapURLBuilder: appSettings.mapTilerConfiguration, @@ -429,7 +429,7 @@ struct LocationSharingScreenViewModelTests { private mutating func setupViewModel(liveLocationManagerConfiguration: LiveLocationManagerMock.Configuration = .init(), members: [RoomMemberProxyMock] = .allMembersAsAdmin) { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() timelineProxy = TimelineProxyMock(.init()) viewModel = LocationSharingScreenViewModel(interactionMode: .picker(shouldShowLiveLocationOption: true), mapURLBuilder: appSettings.mapTilerConfiguration, @@ -444,7 +444,7 @@ struct LocationSharingScreenViewModelTests { private mutating func setupViewModel(liveLocationManagerMock: LiveLocationManagerMock, members: [RoomMemberProxyMock] = .allMembersAsAdmin) { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() timelineProxy = TimelineProxyMock(.init()) viewModel = LocationSharingScreenViewModel(interactionMode: .picker(shouldShowLiveLocationOption: true), mapURLBuilder: appSettings.mapTilerConfiguration, @@ -461,7 +461,7 @@ struct LocationSharingScreenViewModelTests { initialShare: LiveLocationShare, liveLocationsSubject: CurrentValueSubject<[LiveLocationShare], Never>, members: [RoomMemberProxyMock] = .allMembers) { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let liveLocationServiceMock = RoomLiveLocationServiceMock() liveLocationServiceMock.liveLocationsPublisher = liveLocationsSubject.asCurrentValuePublisher() diff --git a/UnitTests/Sources/LoginScreenViewModelTests.swift b/UnitTests/Sources/LoginScreenViewModelTests.swift index c57b4e4ae..c45d00400 100644 --- a/UnitTests/Sources/LoginScreenViewModelTests.swift +++ b/UnitTests/Sources/LoginScreenViewModelTests.swift @@ -227,7 +227,7 @@ struct LoginScreenViewModelTests { // MARK: - Helpers private mutating func setupViewModel(homeserverAddress: String = "example.com", loginHint: String? = nil) async { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() clientFactory = AuthenticationClientFactoryMock(configuration: .init()) service = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()), diff --git a/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift b/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift index 565f93f8b..072cdf2df 100644 --- a/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift +++ b/UnitTests/Sources/MediaUploadPreviewScreenViewModelTests.swift @@ -28,17 +28,12 @@ final class MediaUploadPreviewScreenViewModelTests { } init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() appSettings.optimizeMediaUploads = false userIndicatorController = UserIndicatorControllerMock.default } - deinit { - AppSettings.resetAllSettings() - } - @Test func imageUploadWithoutCaption() async throws { setUpViewModel(urls: [imageURL], expectedCaption: nil) diff --git a/UnitTests/Sources/MediaUploadingPreprocessorTests.swift b/UnitTests/Sources/MediaUploadingPreprocessorTests.swift index f2479badc..139994ab7 100644 --- a/UnitTests/Sources/MediaUploadingPreprocessorTests.swift +++ b/UnitTests/Sources/MediaUploadingPreprocessorTests.swift @@ -17,16 +17,11 @@ final class MediaUploadingPreprocessorTests { var mediaUploadingPreprocessor: MediaUploadingPreprocessor! init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() appSettings.optimizeMediaUploads = false mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings) } - deinit { - AppSettings.resetAllSettings() - } - @Test func audioFileProcessing() async throws { let url = try #require(Bundle(for: Self.self).url(forResource: "test_audio.mp3", withExtension: nil), "Failed retrieving test asset") diff --git a/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift b/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift index bfae29677..6f8662b99 100644 --- a/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift +++ b/UnitTests/Sources/NotificationManager/NotificationManagerTests.swift @@ -25,8 +25,7 @@ final class NotificationManagerTests { private let appSettings: AppSettings init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() notificationCenter = UserNotificationCenterMock() notificationCenter.requestAuthorizationOptionsReturnValue = true notificationCenter.authorizationStatusReturnValue = .authorized diff --git a/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift b/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift index 5761455c1..01972db12 100644 --- a/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/NotificationSettingsScreenViewModelTests.swift @@ -21,11 +21,9 @@ struct NotificationSettingsScreenViewModelTests { private var toneManager: NotificationToneManagerMock init() throws { - AppSettings.resetAllSettings() - userNotificationCenter = UserNotificationCenterMock() userNotificationCenter.authorizationStatusReturnValue = .authorized - appSettings = AppSettings() + appSettings = AppSettings.volatile() notificationSettingsProxy = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) notificationSettingsProxy.getDefaultRoomNotificationModeIsEncryptedIsOneToOneReturnValue = .allMessages notificationSettingsProxy.isRoomMentionEnabledReturnValue = true diff --git a/UnitTests/Sources/NotificationToneManagerTests.swift b/UnitTests/Sources/NotificationToneManagerTests.swift index cb9eab0f7..677423833 100644 --- a/UnitTests/Sources/NotificationToneManagerTests.swift +++ b/UnitTests/Sources/NotificationToneManagerTests.swift @@ -18,8 +18,7 @@ struct NotificationToneManagerTests { private let manager: NotificationToneManager init() { - AppSettings.resetAllSettings() - manager = NotificationToneManager(appSettings: AppSettings()) + manager = NotificationToneManager(appSettings: .volatile()) } // MARK: - Deletion diff --git a/UnitTests/Sources/PillContextTests.swift b/UnitTests/Sources/PillContextTests.swift index 028058800..d412368b9 100644 --- a/UnitTests/Sources/PillContextTests.swift +++ b/UnitTests/Sources/PillContextTests.swift @@ -15,7 +15,7 @@ import Testing struct PillContextTests { @Test func user() async { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let id = "@test:matrix.org" @@ -49,7 +49,7 @@ struct PillContextTests { @Test func ownUser() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let id = "@test:matrix.org" @@ -74,7 +74,7 @@ struct PillContextTests { @Test func allUsers() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let avatarURL = URL(string: "https://matrix.jpg") @@ -102,7 +102,7 @@ struct PillContextTests { @Test func roomIDMention() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -130,7 +130,7 @@ struct PillContextTests { @Test func roomIDMentionMissingRoom() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -156,7 +156,7 @@ struct PillContextTests { @Test func roomAliasMention() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -186,7 +186,7 @@ struct PillContextTests { @Test func roomAliasMentionMissingRoom() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -212,7 +212,7 @@ struct PillContextTests { @Test func eventOnRoomIDMention() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -240,7 +240,7 @@ struct PillContextTests { @Test func eventOnRoomIDMentionMissingRoom() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -266,7 +266,7 @@ struct PillContextTests { @Test func eventOnRoomAliasMention() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) @@ -296,7 +296,7 @@ struct PillContextTests { @Test func eventOnRoomAliasMentionMissingRoom() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userIndicatorController = UserIndicatorControllerMock.default let proxyMock = JoinedRoomProxyMock(.init()) diff --git a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift index 4bdc1cbf2..b9d049aaf 100644 --- a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift @@ -167,7 +167,7 @@ struct RoomDetailsEditScreenViewModelTests { userIndicatorController = UserIndicatorControllerMock.default viewModel = .init(roomProxy: JoinedRoomProxyMock(roomProxyConfiguration), userSession: UserSessionMock(.init()), - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), userIndicatorController: userIndicatorController) } } diff --git a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift index 7f8dde7f4..b662fb868 100644 --- a/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsScreenViewModelTests.swift @@ -25,7 +25,6 @@ struct RoomDetailsScreenViewModelTests { var cancellables = Set() init() { - AppSettings.resetAllSettings() cancellables.removeAll() roomProxyMock = JoinedRoomProxyMock(.init(name: "Test")) notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) @@ -35,7 +34,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) } @Test @@ -48,7 +47,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil } context.send(viewAction: .processTapLeave) @@ -68,7 +67,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil } context.send(viewAction: .processTapLeave) @@ -89,7 +88,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) context.send(viewAction: .processTapLeave) #expect(context.leaveRoomAlertItem?.state == .empty) @@ -147,7 +146,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil } @@ -168,7 +167,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil } @@ -199,7 +198,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil } @@ -229,7 +228,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil } @@ -260,7 +259,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil } @@ -292,7 +291,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -309,7 +308,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -361,7 +360,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -400,7 +399,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -439,7 +438,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -459,7 +458,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -479,7 +478,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()), attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) _ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first() @@ -497,7 +496,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) var deferred = deferFulfillment(context.observe(\.viewState.notificationSettingsState)) { $0.isError } @@ -705,7 +704,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState)) { state in state.knockRequestsCount == 2 && state.canSeeKnockingRequests @@ -726,7 +725,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState)) { state in state.knockRequestsCount == 0 && state.canSeeKnockingRequests @@ -749,7 +748,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState)) { state in state.knockRequestsCount == 2 && @@ -772,7 +771,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferred = deferFulfillment(context.observe(\.viewState)) { state in state.knockRequestsCount == 2 && @@ -799,7 +798,7 @@ struct RoomDetailsScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock.default, notificationSettingsProxy: notificationSettingsProxyMock, attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()), - appSettings: AppSettings()) + appSettings: .volatile()) let deferredShared = deferFulfillment(context.observe(\.viewState), message: "The pill should be shown for rooms with shared history visibility") { state in diff --git a/UnitTests/Sources/RoomFlowCoordinatorTests.swift b/UnitTests/Sources/RoomFlowCoordinatorTests.swift index a9685efd1..2fab28f4e 100644 --- a/UnitTests/Sources/RoomFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomFlowCoordinatorTests.swift @@ -22,13 +22,9 @@ final class RoomFlowCoordinatorTests { private let appSettings: AppSettings init() { - appSettings = AppSettings() + appSettings = AppSettings.volatile() } - deinit { - AppSettings.resetAllSettings() - } - @Test func roomPresentation() async throws { setupRoomFlowCoordinator() diff --git a/UnitTests/Sources/RoomListFiltersStateTests.swift b/UnitTests/Sources/RoomListFiltersStateTests.swift index c7d28b763..092b1b29e 100644 --- a/UnitTests/Sources/RoomListFiltersStateTests.swift +++ b/UnitTests/Sources/RoomListFiltersStateTests.swift @@ -15,15 +15,10 @@ final class RoomListFiltersStateTests { let allCasesWithoutLowPriority = RoomListFilter.allCases.filter { $0 != .lowPriority } init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() state = RoomListFiltersState(appSettings: appSettings) } - deinit { - AppSettings.resetAllSettings() - } - @Test func initialState() { #expect(!state.isFiltering) diff --git a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift index 5801fa582..7fb7bee31 100644 --- a/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift +++ b/UnitTests/Sources/RoomMemberDetailsViewModelTests.swift @@ -213,6 +213,6 @@ struct RoomMemberDetailsViewModelTests { userSession: userSession, userIndicatorController: UserIndicatorControllerMock.default, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) } } diff --git a/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift b/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift index 18cd97675..7aef41b2b 100644 --- a/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomMembersFlowCoordinatorTests.swift @@ -51,7 +51,7 @@ struct RoomMembersFlowCoordinatorTests { let clientProxy = ClientProxyMock(.init()) clientProxy.directRoomForUserIDReturnValue = .success(nil) - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let flowParameters = CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), bugReportService: BugReportServiceMock(.init()), diff --git a/UnitTests/Sources/RoomScreenViewModelTests.swift b/UnitTests/Sources/RoomScreenViewModelTests.swift index cd3c62a21..efe67087b 100644 --- a/UnitTests/Sources/RoomScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomScreenViewModelTests.swift @@ -20,12 +20,7 @@ final class RoomScreenViewModelTests { private let appSettings: AppSettings init() async throws { - AppSettings.resetAllSettings() - appSettings = AppSettings() - } - - deinit { - AppSettings.resetAllSettings() + appSettings = AppSettings.volatile() } @Test diff --git a/UnitTests/Sources/RoomSummaryProviderTests.swift b/UnitTests/Sources/RoomSummaryProviderTests.swift index c3b2dc194..4c47d3c36 100644 --- a/UnitTests/Sources/RoomSummaryProviderTests.swift +++ b/UnitTests/Sources/RoomSummaryProviderTests.swift @@ -22,10 +22,6 @@ final class RoomSummaryProviderTests { var dynamicEntriesController: RoomListDynamicEntriesControllerSDKMock! var roomSummaryProvider: RoomSummaryProvider! - deinit { - AppSettings.resetAllSettings() - } - @Test func defaultRustFilters() async { // Given a new room provider. @@ -94,8 +90,7 @@ final class RoomSummaryProviderTests { // MARK: - Helpers private func setup(isLowPriorityFilterEnabled: Bool = false) { - AppSettings.resetAllSettings() - appSettings = AppSettings() + appSettings = AppSettings.volatile() appSettings.lowPriorityFilterEnabled = isLowPriorityFilterEnabled let stateEventStringBuilder = RoomStateEventStringBuilder(userID: "@me:matrix.org") diff --git a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift index ba0ddde69..225a82634 100644 --- a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift +++ b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift @@ -20,15 +20,10 @@ final class SecurityAndPrivacyScreenViewModelTests { var context: SecurityAndPrivacyScreenViewModelType.Context { viewModel.context } - - init() { - AppSettings.resetAllSettings() - } - + deinit { viewModel = nil roomProxy = nil - AppSettings.resetAllSettings() } @Test @@ -444,7 +439,7 @@ final class SecurityAndPrivacyScreenViewModelTests { private func setupViewModel(joinedParentSpaces: [SpaceServiceRoom], topLevelSpaces: [SpaceServiceRoom] = [], joinRule: ElementX.JoinRule) { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() appSettings.knockingEnabled = true roomProxy = JoinedRoomProxyMock(.init(isEncrypted: false, canonicalAlias: "#room:matrix.org", diff --git a/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift b/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift index 2c762b923..275176352 100644 --- a/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift +++ b/UnitTests/Sources/ServerConfirmationScreenViewModelTests.swift @@ -25,12 +25,7 @@ final class ServerConfirmationScreenViewModelTests { private let appSettings: AppSettings init() { - AppSettings.resetAllSettings() - appSettings = AppSettings() - } - - deinit { - AppSettings.resetAllSettings() + appSettings = AppSettings.volatile() } // MARK: - Confirmation mode diff --git a/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift b/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift index 780035dca..8d188f73b 100644 --- a/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift +++ b/UnitTests/Sources/ServerSelectionScreenViewModelTests.swift @@ -148,7 +148,7 @@ struct ServerSelectionScreenViewModelTests { // MARK: - Helpers private mutating func setup(authenticationFlow: AuthenticationFlow) { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() clientFactory = AuthenticationClientFactoryMock(configuration: .init()) service = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()), diff --git a/UnitTests/Sources/SessionVerificationViewModelTests.swift b/UnitTests/Sources/SessionVerificationViewModelTests.swift index c94ae5436..c3e3a4d42 100644 --- a/UnitTests/Sources/SessionVerificationViewModelTests.swift +++ b/UnitTests/Sources/SessionVerificationViewModelTests.swift @@ -21,7 +21,7 @@ struct SessionVerificationViewModelTests { sessionVerificationController = SessionVerificationControllerProxyMock.configureMock() viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: sessionVerificationController, flow: .deviceInitiator, - appSettings: AppSettings(), + appSettings: .volatile(), mediaProvider: MediaProviderMock(configuration: .init())) context = viewModel.context } diff --git a/UnitTests/Sources/SettingsScreenViewModelTests.swift b/UnitTests/Sources/SettingsScreenViewModelTests.swift index 1910bca93..793c6049f 100644 --- a/UnitTests/Sources/SettingsScreenViewModelTests.swift +++ b/UnitTests/Sources/SettingsScreenViewModelTests.swift @@ -16,7 +16,7 @@ struct SettingsScreenViewModelTests { private var context: SettingsScreenViewModelType.Context init() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "")))) viewModel = SettingsScreenViewModel(userSession: userSession, appSettings: appSettings, diff --git a/UnitTests/Sources/SpaceListScreenViewModelTests.swift b/UnitTests/Sources/SpaceListScreenViewModelTests.swift index 169af544b..1978bd4a9 100644 --- a/UnitTests/Sources/SpaceListScreenViewModelTests.swift +++ b/UnitTests/Sources/SpaceListScreenViewModelTests.swift @@ -22,8 +22,7 @@ final class SpacesScreenViewModelTests { } init() { - AppSettings.resetAllSettings() - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let clientProxy = ClientProxyMock(.init()) let userSession = UserSessionMock(.init(clientProxy: clientProxy)) @@ -47,10 +46,6 @@ final class SpacesScreenViewModelTests { userIndicatorController: UserIndicatorControllerMock()) } - deinit { - AppSettings.resetAllSettings() - } - @Test func initialState() { #expect(context.viewState.topLevelSpaces.count == 3) diff --git a/UnitTests/Sources/StartChatViewModelTests.swift b/UnitTests/Sources/StartChatViewModelTests.swift index 9a2ea1e6a..d2a27bdcb 100644 --- a/UnitTests/Sources/StartChatViewModelTests.swift +++ b/UnitTests/Sources/StartChatViewModelTests.swift @@ -20,7 +20,7 @@ struct StartChatScreenViewModelTests { } init() { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() clientProxy = .init(.init(userID: "")) userDiscoveryService = UserDiscoveryServiceMock() diff --git a/UnitTests/Sources/TimelineViewModelTests.swift b/UnitTests/Sources/TimelineViewModelTests.swift index 1de14dbde..eda641a75 100644 --- a/UnitTests/Sources/TimelineViewModelTests.swift +++ b/UnitTests/Sources/TimelineViewModelTests.swift @@ -17,7 +17,6 @@ final class TimelineViewModelTests { var cancellables = Set() init() async throws { - AppSettings.resetAllSettings() cancellables.removeAll() } @@ -307,7 +306,7 @@ final class TimelineViewModelTests { timelineController.timelineItems = items timelineController.roomProxy = roomProxy - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let viewModel = TimelineViewModel(roomProxy: roomProxy, timelineController: timelineController, @@ -333,7 +332,7 @@ final class TimelineViewModelTests { addReadReceipts: receipts) let id = message.id - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() // When showing them in a timeline. let timelineController = MockTimelineController() @@ -360,7 +359,7 @@ final class TimelineViewModelTests { @Test func showManageUserAsAdmin() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "", members: [RoomMemberProxyMock.mockAdmin, @@ -399,7 +398,7 @@ final class TimelineViewModelTests { @Test func showDetailsForAnAdmin() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "", members: [RoomMemberProxyMock.mockAdmin, @@ -438,7 +437,7 @@ final class TimelineViewModelTests { @Test func showDetailsForABannedUser() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "", members: [RoomMemberProxyMock.mockAdmin, @@ -480,7 +479,7 @@ final class TimelineViewModelTests { @Test func pinnedEvents() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() var configuration = JoinedRoomProxyMockConfiguration(name: "", pinnedEventIDs: .init(["test1"])) @@ -511,7 +510,7 @@ final class TimelineViewModelTests { @Test func canUserPinEvents() async throws { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let configuration = JoinedRoomProxyMockConfiguration(name: "", powerLevelsConfiguration: .init(canUserPin: true)) @@ -588,7 +587,7 @@ final class TimelineViewModelTests { private func makeViewModel(roomProxy: JoinedRoomProxyProtocol? = nil, focussedEventID: String? = nil, timelineController: TimelineControllerProtocol) -> TimelineViewModel { - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() return TimelineViewModel(roomProxy: roomProxy ?? JoinedRoomProxyMock(.init(name: "")), focussedEventID: focussedEventID, diff --git a/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift index f4e198a93..f07b5425c 100644 --- a/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/UserDetailsEditScreenViewModelTests.swift @@ -20,7 +20,7 @@ struct UserDetailsEditScreenViewModelTests { init() { viewModel = .init(userSession: UserSessionMock(.init()), - mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()), + mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()), userIndicatorController: UserIndicatorControllerMock.default) } diff --git a/UnitTests/Sources/UserPreferenceTests.swift b/UnitTests/Sources/UserPreferenceTests.swift index 0852e539f..03ce0660f 100644 --- a/UnitTests/Sources/UserPreferenceTests.swift +++ b/UnitTests/Sources/UserPreferenceTests.swift @@ -11,128 +11,131 @@ import Foundation import Testing struct UserPreferenceTests { - init() { - UserDefaults.testDefaults.removeVolatileDomain(forName: .userDefaultsSuiteName) - UserDefaults.testDefaults.removePersistentDomain(forName: .userDefaultsSuiteName) - } - @Test func storePlistValue() { + let testDefaults = VolatileUserDefaults() let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.plist = "Hello" } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) #expect(value.plist == "Hello") - #expect(UserDefaults.testDefaults.string(forKey: .key2) != nil) - #expect(UserDefaults.testDefaults.data(forKey: .key2) == nil) + #expect(testDefaults.object(forKey: TestsKey.key2.rawValue) is String) + #expect(testDefaults.data(forKey: TestsKey.key2.rawValue) == nil) } @Test func storeCodableValue() { + let testDefaults = VolatileUserDefaults() let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.codable = storedType } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) #expect(value.codable == storedType) - #expect(UserDefaults.testDefaults.data(forKey: .key3) != nil) + #expect(testDefaults.data(forKey: TestsKey.key3.rawValue) != nil) } @Test func storePlistValueOnVolatileStorage() { + let testDefaults = VolatileUserDefaults() let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.volatileVar = "Hello" } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) #expect(value.volatileVar == nil) } @Test func storeCodableValueOnVolatileStorage() { + let testDefaults = VolatileUserDefaults() let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.volatileCodable = storedType } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) #expect(value.volatileCodable == nil) - #expect(UserDefaults.testDefaults.data(forKey: .key4) == nil) + #expect(testDefaults.data(forKey: TestsKey.key4.rawValue) == nil) } @Test func storePlistArray() { + let testDefaults = VolatileUserDefaults() let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.plistArray = [1, 2, 3] } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) #expect(value.plistArray == [1, 2, 3]) - #expect(UserDefaults.testDefaults.array(forKey: .key5) as? [Int] == [1, 2, 3]) - #expect(UserDefaults.testDefaults.data(forKey: .key5) == nil) + #expect(testDefaults.object(forKey: TestsKey.key5.rawValue) as? [Int] == [1, 2, 3]) + #expect(testDefaults.data(forKey: TestsKey.key5.rawValue) == nil) } @Test func assignNilToPlistType() { + let testDefaults = VolatileUserDefaults() let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.plist = "Hello" } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.plist = nil #expect(value.plist == nil) - #expect(UserDefaults.testDefaults.string(forKey: .key2) == nil) + #expect(testDefaults.object(forKey: TestsKey.key2.rawValue) as? String == nil) } @Test func assignNilToCodableType() { + let testDefaults = VolatileUserDefaults() let storedType = CodableTestType(a: "some", b: [1, 2, 3]) let setPreference = { - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.codable = storedType } setPreference() - let value = TestPreferences() + let value = TestPreferences(testDefaults) value.codable = nil #expect(value.codable == nil) - #expect(UserDefaults.testDefaults.data(forKey: .key3) == nil) + #expect(testDefaults.data(forKey: TestsKey.key3.rawValue) == nil) } @Test func localOverRemoteValue() { - @UserPreference(key: "testKey", defaultValue: "", storageType: .userDefaults(.testDefaults)) var preference + let storage = VolatileUserDefaults() + @UserPreference(key: TestsKey.testKey, defaultValue: "", storage: storage) var preference #expect(preference == "") _preference.remoteValue = "remote" @@ -144,7 +147,8 @@ struct UserPreferenceTests { @Test func remoteOverLocalValue() { - @UserPreference(key: "testKey", defaultValue: "", storageType: .userDefaults(.testDefaults), mode: .remoteOverLocal) var preference + let storage = VolatileUserDefaults() + @UserPreference(key: TestsKey.testKey, defaultValue: "", storage: storage, mode: .remoteOverLocal) var preference #expect(preference == "") _preference.remoteValue = "remote" @@ -157,20 +161,28 @@ struct UserPreferenceTests { } private struct TestPreferences { - @UserPreference(key: .key1, storageType: .volatile) + @UserPreference var volatileVar: String? - @UserPreference(key: .key2, storageType: .userDefaults(.testDefaults)) + @UserPreference var plist: String? - @UserPreference(key: .key3, storageType: .userDefaults(.testDefaults)) + @UserPreference var codable: CodableTestType? - @UserPreference(key: .key4, storageType: .volatile) + @UserPreference var volatileCodable: CodableTestType? - @UserPreference(key: .key5, storageType: .userDefaults(.testDefaults)) + @UserPreference var plistArray: [Int]? + + init(_ storage: UserDefaultsProtocol) { + _volatileVar = UserPreference(key: TestsKey.key1, storage: VolatileUserDefaults()) + _plist = UserPreference(key: TestsKey.key2, storage: storage) + _codable = UserPreference(key: TestsKey.key3, storage: storage) + _volatileCodable = UserPreference(key: TestsKey.key4, storage: VolatileUserDefaults()) + _plistArray = UserPreference(key: TestsKey.key5, storage: storage) + } } private struct CodableTestType: Equatable, Codable { @@ -178,16 +190,13 @@ private struct CodableTestType: Equatable, Codable { let b: [Int] } -private extension String { - static let key1 = "foo.volatile" - static let key2 = "foo.plist" - static let key3 = "foo.codable" - static let key4 = "foo.volatile.codable" - static let key5 = "foo.plist.array" - static let userDefaultsSuiteName = "io.element.elementx.unitests" -} - -private extension UserDefaults { - // swiftlint:disable:next force_unwrapping - static let testDefaults = UserDefaults(suiteName: .userDefaultsSuiteName)! +private struct TestsKey: PreferenceKeyable, RawRepresentable { + static let testKey = Self(rawValue: "testKey") + static let key1 = Self(rawValue: "foo.volatile") + static let key2 = Self(rawValue: "foo.plist") + static let key3 = Self(rawValue: "foo.codable") + static let key4 = Self(rawValue: "foo.volatile.codable") + static let key5 = Self(rawValue: "foo.plist.array") + + let rawValue: String } diff --git a/UnitTests/Sources/UserProfileScreenViewModelTests.swift b/UnitTests/Sources/UserProfileScreenViewModelTests.swift index 687f9f585..e484cd12e 100644 --- a/UnitTests/Sources/UserProfileScreenViewModelTests.swift +++ b/UnitTests/Sources/UserProfileScreenViewModelTests.swift @@ -24,7 +24,7 @@ struct UserProfileScreenViewModelTests { userSession: UserSessionMock(.init(clientProxy: clientProxy)), userIndicatorController: userIndicatorController, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) let context = viewModel.context let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil } @@ -48,7 +48,7 @@ struct UserProfileScreenViewModelTests { userSession: UserSessionMock(.init(clientProxy: clientProxy)), userIndicatorController: userIndicatorController, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) let context = viewModel.context let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil } @@ -74,7 +74,7 @@ struct UserProfileScreenViewModelTests { userSession: UserSessionMock(.init(clientProxy: clientProxy)), userIndicatorController: userIndicatorController, analytics: AnalyticsServiceMock.default, - appSettings: AppSettings()) + appSettings: .volatile()) let context = viewModel.context diff --git a/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift b/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift index 3b402e1c3..5a060018a 100644 --- a/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift +++ b/UnitTests/Sources/UserSessionFlowCoordinatorTests.swift @@ -50,7 +50,7 @@ struct UserSessionFlowCoordinatorTests { appMediator.networkMonitor = networkMonitor userIndicatorController = UserIndicatorControllerMock.default - let appSettings = AppSettings() + let appSettings = AppSettings.volatile() let flowParameters = CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)), bugReportService: BugReportServiceMock(.init()),