mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 22:49:30 +08:00
refactor: set statusInfo init to null
This commit is contained in:
parent
955fbd400e
commit
73b104a968
2 changed files with 13 additions and 4 deletions
9
src/components/Actions.tsx
Normal file
9
src/components/Actions.tsx
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const Actions = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Actions
|
|
@ -14,9 +14,9 @@ export default function Command(props: LaunchProps<{ draftValues: Partial<Status
|
||||||
const [cw, setCw] = useState<string>(draftValues?.spoiler_text || "");
|
const [cw, setCw] = useState<string>(draftValues?.spoiler_text || "");
|
||||||
const [isMarkdown, setIsMarkdown] = useState<boolean>(true);
|
const [isMarkdown, setIsMarkdown] = useState<boolean>(true);
|
||||||
|
|
||||||
const cached = cache.get("latest-pubished-status");
|
const cached = cache.get("latest_published_status");
|
||||||
|
|
||||||
const [statusInfo, setStatusInfo] = useState<StatusResponse>(cached ? JSON.parse(cached) : "");
|
const [statusInfo, setStatusInfo] = useState<StatusResponse>(cached ? JSON.parse(cached) : null);
|
||||||
const [openActionText, setOpenActionText] = useState<string>("Open the last published status");
|
const [openActionText, setOpenActionText] = useState<string>("Open the last published status");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -34,7 +34,7 @@ export default function Command(props: LaunchProps<{ draftValues: Partial<Status
|
||||||
});
|
});
|
||||||
|
|
||||||
setStatusInfo(response);
|
setStatusInfo(response);
|
||||||
cache.set("latest-pubished-status", JSON.stringify({ ...response }));
|
cache.set("latest_published_status", JSON.stringify(response));
|
||||||
showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
|
showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
|
||||||
setOpenActionText("Open the status in Browser");
|
setOpenActionText("Open the status in Browser");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -52,7 +52,7 @@ export default function Command(props: LaunchProps<{ draftValues: Partial<Status
|
||||||
actions={
|
actions={
|
||||||
<ActionPanel>
|
<ActionPanel>
|
||||||
<Action.SubmitForm onSubmit={handleSubmit} title="Publish" icon={Icon.Upload} />
|
<Action.SubmitForm onSubmit={handleSubmit} title="Publish" icon={Icon.Upload} />
|
||||||
<Action.OpenInBrowser url={statusInfo.url} title={openActionText} />
|
{ statusInfo && <Action.OpenInBrowser url={statusInfo.url} title={openActionText} />}
|
||||||
</ActionPanel>
|
</ActionPanel>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue