import { Users } from "revolt.js/dist/api/objects"; import styles from "./UserPicker.module.scss"; import { Text } from "preact-i18n"; import { useState } from "preact/hooks"; import { useData } from "../../../mobx/State"; import UserCheckbox from "../../../components/common/user/UserCheckbox"; import Modal from "../../../components/ui/Modal"; interface Props { omit?: string[]; onClose: () => void; callback: (users: string[]) => Promise; } export function UserPicker(props: Props) { const [selected, setSelected] = useState([]); const omit = [...(props.omit || []), "00000000000000000000000000"]; const store = useData(); return ( } onClose={props.onClose} actions={[ { children: , onClick: () => props.callback(selected).then(props.onClose), }, ]}>
{[...store.users.values()] .filter( (x) => x && x.relationship === Users.Relationship.Friend && !omit.includes(x._id), ) .map((x) => ( { if (v) { setSelected([...selected, x._id]); } else { setSelected( selected.filter((y) => y !== x._id), ); } }} /> ))}
); }