Merge pull request #60 from janderedev/pr-5

This commit is contained in:
Paul Makles 2021-08-12 21:39:23 +01:00 committed by GitHub
commit 4d9c324326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import { Localizer, Text } from "preact-i18n";
import { useContext, useEffect, useLayoutEffect, useState } from "preact/hooks";
import ChannelIcon from "../../../components/common/ChannelIcon";
import ServerIcon from "../../../components/common/ServerIcon";
import Tooltip from "../../../components/common/Tooltip";
import UserIcon from "../../../components/common/user/UserIcon";
import { Username } from "../../../components/common/user/UserShort";
@ -73,6 +74,10 @@ export const UserProfile = observer(
channel.recipient_ids!.includes(user_id),
);
const mutualServers = mutual?.servers.map((id) =>
client.servers.get(id),
);
useLayoutEffect(() => {
if (!user_id) return;
if (typeof profile !== "undefined") setProfile(undefined);
@ -218,6 +223,11 @@ export const UserProfile = observer(
onClick={() => setTab("groups")}>
<Text id="app.special.popovers.user_profile.mutual_groups" />
</div>
<div
data-active={tab === "servers"}
onClick={() => setTab("servers")}>
<Text id="app.special.popovers.user_profile.mutual_servers" />
</div>
</>
)}
</div>
@ -418,6 +428,32 @@ export const UserProfile = observer(
)}
</div>
)}
{tab === "servers" && (
<div className={styles.entries}>
{!mutualServers || mutualServers.length === 0 ? (
<div className={styles.empty}>
<Text id="app.special.popovers.user_profile.no_servers" />
</div>
) : (
mutualServers.map(
(x) =>
x && (
<Link to={`/server/${x._id}`}>
<div
className={styles.entry}
key={x._id}>
<ServerIcon
target={x}
size={32}
/>
<span>{x.name}</span>
</div>
</Link>
),
)
)}
</div>
)}
</div>
</Modal>
);