Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7031bde

Browse files
committed
feat: simplify rendering of roomfacepile
1 parent 7ed3089 commit 7031bde

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed

src/components/views/elements/RoomFacePile.tsx

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2021 The Matrix.org Foundation C.I.C.
2+
Copyright 2021-2022 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { FC, HTMLAttributes, ReactNode, useContext } from "react";
17+
import React, { FC, HTMLAttributes, useContext } from "react";
1818
import { Room } from "matrix-js-sdk/src/models/room";
1919
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
2020
import { sortBy } from "lodash";
@@ -60,36 +60,18 @@ const RoomFacePile: FC<IProps> = (
6060
// reverse members in tooltip order to make the order between the two match up.
6161
const commaSeparatedMembers = shownMembers.map(m => m.name).reverse().join(", ");
6262

63-
let tooltip: ReactNode;
64-
if (props.onClick) {
65-
let subText: string;
66-
if (isJoined) {
67-
subText = _t("Including you, %(commaSeparatedMembers)s", { commaSeparatedMembers });
68-
} else {
69-
subText = _t("Including %(commaSeparatedMembers)s", { commaSeparatedMembers });
70-
}
71-
72-
tooltip = <div>
73-
<div className="mx_Tooltip_title">
74-
{ _t("View all %(count)s members", { count }) }
75-
</div>
76-
<div className="mx_Tooltip_sub">
77-
{ subText }
78-
</div>
79-
</div>;
80-
} else {
81-
if (isJoined) {
82-
tooltip = _t("%(count)s members including you, %(commaSeparatedMembers)s", {
83-
count: count - 1,
84-
commaSeparatedMembers,
85-
});
86-
} else {
87-
tooltip = _t("%(count)s members including %(commaSeparatedMembers)s", {
88-
count,
89-
commaSeparatedMembers,
90-
});
91-
}
92-
}
63+
const tooltip = <div>
64+
<div className="mx_Tooltip_title">
65+
{ props.onClick
66+
? _t("View all %(count)s members", { count })
67+
: _t("%(count)s members", { count }) }
68+
</div>
69+
<div className="mx_Tooltip_sub">
70+
{ isJoined
71+
? _t("Including you, %(commaSeparatedMembers)s", { commaSeparatedMembers })
72+
: _t("Including %(commaSeparatedMembers)s", { commaSeparatedMembers }) }
73+
</div>
74+
</div>;
9375

9476
return <FacePile
9577
members={shownMembers}

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,15 +2364,10 @@
23642364
"This address is available to use": "This address is available to use",
23652365
"This address is already in use": "This address is already in use",
23662366
"This address had invalid server or is already in use": "This address had invalid server or is already in use",
2367-
"Including you, %(commaSeparatedMembers)s": "Including you, %(commaSeparatedMembers)s",
2368-
"Including %(commaSeparatedMembers)s": "Including %(commaSeparatedMembers)s",
23692367
"View all %(count)s members|other": "View all %(count)s members",
23702368
"View all %(count)s members|one": "View 1 member",
2371-
"%(count)s members including you, %(commaSeparatedMembers)s|other": "%(count)s members including you, %(commaSeparatedMembers)s",
2372-
"%(count)s members including you, %(commaSeparatedMembers)s|zero": "You",
2373-
"%(count)s members including you, %(commaSeparatedMembers)s|one": "%(count)s members including you and %(commaSeparatedMembers)s",
2374-
"%(count)s members including %(commaSeparatedMembers)s|other": "%(count)s members including %(commaSeparatedMembers)s",
2375-
"%(count)s members including %(commaSeparatedMembers)s|one": "%(commaSeparatedMembers)s",
2369+
"Including you, %(commaSeparatedMembers)s": "Including you, %(commaSeparatedMembers)s",
2370+
"Including %(commaSeparatedMembers)s": "Including %(commaSeparatedMembers)s",
23762371
"%(count)s people you know have already joined|other": "%(count)s people you know have already joined",
23772372
"%(count)s people you know have already joined|one": "%(count)s person you know has already joined",
23782373
"Message search initialisation failed, check <a>your settings</a> for more information": "Message search initialisation failed, check <a>your settings</a> for more information",

0 commit comments

Comments
 (0)