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

Commit

Permalink
feat: simplify rendering of roomfacepile
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed May 12, 2022
1 parent 7ed3089 commit 061be34
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions src/components/views/elements/RoomFacePile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Copyright 2021-2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

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

let tooltip: ReactNode;
if (props.onClick) {
let subText: string;
if (isJoined) {
subText = _t("Including you, %(commaSeparatedMembers)s", { commaSeparatedMembers });
} else {
subText = _t("Including %(commaSeparatedMembers)s", { commaSeparatedMembers });
}

tooltip = <div>
<div className="mx_Tooltip_title">
{ _t("View all %(count)s members", { count }) }
</div>
<div className="mx_Tooltip_sub">
{ subText }
</div>
</div>;
} else {
if (isJoined) {
tooltip = _t("%(count)s members including you, %(commaSeparatedMembers)s", {
count: count - 1,
commaSeparatedMembers,
});
} else {
tooltip = _t("%(count)s members including %(commaSeparatedMembers)s", {
count,
commaSeparatedMembers,
});
}
}
const tooltip = <div>
<div className="mx_Tooltip_title">
{ props.onClick
? _t("View all %(count)s members", { count })
: _t("%(count)s members", { count }) }
</div>
<div className="mx_Tooltip_sub">
{ isJoined
? _t("Including you, %(commaSeparatedMembers)s", { commaSeparatedMembers })
: _t("Including %(commaSeparatedMembers)s", { commaSeparatedMembers }) }
</div>
</div>;

return <FacePile
members={shownMembers}
Expand Down

0 comments on commit 061be34

Please sign in to comment.