Prompt user when inviting users with uncached identities#5331
Prompt user when inviting users with uncached identities#5331
Conversation
6a44d49 to
edeaec7
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5331 +/- ##
===========================================
+ Coverage 74.38% 74.46% +0.07%
===========================================
Files 800 801 +1
Lines 53519 53639 +120
===========================================
+ Hits 39811 39940 +129
+ Misses 13708 13699 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
d6c1c97 to
2761e63
Compare
2761e63 to
11c98cb
Compare
| import Compound | ||
| import SwiftUI | ||
|
|
||
| struct ConfirmInviteUsersSheetView: View { |
There was a problem hiding this comment.
I am wondering if it would be better to repurpose the existing SendInviteConfirmationView to support arbitrary numbers of members, but this seems to suffice for now.
There was a problem hiding this comment.
I think it's fine too keep them separate but can we maybe name it InviteUsersConfirmationView so it somewhat matches the other one?
| Task { @MainActor in | ||
| // If we do not, we will prompt the user to confirm they meant to invite them. | ||
| self.state.usersToConfirm.append(user) | ||
| } |
There was a problem hiding this comment.
There is a potential race condition here, but I'm not sure how to fix it and since we're only loading from the store, these tasks should be very short-lived.
There was a problem hiding this comment.
these tasks should be very short-lived
I agree so why not run them directly on the current actor?
| MXLog.error("Failed to get cached user identity for \(user.userID)") | ||
| return |
There was a problem hiding this comment.
It might be worth appending here even in the case of failure, like the changes to the other view models do.
|
I can't see why the Apple CI is failing, but otherwise I believe this is ready for review. |
stefanceriu
left a comment
There was a problem hiding this comment.
Looking good, nice start 👍
| "crypto_history_sharing_confirm_invite_dialog_title" = "Invite new contacts to this room?"; | ||
| "crypto_history_sharing_confirm_invite_dialog_content" = "You currently don’t have any chats with these contacts. Confirm inviting them to this room before continuing."; | ||
| "crypto_history_sharing_confirm_start_chat_dialog_title" = "Start a chat with this new contact?"; | ||
| "crypto_history_sharing_confirm_start_chat_dialog_content" = "You currently don’t have any chats with this person. Confirm inviting them before continuing."; |
There was a problem hiding this comment.
Should these have made it to localazy already?
There was a problem hiding this comment.
It's on my list of things to do!
| import Compound | ||
| import SwiftUI | ||
|
|
||
| struct ConfirmInviteUsersSheetView: View { |
There was a problem hiding this comment.
I think it's fine too keep them separate but can we maybe name it InviteUsersConfirmationView so it somewhat matches the other one?
| /// Whether we are showing the confirmation dialog. | ||
| var presentConfirmationDialog = false |
There was a problem hiding this comment.
Can we infer this from usersToConfirm and have it be computed instead or at least set when that changes? 🤔
| Task { @MainActor in | ||
| // If we do not, we will prompt the user to confirm they meant to invite them. | ||
| self.state.usersToConfirm.append(user) | ||
| } |
There was a problem hiding this comment.
these tasks should be very short-lived
I agree so why not run them directly on the current actor?
| MXLog.error("Failed to get cached user identity for \(user.userID)") | ||
| return |
| self.state.bindings.inviteConfirmationUserIdentityKnown = switch identity { | ||
| case .success(let identity): identity != nil | ||
| default: false | ||
| } |
There was a problem hiding this comment.
Can also be written as
self.state.bindings.inviteConfirmationUserIdentityKnown = if case .success(let identity) = await self.userSession.clientProxy.userIdentity(for: roomMemberProxy.userID, fallBackToServer: false) {
identity != nil
} else {
false
}
|
|
||
| struct SendInviteConfirmationView: View { | ||
| let userToInvite: UserProfileProxy | ||
| let userIdentityKnown: Bool |
There was a problem hiding this comment.
I would rename this to isUserIdentityKnown
| SendInviteConfirmationView(userToInvite: .mockBob, | ||
| userIdentityKnown: true, | ||
| mediaProvider: nil) { } | ||
| .previewDisplayName("With Identity") |
There was a problem hiding this comment.
Technically With identity known and unknown as you're actually passing the identity in.
| var alertInfo: AlertInfo<StartChatScreenErrorType>? | ||
|
|
||
| var selectedUserToInvite: UserProfileProxy? | ||
| var selectedUserIdentityKnown = false |
There was a problem hiding this comment.
Same question here, why is this a binding?
| if appSettings.enableKeyShareOnInvite { | ||
| Task.detached { | ||
| let identity = await self.userSession.clientProxy.userIdentity(for: user.userID, fallBackToServer: false) | ||
| Task { @MainActor in |
If the user attempts to invite someone (to a room or creating a DM) who's identity is not cached, we prompt them to make sure this was their intention.
Part of element-hq/element-meta#3163
Pull Request Checklist
UI changes have been tested with: