import styles from "./Friend.module.scss"; import { UserDetail, Conversation, UserPlus } from "@styled-icons/boxicons-solid"; import { Friend } from "./Friend"; import { Text } from "preact-i18n"; import Header from "../../components/ui/Header"; import Overline from "../../components/ui/Overline"; import IconButton from "../../components/ui/IconButton"; import { useUsers } from "../../context/revoltjs/hooks"; import { User, Users } from "revolt.js/dist/api/objects"; import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice"; import { useIntermediate } from "../../context/intermediate/Intermediate"; export default function Friends() { const { openScreen } = useIntermediate(); const users = useUsers() as User[]; users.sort((a, b) => a.username.localeCompare(b.username)); const pending = users.filter( x => x.relationship === Users.Relationship.Incoming || x.relationship === Users.Relationship.Outgoing ); const friends = users.filter( x => x.relationship === Users.Relationship.Friend ); const blocked = users.filter( x => x.relationship === Users.Relationship.Blocked ); const online = friends.filter(x => x.online && x.status?.presence !== Users.Presence.Invisible); const offline = friends.filter(x => !x.online || x.status?.presence === Users.Presence.Invisible); return ( <>
{ !isTouchscreenDevice && }
openScreen({ id: 'special_input', type: 'create_group' })}> openScreen({ id: 'special_input', type: 'add_friend' })}>
{pending.length + friends.length + blocked.length === 0 && ( <> )} {pending.length > 0 && ( —{" "} {pending.length} )} {pending.map(y => ( ))} {online.length > 0 && ( —{" "} {online.length} )} {online.map(y => ( ))} {offline.length > 0 && ( —{" "} {offline.length} )} {offline.map(y => ( ))} {blocked.length > 0 && ( —{" "} {blocked.length} )} {blocked.map(y => ( ))}
); }