From fd03c64d92fb9b54c5b750c8e1dbafbede72de60 Mon Sep 17 00:00:00 2001 From: Paul <paulmakles@gmail.com> Date: Sun, 25 Jul 2021 12:50:34 +0100 Subject: [PATCH] Show friend requests on top-right avatar. --- src/components/navigation/left/HomeSidebar.tsx | 11 +---------- src/components/navigation/left/ServerListSidebar.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/components/navigation/left/HomeSidebar.tsx b/src/components/navigation/left/HomeSidebar.tsx index 46497aa..12b51da 100644 --- a/src/components/navigation/left/HomeSidebar.tsx +++ b/src/components/navigation/left/HomeSidebar.tsx @@ -66,16 +66,7 @@ function HomeSidebar(props: Props) { .filter((x) => x.channel_type !== "SavedMessages") .map((x) => mapChannelWithUnread(x, props.unreads)); - const users = useUsers( - ( - channelsArr as ( - | Channels.DirectMessageChannel - | Channels.GroupChannel - )[] - ).reduce((prev: any, cur) => [...prev, ...cur.recipients], []), - ctx, - ); - + const users = useUsers(undefined, ctx); channelsArr.sort((b, a) => a.timestamp.localeCompare(b.timestamp)); return ( diff --git a/src/components/navigation/left/ServerListSidebar.tsx b/src/components/navigation/left/ServerListSidebar.tsx index b8b9b32..881d611 100644 --- a/src/components/navigation/left/ServerListSidebar.tsx +++ b/src/components/navigation/left/ServerListSidebar.tsx @@ -1,6 +1,6 @@ import { Plus } from "@styled-icons/boxicons-regular"; import { useLocation, useParams } from "react-router-dom"; -import { Channel, Servers } from "revolt.js/dist/api/objects"; +import { Channel, Servers, Users } from "revolt.js/dist/api/objects"; import styled, { css } from "styled-components"; import { attachContextMenu, openContextMenu } from "preact-context-menu"; @@ -19,6 +19,7 @@ import { useForceUpdate, useSelf, useServers, + useUsers, } from "../../../context/revoltjs/hooks"; import logoSVG from "../../../assets/logo.svg"; @@ -56,7 +57,7 @@ function Icon({ <circle cx="27" cy="5" r="5" fill={"white"} /> )} {unread === "mention" && ( - <circle cx="27" cy="5" r="5" fill={"red"} /> + <circle cx="27" cy="5" r="5" fill={"var(--error)"} /> )} </svg> ); @@ -184,6 +185,7 @@ export function ServerListSidebar({ unreads, lastOpened }: Props) { const channels = (useChannels(undefined, ctx) as Channel[]).map((x) => mapChannelWithUnread(x, unreads), ); + const users = useUsers(undefined, ctx); const unreadChannels = channels.filter((x) => x.unread).map((x) => x._id); @@ -228,6 +230,10 @@ export function ServerListSidebar({ unreads, lastOpened }: Props) { } } + if (users.find((x) => x?.relationship === Users.Relationship.Incoming)) { + alertCount++; + } + if (alertCount > 0) homeUnread = "mention"; const homeActive = typeof server === "undefined" && !path.startsWith("/invite"); -- GitLab