expose user trust in member panel

This commit is contained in:
Bruno Windels 2023-03-03 15:22:02 +01:00
parent 4c7f784911
commit 149f187904
2 changed files with 23 additions and 4 deletions

View File

@ -29,10 +29,22 @@ export class MemberDetailsViewModel extends ViewModel {
this._session = options.session; this._session = options.session;
this.track(this._powerLevelsObservable.subscribe(() => this._onPowerLevelsChange())); this.track(this._powerLevelsObservable.subscribe(() => this._onPowerLevelsChange()));
this.track(this._observableMember.subscribe( () => this._onMemberChange())); this.track(this._observableMember.subscribe( () => this._onMemberChange()));
this._isTrusted = false;
this.init(); // TODO: call this from parent view model and do something smart with error view model if it fails async?
}
async init() {
if (this.features.crossSigning) {
this._isTrusted = await this.logger.run({l: "MemberDetailsViewModel.verify user", id: this._member.userId}, log => {
return this._session.crossSigning.isUserTrusted(this._member.userId, log);
});
this.emitChange("isTrusted");
}
} }
get name() { return this._member.name; } get name() { return this._member.name; }
get userId() { return this._member.userId; } get userId() { return this._member.userId; }
get isTrusted() { return this._isTrusted; }
get type() { return "member-details"; } get type() { return "member-details"; }
get shouldShowBackButton() { return true; } get shouldShowBackButton() { return true; }

View File

@ -19,15 +19,22 @@ import {TemplateView} from "../../general/TemplateView";
export class MemberDetailsView extends TemplateView { export class MemberDetailsView extends TemplateView {
render(t, vm) { render(t, vm) {
const securityNodes = [
t.p(vm.isEncrypted ?
vm.i18n`Messages in this room are end-to-end encrypted.` :
vm.i18n`Messages in this room are not end-to-end encrypted.`),
]
if (vm.features.crossSigning) {
securityNodes.push(t.p(vm => vm.isTrusted ? vm.i18n`This user is trusted` : vm.i18n`This user is not trusted`));
}
return t.div({className: "MemberDetailsView"}, return t.div({className: "MemberDetailsView"},
[ t.view(new AvatarView(vm, 128)), [ t.view(new AvatarView(vm, 128)),
t.div({className: "MemberDetailsView_name"}, t.h2(vm => vm.name)), t.div({className: "MemberDetailsView_name"}, t.h2(vm => vm.name)),
t.div({className: "MemberDetailsView_id"}, vm.userId), t.div({className: "MemberDetailsView_id"}, vm.userId),
this._createSection(t, vm.i18n`Role`, vm => vm.role), this._createSection(t, vm.i18n`Role`, vm => vm.role),
this._createSection(t, vm.i18n`Security`, vm.isEncrypted ? this._createSection(t, vm.i18n`Security`, securityNodes),
vm.i18n`Messages in this room are end-to-end encrypted.` :
vm.i18n`Messages in this room are not end-to-end encrypted.`
),
this._createOptions(t, vm) this._createOptions(t, vm)
]); ]);
} }