From 1c3d76d45fe3d18c3c51afd37dc911a08d345cf7 Mon Sep 17 00:00:00 2001 From: janderedev Date: Thu, 12 Aug 2021 12:32:56 +0200 Subject: [PATCH 1/3] Added mutual servers tab on user profile --- .../intermediate/popovers/UserProfile.tsx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/context/intermediate/popovers/UserProfile.tsx b/src/context/intermediate/popovers/UserProfile.tsx index 814460a3..0ba20bab 100644 --- a/src/context/intermediate/popovers/UserProfile.tsx +++ b/src/context/intermediate/popovers/UserProfile.tsx @@ -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 UserStatus from "../../../components/common/user/UserStatus"; @@ -71,6 +72,11 @@ export const UserProfile = observer( channel.recipient_ids!.includes(user_id), ); + // Fix this once an API route for fetching mutual servers exists + const mutualServers = [...client.servers.values()].filter( + (server) => true, + ); + useLayoutEffect(() => { if (!user_id) return; if (typeof profile !== "undefined") setProfile(undefined); @@ -211,6 +217,11 @@ export const UserProfile = observer( onClick={() => setTab("groups")}> +
setTab("servers")}> + +
)} @@ -359,6 +370,32 @@ export const UserProfile = observer( )} )} + {tab === "servers" && ( +
+ {mutualServers.length === 0 ? ( +
+ +
+ ) : ( + mutualServers.map( + (x) => + x && ( + +
+ + {x.name} +
+ + ), + ) + )} +
+ )} ); From 3cc7caefd19f03e2078c5b98175f46ecf6ee374d Mon Sep 17 00:00:00 2001 From: janderedev Date: Thu, 12 Aug 2021 12:46:29 +0200 Subject: [PATCH 2/3] Update translations --- external/lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/lang b/external/lang index f20556de..7be90cf4 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit f20556de7648d4c600ef163b909d2f0141d25ded +Subproject commit 7be90cf44ba08d235ae52d7dc6073d8f9347232b From ac04bd2b44c8de7cbedb0c1cc91ca8afea91c8ff Mon Sep 17 00:00:00 2001 From: janderedev Date: Thu, 12 Aug 2021 18:29:01 +0200 Subject: [PATCH 3/3] Filter mutual servers properly --- src/context/intermediate/popovers/UserProfile.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/context/intermediate/popovers/UserProfile.tsx b/src/context/intermediate/popovers/UserProfile.tsx index 68c071ee..bca4f9de 100644 --- a/src/context/intermediate/popovers/UserProfile.tsx +++ b/src/context/intermediate/popovers/UserProfile.tsx @@ -74,9 +74,8 @@ export const UserProfile = observer( channel.recipient_ids!.includes(user_id), ); - // Fix this once an API route for fetching mutual servers exists - const mutualServers = [...client.servers.values()].filter( - (server) => true, + const mutualServers = mutual?.servers.map((id) => + client.servers.get(id), ); useLayoutEffect(() => { @@ -428,7 +427,7 @@ export const UserProfile = observer( )} {tab === "servers" && (
- {mutualServers.length === 0 ? ( + {!mutualServers || mutualServers.length === 0 ? (