-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(crypto): Support verification violation composer banner #29067
Conversation
02a2640
to
8325c0c
Compare
dc9ece8
to
f56a743
Compare
|
||
export type ViolationType = "PinViolation" | "VerificationViolation"; | ||
|
||
export type ViolationPrompt = { |
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.
Could all of these exported things have tsdoc please?
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.
done 6b76fbc
onButtonClick: (ev: ButtonEvent) => void; | ||
} | ||
|
||
async function mapToViolations(cryptoApi: CryptoApi, members: RoomMember[]): Promise<ViolationPrompt[]> { |
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.
This could also do with some doc as it's not super obvious what it does.
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.
Done 6b76fbc
}, | ||
[crypto, room, loadViolations], | ||
); | ||
useTypedEventEmitter(cli, RoomStateEvent.Events, onRoomStateEvent); |
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.
For functions that are defined and then just used once on the next line, probably may as well just use an anonymous one inline.
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.
Done in 6b76fbc
}); | ||
}, [loadViolations]); | ||
|
||
let onButtonClick: (ev: ButtonEvent) => void = () => {}; |
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.
It's a bit weird to assign a different callback to the button depending on the state. Generally you would just have one callback which behaves accordingly. Also, you probably want to make it a useCallback
and ideally be a bit more specific than onButtonClick (even though in this case there's only one button).
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.
Thx, I tried that d1509b9
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.
Thanks, this looks fine to me
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.
Just a few nits, but looks reasonable.
test/unit-tests/components/views/rooms/UserIdentityWarning-test.tsx
Outdated
Show resolved
Hide resolved
test/unit-tests/components/views/rooms/UserIdentityWarning-test.tsx
Outdated
Show resolved
Hide resolved
test/unit-tests/components/views/rooms/UserIdentityWarning-test.tsx
Outdated
Show resolved
Hide resolved
test/unit-tests/components/views/rooms/UserIdentityWarning-test.tsx
Outdated
Show resolved
Hide resolved
fixup: logger import fixup: test lint type problems fix test having an unexpected verification violation fixup sonarcubes warnings
c263c81
to
673e0d4
Compare
await firstStatusPromise.promise; | ||
callNumber++; | ||
if (callNumber == 1) { | ||
await sleep(40); | ||
return new UserVerificationStatus(false, false, false, false); | ||
} else { | ||
return new UserVerificationStatus(false, false, false, true); | ||
} |
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.
@BillCarsonFr as author and @uhoreg and @dbkr as reviewers: can any of you tell me what's going on here? On the first call to getUserVerificationStatus
it blocks for 40ms, but on subsequent calls, it returns immediately: why does it sleep in the first place?
This test seems to be racy (#29266); I think we need something more resilient than sleeps for tens of ms.
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.
Looking further at what's happening in this PR, it looks like this test is no longer relevant. It's testing what happens when the UserTrustStatusChanged
event says something different to getUserVerificationStatus
, but the code no longer relies on the payload of UserTrustStatusChanged
, so it feels like the test is redundant.
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.
(conclusion from discussion with @BillCarsonFr is that this test is indeed redundant)
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.
It was testing a race that was possible in the component before the refactoring to view model.
The old component was saying:
// For each user, we assign a sequence number to each verification status
// that we get, or fetch.
//
// Since fetching a verification status is asynchronous, we could get an
// update in the middle of fetching the verification status, which could
// mean that the status that we fetched is out of date. So if the current
// sequence number is not the same as the sequence number when we started
// the fetch, then we drop our fetched result, under the assumption that the
// update that we received is the most up-to-date version. If it is in fact
// not the most up-to-date version, then we should be receiving a new update
// soon with the newer value, so it will fix itself in the end.
So this test was trying to trigger this flow, where the initial status fetch is resolved late thus returning an outdated value, this to ensure that the component detects it and get the up to date value
It is indeed redondant with the new model (was usefull to test no regression with the old component)
Since the refactoring in #29067, this test is redundant. It is also flaky and hard to understand. Time for it to die.
* Remove redundant `UserIdentityWarning` test Since the refactoring in #29067, this test is redundant. It is also flaky and hard to understand. Time for it to die. * delint
Draft: depends on matrix-org/matrix-js-sdk#4646
Following an initial early review, I have refactored the component to now use a viewModel 8325c0c
The update model has also been made a lot more simple, but also less optimized; as an example a
UserTrustStatusChanged
event will trigger a new computation of all the violations in the room. If we see performances problem this could be improovedFollowing initial review,
Checklist
public
/exported
symbols have accurate TSDoc documentation.