mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 14:49:29 +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 [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");
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -34,7 +34,7 @@ export default function Command(props: LaunchProps<{ draftValues: Partial<Status
|
|||
});
|
||||
|
||||
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 (≧∇≦)/ ! ");
|
||||
setOpenActionText("Open the status in Browser");
|
||||
setTimeout(() => {
|
||||
|
@ -52,7 +52,7 @@ export default function Command(props: LaunchProps<{ draftValues: Partial<Status
|
|||
actions={
|
||||
<ActionPanel>
|
||||
<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>
|
||||
}
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue