mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 11:05:03 +01:00
We don't need this to be an observable
Since we treat related messages as context events, we don't need to make sasVerificationInProgress an observable.
This commit is contained in:
parent
901c149e9e
commit
a582aa1746
@ -19,7 +19,6 @@ import {TileShape} from "./ITile";
|
||||
import {SimpleTile} from "./SimpleTile";
|
||||
import {UpdateAction} from "../UpdateAction.js"
|
||||
import {VerificationEventType} from "../../../../../matrix/verification/SAS/channel/types";
|
||||
import type {SASVerification} from "../../../../../matrix/verification/SAS/SASVerification";
|
||||
import type {EventEntry} from "../../../../../matrix/room/timeline/entries/EventEntry.js";
|
||||
import type {Options} from "./SimpleTile";
|
||||
|
||||
@ -38,12 +37,6 @@ export class VerificationTile extends SimpleTile {
|
||||
constructor(entry: EventEntry, options: Options) {
|
||||
super(entry, options);
|
||||
this.request = new SASRequest(this.lowerEntry);
|
||||
const crossSigning = this.getOption("session").crossSigning.get();
|
||||
this.track(
|
||||
crossSigning.sasVerificationObservable.subscribe((sas) => {
|
||||
this.subscribeToSASVerification(sas);
|
||||
})
|
||||
);
|
||||
// Calculate status based on available context-for entries
|
||||
this.updateStatusFromAvailableContextForEntries();
|
||||
}
|
||||
@ -82,29 +75,6 @@ export class VerificationTile extends SimpleTile {
|
||||
this.navigation.applyPath(path);
|
||||
}
|
||||
|
||||
private subscribeToSASVerification(sas: SASVerification | undefined) {
|
||||
if (!sas || sas.channel.id !== this.eventId) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Subscribe to SAS events so that we can update the UI when each stage is
|
||||
* completed.
|
||||
*/
|
||||
this.track(
|
||||
sas.disposableOn("VerificationCancelled", (cancellation) => {
|
||||
this.isCancelledByUs = cancellation?.cancelledByUs!;
|
||||
this.status = Status.Cancelled;
|
||||
this.emitChange("status");
|
||||
})
|
||||
);
|
||||
this.track(
|
||||
sas.disposableOn("VerificationCompleted", () => {
|
||||
this.status = Status.Completed;
|
||||
this.emitChange("status");
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
updateEntry(entry: any, param: any) {
|
||||
if (param === "context-added") {
|
||||
// We received a new contextForEntry, maybe it tells us that
|
||||
|
@ -16,7 +16,6 @@ limitations under the License.
|
||||
|
||||
import {verifyEd25519Signature, SignatureVerification} from "../e2ee/common";
|
||||
import {BaseObservableValue, RetainedObservableValue} from "../../observable/value";
|
||||
import {ObservableValue} from "../../observable/value";
|
||||
import {pkSign} from "./common";
|
||||
import {SASVerification} from "./SAS/SASVerification";
|
||||
import {ToDeviceChannel} from "./SAS/channel/ToDeviceChannel";
|
||||
@ -101,7 +100,7 @@ export class CrossSigning {
|
||||
private _isMasterKeyTrusted: boolean = false;
|
||||
private readonly observedUsers: Map<string, RetainedObservableValue<UserTrust | undefined>> = new Map();
|
||||
private readonly deviceId: string;
|
||||
public sasVerificationObservable: ObservableValue<SASVerification | undefined> = new ObservableValue(undefined);
|
||||
private sasVerificationInProgress?: SASVerification;
|
||||
public receivedSASVerifications: ObservableMap<string, SASRequest> = new ObservableMap();
|
||||
|
||||
constructor(options: {
|
||||
@ -187,8 +186,7 @@ export class CrossSigning {
|
||||
startVerification(requestOrUserId: string, logOrRoom: Room, _log: ILogItem): SASVerification | undefined;
|
||||
startVerification(requestOrUserId: string | SASRequest, logOrRoom: Room | ILogItem, _log?: ILogItem): SASVerification | undefined {
|
||||
const log: ILogItem = _log ?? logOrRoom;
|
||||
const sasVerificationInProgress = this.sasVerificationObservable.get();
|
||||
if (sasVerificationInProgress && !sasVerificationInProgress.finished) {
|
||||
if (this.sasVerificationInProgress && !this.sasVerificationInProgress.finished) {
|
||||
log.log({ sasVerificationAlreadyInProgress: true });
|
||||
return;
|
||||
}
|
||||
@ -216,7 +214,7 @@ export class CrossSigning {
|
||||
}, startingMessage);
|
||||
}
|
||||
|
||||
const sas = new SASVerification({
|
||||
this.sasVerificationInProgress = new SASVerification({
|
||||
olm: this.olm,
|
||||
olmUtil: this.olmUtil,
|
||||
ourUserId: this.ownUserId,
|
||||
@ -229,8 +227,7 @@ export class CrossSigning {
|
||||
hsApi: this.hsApi,
|
||||
clock: this.platform.clock,
|
||||
});
|
||||
this.sasVerificationObservable.set(sas);
|
||||
return sas;
|
||||
return this.sasVerificationInProgress;
|
||||
}
|
||||
|
||||
private handleSASDeviceMessage({ unencrypted: event }) {
|
||||
@ -240,8 +237,7 @@ export class CrossSigning {
|
||||
* SAS verification, we should ignore it because the device channel
|
||||
* object (who also listens for to_device messages) will take care of it (if needed).
|
||||
*/
|
||||
const sasVerificationInProgress = this.sasVerificationObservable.get();
|
||||
const shouldIgnoreEvent = sasVerificationInProgress?.channel.id === txnId;
|
||||
const shouldIgnoreEvent = this.sasVerificationInProgress?.channel.id === txnId;
|
||||
if (shouldIgnoreEvent) { return; }
|
||||
/**
|
||||
* 1. If we receive the cancel message, we need to update the requests map.
|
||||
|
Loading…
Reference in New Issue
Block a user