import { Friend } from "./Friend"; import { Text } from "preact-i18n"; import styles from "./Friend.module.scss"; import Header from "../../components/ui/Header"; import Overline from "../../components/ui/Overline"; import Tooltip from "../../components/common/Tooltip"; import IconButton from "../../components/ui/IconButton"; import { useUsers } from "../../context/revoltjs/hooks"; import { User, Users } from "revolt.js/dist/api/objects"; import UserIcon from "../../components/common/user/UserIcon"; import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice"; import { useIntermediate } from "../../context/intermediate/Intermediate"; import { ChevronDown, ChevronRight, ListPlus } from "@styled-icons/boxicons-regular"; import { UserDetail, MessageAdd, UserPlus } from "@styled-icons/boxicons-solid"; import { TextReact } from "../../lib/i18n"; import { Children } from "../../types/Preact"; import Details from "../../components/ui/Details"; export default function Friends() { const { openScreen } = useIntermediate(); const users = useUsers() as User[]; users.sort((a, b) => a.username.localeCompare(b.username)); const friends = users.filter(x => x.relationship === Users.Relationship.Friend); const lists = [ [ '', users.filter(x => x.relationship === Users.Relationship.Incoming ) ], [ 'app.special.friends.sent', users.filter(x => x.relationship === Users.Relationship.Outgoing ) ], [ 'app.status.online', friends.filter(x => x.online && x.status?.presence !== Users.Presence.Invisible ) ], [ 'app.status.offline', friends.filter(x => !x.online || x.status?.presence === Users.Presence.Invisible ) ], [ 'app.special.friends.blocked', friends.filter(x => x.relationship === Users.Relationship.Blocked ) ] ] as [ string, User[] ][]; 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.map(x => x._id) })}>
{ incoming.map((x, i) => i < 3 && ) }
{ incoming.length }
{ incoming.length > 3 ? : incoming.length > 1 ? : }
} { lists.map(([i18n, list], index) => { if (index === 0) return; if (list.length === 0) return; return (
— { list.length }
{ list.map(x => ) }
) }) }
); }