1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-02 17:02:31 +03:00

Null check and naming

This commit is contained in:
Travis Ralston
2019-06-20 14:12:16 -06:00
parent e34eb48914
commit 5c2fb1c42b

View File

@@ -70,12 +70,12 @@ export default class VerificationBase extends EventEmitter {
this._transactionTimeoutTimer = null; this._transactionTimeoutTimer = null;
// At this point, the verification request was received so start the timeout timer. // At this point, the verification request was received so start the timeout timer.
this._pingTransaction(); this._resetTimer();
} }
_pingTransaction() { _resetTimer() {
console.log("Refreshing/starting the verification transaction timeout timer"); console.log("Refreshing/starting the verification transaction timeout timer");
clearTimeout(this._transactionTimeoutTimer); if (this._transactionTimeoutTimer !== null) clearTimeout(this._transactionTimeoutTimer);
setTimeout(() => { setTimeout(() => {
if (!this._done && !this.cancelled) { if (!this._done && !this.cancelled) {
console.log("Triggering verification timeout"); console.log("Triggering verification timeout");
@@ -111,7 +111,7 @@ export default class VerificationBase extends EventEmitter {
} else if (e.getType() === this._expectedEvent) { } else if (e.getType() === this._expectedEvent) {
this._expectedEvent = undefined; this._expectedEvent = undefined;
this._rejectEvent = undefined; this._rejectEvent = undefined;
this._pingTransaction(); this._resetTimer();
this._resolveEvent(e); this._resolveEvent(e);
} else { } else {
this._expectedEvent = undefined; this._expectedEvent = undefined;
@@ -203,7 +203,7 @@ export default class VerificationBase extends EventEmitter {
}); });
if (this._doVerification && !this._started) { if (this._doVerification && !this._started) {
this._started = true; this._started = true;
this._pingTransaction(); // restart the timeout this._resetTimer(); // restart the timeout
Promise.resolve(this._doVerification()) Promise.resolve(this._doVerification())
.then(this.done.bind(this), this.cancel.bind(this)); .then(this.done.bind(this), this.cancel.bind(this));
} }