refactor: remove StatusContent component

This commit is contained in:
sevichecc 2023-04-16 20:41:15 +08:00
parent 46451ac343
commit 190b7a75af
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000
2 changed files with 10 additions and 29 deletions

View file

@ -1,27 +0,0 @@
import { useState } from "react";
import { Form } from "@raycast/api";
interface statusProps {
isMarkdown: boolean;
draftStatus: string | undefined;
}
const StatusContent = ({ isMarkdown, draftStatus }: statusProps) => {
const [statusContent, setStatusContent] = useState<string>(draftStatus || "");
return (
<>
<Form.TextArea
id="status"
title="Content"
placeholder={`Write something down ${isMarkdown ? "with Markdown" : ""}`}
enableMarkdown={isMarkdown}
autoFocus={true}
value={statusContent}
onChange={setStatusContent}
/>
</>
);
};
export default StatusContent;

View file

@ -17,7 +17,6 @@ import { AkkomaError, StatusResponse, Preference, Status } from "./types";
import { authorize } from "./oauth"; import { authorize } from "./oauth";
import VisibilityDropdown from "./components/VisibilityDropdown"; import VisibilityDropdown from "./components/VisibilityDropdown";
import StatusContent from "./components/StatusContent";
const cache = new Cache(); const cache = new Cache();
@ -51,6 +50,7 @@ export default function SimpleCommand(props: CommandProps) {
sensitive: false, sensitive: false,
openActionText: "Open the last published status", openActionText: "Open the last published status",
fqn: "", fqn: "",
content: draftValues?.status || "",
}); });
const cached = cache.get("latest_published_status"); const cached = cache.get("latest_published_status");
@ -143,7 +143,15 @@ export default function SimpleCommand(props: CommandProps) {
ref={cwRef} ref={cwRef}
/> />
)} )}
<StatusContent isMarkdown={state.isMarkdown} draftStatus={draftValues?.status} /> <Form.TextArea
id="status"
title="Content"
placeholder={`Write something down ${state.isMarkdown ? "with Markdown" : ""}`}
enableMarkdown={state.isMarkdown}
autoFocus={true}
value={state.content}
onChange={(value) => setState((prevState) => ({ ...prevState, content: value }))}
/>
{!props.children && <VisibilityDropdown />} {!props.children && <VisibilityDropdown />}
{props.children} {props.children}
<Form.Checkbox <Form.Checkbox