diff --git a/src/components/StatusPreview.tsx b/src/components/StatusPreview.tsx new file mode 100644 index 0000000..6a8e87d --- /dev/null +++ b/src/components/StatusPreview.tsx @@ -0,0 +1,11 @@ +import { Detail } from "@raycast/api" + +const StatusPreview = () => { + return ( +
+ +
+ ) +} + +export default StatusPreview diff --git a/src/simple-status.tsx b/src/simple-status.tsx index ba40b09..66c3ef1 100644 --- a/src/simple-status.tsx +++ b/src/simple-status.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useState,useRef } from "react"; import { Form, ActionPanel, @@ -21,17 +21,22 @@ import StatusContent from "./components/statusContent"; const cache = new Cache(); -export default function Command(props: LaunchProps<{ draftValues: Partial }>) { +type SimpleStatus = Pick; + +export default function Command(props: LaunchProps<{ draftValues: SimpleStatus }>) { const { instance } = getPreferenceValues(); const { draftValues } = props; const [cw, setCw] = useState(draftValues?.spoiler_text || ""); const [isMarkdown, setIsMarkdown] = useState(true); + const [showCw, setShowCw] = useState(false); const [openActionText, setOpenActionText] = useState("Open the last published status"); const [fqn, setFqn] = useState(""); const cached = cache.get("latest_published_status"); const [statusInfo, setStatusInfo] = useState(cached ? JSON.parse(cached) : null); + const cwRef = useRef(null); + useEffect(() => { const init = async () => { authorize(); @@ -42,7 +47,7 @@ export default function Command(props: LaunchProps<{ draftValues: Partial) => { + const handleSubmit = async (values: SimpleStatus) => { try { if (!values.status) throw new Error("You might forget the content, right ? |・ω・)"); showToast(Toast.Style.Animated, "Publishing to the Fediverse ... ᕕ( ᐛ )ᕗ"); @@ -65,6 +70,13 @@ export default function Command(props: LaunchProps<{ draftValues: Partial { + setShowCw(!showCw) + if (cwRef.current) { + cwRef.current.focus(); + } + } + return (
{fqn && } - + {showCw && ( + + )} - + + ); }