Fix rebase

This commit is contained in:
RMidhunSuresh 2023-03-28 15:08:47 +05:30
parent f822a7a344
commit 53c0fc2934
7 changed files with 27 additions and 26 deletions

View File

@ -34,7 +34,7 @@ export type SegmentType = {
"details": true;
"members": true;
"member": string;
"device-verification": string;
"device-verification": string | boolean;
"join-room": true;
};

View File

@ -97,13 +97,12 @@ export class SessionViewModel extends ViewModel {
}));
this._updateJoinRoom(joinRoom.get());
if (this._client.session.features.crossSigning) {
const verification = this.navigation.observe("device-verification");
this.track(verification.subscribe((txnId) => {
this._updateVerification(txnId);
}));
this._updateVerification(verification.get());
if (this.features.crossSigning) {
const verification = this.navigation.observe("device-verification");
this.track(verification.subscribe((txnId) => {
this._updateVerification(txnId);
}));
this._updateVerification(verification.get());
}
const lightbox = this.navigation.observe("lightbox");

View File

@ -33,10 +33,16 @@ export class ToastCollectionViewModel extends ViewModel<SegmentType, Options> {
constructor(options: Options) {
super(options);
const session = this.getOption("session");
const vms: IToastCollection["toastViewModels"][] = [
this.track(new CallToastCollectionViewModel(this.childOptions({ session }))),
this.track(new VerificationToastCollectionViewModel(this.childOptions({session}))),
].map(vm => vm.toastViewModels);
this.toastViewModels = new ConcatList(...vms);
const collectionVms: IToastCollection[] = [];
if (this.features.calls) {
collectionVms.push(this.track(new CallToastCollectionViewModel(this.childOptions({ session }))));
}
if (this.features.crossSigning) {
collectionVms.push(this.track(new VerificationToastCollectionViewModel(this.childOptions({ session }))));
}
const vms: IToastCollection["toastViewModels"][] = collectionVms.map(vm => vm.toastViewModels);
if (vms.length !== 0) {
this.toastViewModels = new ConcatList(...vms);
}
}
}

View File

@ -32,18 +32,13 @@ export class VerificationToastCollectionViewModel extends ViewModel<SegmentType,
constructor(options: Options) {
super(options);
this.observeSASRequests();
this.track(
options.session.crossSigning.subscribe((crossSigning) => {
this.track(crossSigning.receivedSASVerifications.subscribe(this));
})
);
}
async observeSASRequests() {
const session = this.getOption("session");
if (this.features.crossSigning) {
// todo: hack to wait for crossSigning; remove
await new Promise(r => setTimeout(r, 3000));
const map = session.crossSigning.receivedSASVerifications;
this.track(map.subscribe(this));
}
}
async onAdd(_, request: SASRequest) {
const dismiss = () => {

View File

@ -22,7 +22,7 @@ type Options<N extends MinimumNeededSegmentType = SegmentType> = {
} & BaseClassOptions<N>;
type MinimumNeededSegmentType = {
"device-verification": string;
"device-verification": string | boolean;
};
export class VerificationToastNotificationViewModel<N extends MinimumNeededSegmentType = SegmentType, O extends Options<N> = Options<N>> extends BaseToastNotificationViewModel<N, O> {

View File

@ -51,7 +51,7 @@ export class DeviceVerificationViewModel extends ErrorReportViewModel<SegmentTyp
private async start(requestOrUserId: SASRequest | string) {
await this.logAndCatch("DeviceVerificationViewModel.start", (log) => {
const crossSigning = this.session.crossSigning;
const crossSigning = this.session.crossSigning.get();
this.sas = crossSigning.startVerification(requestOrUserId, log);
this.addEventListeners();
if (typeof requestOrUserId === "string") {

View File

@ -41,8 +41,9 @@ export class ToastCollectionView extends TemplateView<ToastCollectionViewModel>
list: vm.toastViewModels,
parentProvidesUpdates: false,
}, (vm: CallToastNotificationViewModel) => toastViewModelToView(vm));
return t.div({ className: "ToastCollectionView" }, [
t.view(view),
t.if(vm => !!vm.toastViewModels, (t) => t.view(view)),
]);
}
}