mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Prompt user when inviting users with uncached identities (#5331)
If the user attempts to invite someone (to a room or creating a DM) whose identity is not cached, we prompt them to make sure this was their intention.
This commit is contained in:
@@ -21,7 +21,8 @@ struct UserProfileScreenViewModelTests {
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
let context = viewModel.context
|
||||
|
||||
let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil }
|
||||
@@ -42,7 +43,8 @@ struct UserProfileScreenViewModelTests {
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
let context = viewModel.context
|
||||
|
||||
let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil }
|
||||
@@ -52,4 +54,32 @@ struct UserProfileScreenViewModelTests {
|
||||
#expect(context.viewState.userProfile == profile)
|
||||
#expect(context.viewState.permalink != nil)
|
||||
}
|
||||
|
||||
@Test
|
||||
func startingDmWithUnknownUserFetchesIdentity() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
|
||||
let profile = UserProfileProxy.mockAlice
|
||||
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
clientProxy.userIdentityForFallBackToServerReturnValue = .success(nil)
|
||||
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.userID,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
|
||||
let context = viewModel.context
|
||||
|
||||
let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil }
|
||||
try await waitForMemberToLoad.fulfill()
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings).compactMap(\.inviteConfirmationUser), timeout: .seconds(5)) { $0.isUnknown }
|
||||
|
||||
context.send(viewAction: .openDirectChat)
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user