Inline VerificationRequest.{invalid,ready,started,done,cancelled} (#11013)

* Inline `VerificationRequest.{invalid,ready,started,done,cancelled}`

These methods are all just shortcuts for checks on `phase`, so let's get rid of
them

* update test

* Add some more tests

* even more coverage

* fix tests
This commit is contained in:
Richard van der Hoff 2023-06-06 09:27:53 +01:00 committed by GitHub
parent 6fa005dcfc
commit 2801afe570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 210 additions and 35 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import EventEmitter from "events";
import {
PHASE_DONE as VERIF_PHASE_DONE,
Phase as VerificationPhase,
VerificationRequest,
VerificationRequestEvent,
} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
@ -178,7 +179,7 @@ export class SetupEncryptionStore extends EventEmitter {
};
public onVerificationRequestChange = async (): Promise<void> => {
if (this.verificationRequest?.cancelled) {
if (this.verificationRequest?.phase === VerificationPhase.Cancelled) {
this.verificationRequest.off(VerificationRequestEvent.Change, this.onVerificationRequestChange);
this.verificationRequest = null;
this.emit("update");