import { ChevronDown, ChevronRight, ListPlus, } from "@styled-icons/boxicons-regular"; import { UserDetail, MessageAdd, UserPlus } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { RelationshipStatus, Presence } from "revolt-api/types/Users"; import { User } from "revolt.js/dist/maps/Users"; import styles from "./Friend.module.scss"; import { Text } from "preact-i18n"; import { TextReact } from "../../lib/i18n"; import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice"; import { useIntermediate } from "../../context/intermediate/Intermediate"; import { useClient } from "../../context/revoltjs/RevoltClient"; import CollapsibleSection from "../../components/common/CollapsibleSection"; import Tooltip from "../../components/common/Tooltip"; import UserIcon from "../../components/common/user/UserIcon"; import Header from "../../components/ui/Header"; import IconButton from "../../components/ui/IconButton"; import { Children } from "../../types/Preact"; import { Friend } from "./Friend"; export default observer(() => { const { openScreen } = useIntermediate(); const client = useClient(); const users = [...client.users.values()]; users.sort((a, b) => a.username.localeCompare(b.username)); const friends = users.filter( (x) => x.relationship === RelationshipStatus.Friend, ); const lists = [ [ "", users.filter((x) => x.relationship === RelationshipStatus.Incoming), ], [ "app.special.friends.sent", users.filter((x) => x.relationship === RelationshipStatus.Outgoing), "outgoing", ], [ "app.status.online", friends.filter( (x) => x.online && x.status?.presence !== Presence.Invisible, ), "online", ], [ "app.status.offline", friends.filter( (x) => !x.online || x.status?.presence === Presence.Invisible, ), "offline", ], [ "app.special.friends.blocked", users.filter((x) => x.relationship === RelationshipStatus.Blocked), "blocked", ], ] as [string, User[], string][]; const incoming = lists[0][1]; const userlist: Children[] = incoming.map((x) => {x.username}); for (let i = incoming.length - 1; i > 0; i--) userlist.splice(i, 0, ", "); const isEmpty = lists.reduce((p: number, n) => p + n.length, 0) === 0; return ( <>
{!isTouchscreenDevice && }
{/* openScreen({ id: 'special_input', type: 'create_group' })}>
*/} openScreen({ id: "special_input", type: "create_group", }) }> openScreen({ id: "special_input", type: "add_friend", }) }> {/*
*/}
{isEmpty && ( <> )} {incoming.length > 0 && (
openScreen({ id: "pending_requests", users: incoming, }) }>
{incoming.map( (x, i) => i < 3 && ( ), )}
{" "} {incoming.length}
{incoming.length > 3 ? ( ) : incoming.length > 1 ? ( ) : ( )}
)} {lists.map(([i18n, list, section_id], index) => { if (index === 0) return; if (list.length === 0) return; return ( — {list.length}
}> {list.map((x) => ( ))} ); })} ); });