import { useEffect, useRef, useState } from 'preact/hooks'; import { api } from '../utils/api'; import supports from '../utils/supports'; import Icon from './icon'; import MenuConfirm from './menu-confirm'; function ListAddEdit({ list, onClose }) { const { masto } = api(); const [uiState, setUiState] = useState('default'); const editMode = !!list; const nameFieldRef = useRef(); const repliesPolicyFieldRef = useRef(); const exclusiveFieldRef = useRef(); useEffect(() => { if (editMode) { nameFieldRef.current.value = list.title; repliesPolicyFieldRef.current.value = list.repliesPolicy; if (exclusiveFieldRef.current) { exclusiveFieldRef.current.checked = list.exclusive; } } }, [editMode]); const supportsExclusive = supports('@mastodon/list-exclusive'); return (