-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty verification bottom sheet #7130
Conversation
Ensure the User is retrieved from the network, or fallback to a default User object.
@@ -126,7 +128,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( | |||
} | |||
} | |||
|
|||
val userItem = session.getUser(initialState.otherUserId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A null userItem
was the source of the issue.
@@ -160,7 +162,6 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( | |||
|
|||
setState { | |||
copy( | |||
otherUserMxItem = userItem?.toMatrixItem(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is set in the constructor and updated with full data in fetchOtherUserProfile
session.getUser(otherUserId)?.toMatrixItem()?.let { | ||
setState { | ||
copy( | ||
otherUserMxItem = it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First change to set known data
?.let { | ||
setState { | ||
copy( | ||
otherUserMxItem = it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second change to set up to date data, if possible (network available + API is returning data)
@@ -216,12 +239,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( | |||
|
|||
private fun cancelAllPendingVerifications(state: VerificationBottomSheetViewState) { | |||
session.cryptoService() | |||
.verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaulting to ""
everywhere was pretty bad...
Adding @BillCarsonFr as a reviewer, since this is code related to Crypto. |
Probably because of the move to worker for fetching users? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I can see that getUser() is also called in IncomingVerificationRequestHandler.
It should call resolveUser or at least default to a MatriItem with the correct userId?
I do not think so, because even all attempts was unsuccessful. With this theory, after a while it should work. I think this is not a regression, but an old bug. |
Thanks, let me have a look on it. |
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement. Statically reviewed, LGTM! It was annoying to fallback to ""
.
Type of change
Content
When the User with
otherUserId
was not known by the SDK, it was not possible to verify them.First commit 6d2a9ec is the first part of the fix.
otherUserId
was null because retrieved from a nullMatrixItem
.Second commit 92d7391 ensure that the
MatrixItem
cannot be null.The 2nd commit should be sufficient to fix the issue, but the first commit make thing clearer IMHO.
Motivation and context
Be able to Verify every users.
Screenshots / GIFs
Tests
Tested devices
Checklist