forked from mystiq/hydrogen-web
Use powerlevel
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
c9224c13a7
commit
fe6551ff3c
3 changed files with 17 additions and 4 deletions
|
@ -24,6 +24,9 @@ export class MemberDetailsViewModel extends ViewModel {
|
||||||
this._mediaRepository = options.mediaRepository;
|
this._mediaRepository = options.mediaRepository;
|
||||||
this._member = this._observableMember.get();
|
this._member = this._observableMember.get();
|
||||||
this._isEncrypted = options.isEncrypted;
|
this._isEncrypted = options.isEncrypted;
|
||||||
|
this._powerLevelsObservable = options.powerLevelsObservable;
|
||||||
|
this._powerLevel = this._powerLevelFromObservable(this._powerLevelsObservable);
|
||||||
|
this.track(this._powerLevelsObservable.subscribe(() => this._onPowerLevelsChange()));
|
||||||
this.track(this._observableMember.subscribe( () => this._onMemberChange()));
|
this.track(this._observableMember.subscribe( () => this._onMemberChange()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +36,10 @@ export class MemberDetailsViewModel extends ViewModel {
|
||||||
get type() { return "member-details"; }
|
get type() { return "member-details"; }
|
||||||
|
|
||||||
get role() {
|
get role() {
|
||||||
return "Admin";
|
if (this._powerLevel >= 100) { return "Admin"; }
|
||||||
|
else if (this._powerLevel >= 50) { return "Moderator"; }
|
||||||
|
else if (this._powerLevel === 0) { return "Default"; }
|
||||||
|
else { return `Custom (${this._powerLevel})`; }
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMemberChange() {
|
_onMemberChange() {
|
||||||
|
@ -41,6 +47,12 @@ export class MemberDetailsViewModel extends ViewModel {
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onPowerLevelsChange() {
|
||||||
|
const powerLevels = this._powerLevelsObservable.get();
|
||||||
|
this._powerLevel = powerLevels.getUserLevel(this._member.userId);
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
|
|
||||||
get avatarLetter() {
|
get avatarLetter() {
|
||||||
return avatarInitials(this.name);
|
return avatarInitials(this.name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ export class RightPanelViewModel extends ViewModel {
|
||||||
const userId = segment.value;
|
const userId = segment.value;
|
||||||
const observableMember = await this._room.observeMember(userId);
|
const observableMember = await this._room.observeMember(userId);
|
||||||
const isEncrypted = this._room.isEncrypted;
|
const isEncrypted = this._room.isEncrypted;
|
||||||
return {observableMember, isEncrypted, mediaRepository: this._room.mediaRepository};
|
const powerLevelsObservable = await this._room.observePowerLevels();
|
||||||
|
return {observableMember, isEncrypted, powerLevelsObservable, mediaRepository: this._room.mediaRepository};
|
||||||
}
|
}
|
||||||
|
|
||||||
_setupNavigation() {
|
_setupNavigation() {
|
||||||
|
|
|
@ -25,9 +25,9 @@ export class MemberDetailsView extends TemplateView {
|
||||||
};
|
};
|
||||||
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.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.role),
|
this._createSection(t, vm.i18n`ROLE`, vm => vm.role),
|
||||||
this._createSection(t, vm.i18n`SECURITY`, encryptionMessages[vm.isEncrypted]),
|
this._createSection(t, vm.i18n`SECURITY`, encryptionMessages[vm.isEncrypted]),
|
||||||
this._createOptions(t, vm)
|
this._createOptions(t, vm)
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in a new issue