mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Use name instead of displayName
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
a9ff6ab026
commit
a1e3ff3ed8
@ -6,8 +6,8 @@ export class MemberTileViewModel extends ViewModel {
|
|||||||
this._member = options.member;
|
this._member = options.member;
|
||||||
}
|
}
|
||||||
|
|
||||||
get displayName() {
|
get name() {
|
||||||
return this._member.displayName;
|
return this._member.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
get userId() {
|
get userId() {
|
||||||
|
@ -5,7 +5,7 @@ export function createMemberComparator(powerLevels) {
|
|||||||
const p1 = powerLevels.getUserLevel(member.userId);
|
const p1 = powerLevels.getUserLevel(member.userId);
|
||||||
const p2 = powerLevels.getUserLevel(otherMember.userId);
|
const p2 = powerLevels.getUserLevel(otherMember.userId);
|
||||||
if (p1 !== p2) { return p2 - p1; }
|
if (p1 !== p2) { return p2 - p1; }
|
||||||
return member.displayName?.localeCompare(otherMember.displayName);
|
return member.name?.localeCompare(otherMember.name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,67 +25,67 @@ export function tests() {
|
|||||||
return {
|
return {
|
||||||
"power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
"power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50});
|
||||||
const member1 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member1 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
const member2 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2) <= 0, true);
|
assert.strictEqual(fn(member1, member2) <= 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"power_level(member1) < power_level(member2) returns value > 0": assert => {
|
"power_level(member1) < power_level(member2) returns value > 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50});
|
||||||
const member1 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member1 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
const member2 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member2 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
assert.strictEqual(fn(member1, member2) > 0, true);
|
assert.strictEqual(fn(member1, member2) > 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"alphabetic compare on displayName": assert => {
|
"alphabetic compare on name": assert => {
|
||||||
const fn = createComparatorWithPowerLevel();
|
const fn = createComparatorWithPowerLevel();
|
||||||
const member1 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member1 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
const member2 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member2 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
assert.strictEqual(fn(member1, member2) > 0, true);
|
assert.strictEqual(fn(member1, member2) > 0, true);
|
||||||
assert.strictEqual(fn(member2, member1) <= 0, true);
|
assert.strictEqual(fn(member2, member1) <= 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"alphabetic compare with case (alice comes before Bob)": assert => {
|
"alphabetic compare with case (alice comes before Bob)": assert => {
|
||||||
const fn = createComparatorWithPowerLevel();
|
const fn = createComparatorWithPowerLevel();
|
||||||
const member1 = {userId: "@bob:hs.tld", displayName: "Bob"};
|
const member1 = {userId: "@bob:hs.tld", name: "Bob"};
|
||||||
const member2 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member2 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
assert.strictEqual(fn(member1, member2) > 0, true);
|
assert.strictEqual(fn(member1, member2) > 0, true);
|
||||||
assert.strictEqual(fn(member2, member1) <= 0, true);
|
assert.strictEqual(fn(member2, member1) <= 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"equal powerlevel and same names returns 0": assert => {
|
"equal powerlevel and same names returns 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@bobby:hs.tld": 50, "@bob:hs.tld": 50});
|
const fn = createComparatorWithPowerLevel({"@bobby:hs.tld": 50, "@bob:hs.tld": 50});
|
||||||
const member1 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member1 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
const member2 = {userId: "@bobby:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bobby:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2), 0);
|
assert.strictEqual(fn(member1, member2), 0);
|
||||||
assert.strictEqual(fn(member2, member1), 0);
|
assert.strictEqual(fn(member2, member1), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"(both_negative_powerlevel) power_level(member1) < power_level(member2) returns value > 0": assert => {
|
"(both_negative_powerlevel) power_level(member1) < power_level(member2) returns value > 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -100, "@bob:hs.tld": -50});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -100, "@bob:hs.tld": -50});
|
||||||
const member1 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member1 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
const member2 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2) > 0, true);
|
assert.strictEqual(fn(member1, member2) > 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"(both_negative_powerlevel) power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
"(both_negative_powerlevel) power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -50, "@bob:hs.tld": -100});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -50, "@bob:hs.tld": -100});
|
||||||
const member1 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member1 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
const member2 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2) <= 0, true);
|
assert.strictEqual(fn(member1, member2) <= 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"(one_negative_powerlevel) power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
"(one_negative_powerlevel) power_level(member1) > power_level(member2) returns value <= 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50, "@bob:hs.tld": -100});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": 50, "@bob:hs.tld": -100});
|
||||||
const member1 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member1 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
const member2 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2) <= 0, true);
|
assert.strictEqual(fn(member1, member2) <= 0, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
"(one_negative_powerlevel) power_level(member1) < power_level(member2) returns value > 0": assert => {
|
"(one_negative_powerlevel) power_level(member1) < power_level(member2) returns value > 0": assert => {
|
||||||
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -100, "@bob:hs.tld": 50});
|
const fn = createComparatorWithPowerLevel({"@alice:hs.tld": -100, "@bob:hs.tld": 50});
|
||||||
const member1 = {userId: "@alice:hs.tld", displayName: "alice"};
|
const member1 = {userId: "@alice:hs.tld", name: "alice"};
|
||||||
const member2 = {userId: "@bob:hs.tld", displayName: "bob"};
|
const member2 = {userId: "@bob:hs.tld", name: "bob"};
|
||||||
assert.strictEqual(fn(member1, member2) > 0, true);
|
assert.strictEqual(fn(member1, member2) > 0, true);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,6 @@ import {TemplateView} from "../../general/TemplateView.js";
|
|||||||
|
|
||||||
export class MemberTileView extends TemplateView {
|
export class MemberTileView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
return t.div(vm.displayName);
|
return t.div(vm.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user