mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 22:49:30 +08:00
feat: show scheduled time in toast
This commit is contained in:
parent
1b2d51f601
commit
6491f68324
4 changed files with 20 additions and 24 deletions
|
@ -1,5 +0,0 @@
|
||||||
const Actions = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Actions;
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { Detail } from "@raycast/api";
|
|
||||||
|
|
||||||
const StatusPreview = () => {
|
|
||||||
return <div></div>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default StatusPreview;
|
|
|
@ -10,7 +10,7 @@ export default function DetailCommand(props: LaunchProps<{ draftValues: Partial<
|
||||||
return (
|
return (
|
||||||
<SimpleCommand {...props}>
|
<SimpleCommand {...props}>
|
||||||
<Form.FilePicker id="files" value={files} onChange={setFiles} />
|
<Form.FilePicker id="files" value={files} onChange={setFiles} />
|
||||||
{files.length !== 0 && <Form.TextArea id="description" title="Alt text" />}
|
{files.length === 1 &&<Form.TextArea id="description" title="Alt text" />}
|
||||||
<Form.DatePicker id="scheduled_at" title="Scheduled Time"/>
|
<Form.DatePicker id="scheduled_at" title="Scheduled Time"/>
|
||||||
<VisibilityDropdown />
|
<VisibilityDropdown />
|
||||||
</SimpleCommand>
|
</SimpleCommand>
|
||||||
|
|
|
@ -67,7 +67,6 @@ export default function SimpleCommand(props: CommandProps) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(scheduled_at);
|
|
||||||
const newStatus: Partial<Status> = {
|
const newStatus: Partial<Status> = {
|
||||||
spoiler_text,
|
spoiler_text,
|
||||||
status,
|
status,
|
||||||
|
@ -79,24 +78,33 @@ export default function SimpleCommand(props: CommandProps) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await apiServer.postNewStatus(newStatus);
|
const response = await apiServer.postNewStatus(newStatus);
|
||||||
|
if (scheduled_at) {
|
||||||
setStatusInfo(response);
|
showToast(Toast.Style.Success, "Scheduled", labelText(scheduled_at));
|
||||||
|
} else {
|
||||||
if (!scheduled_at) {
|
|
||||||
cache.set("latest_published_status", JSON.stringify(response));
|
cache.set("latest_published_status", JSON.stringify(response));
|
||||||
}
|
setOpenActionText("View the status in Browser");
|
||||||
|
|
||||||
showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
|
showToast(Toast.Style.Success, "Status has been published (≧∇≦)/ ! ");
|
||||||
setOpenActionText("Open the status in Browser");
|
}
|
||||||
setTimeout(() => {
|
setStatusInfo(response)
|
||||||
popToRoot();
|
setCw("");
|
||||||
}, 1000);
|
setTimeout(()=> popToRoot, 2000)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const requestErr = error as AkkomaError;
|
const requestErr = error as AkkomaError;
|
||||||
showToast(Toast.Style.Failure, "Error", requestErr.message);
|
showToast(Toast.Style.Failure, "Error", requestErr.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const labelText = (time: Date) => {
|
||||||
|
return new Intl.DateTimeFormat("default", {
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
month: "long",
|
||||||
|
weekday: "long",
|
||||||
|
dayPeriod: "narrow",
|
||||||
|
}).format(time);
|
||||||
|
};
|
||||||
|
|
||||||
const handleCw = (value: boolean) => {
|
const handleCw = (value: boolean) => {
|
||||||
setSensitive(value);
|
setSensitive(value);
|
||||||
if (cwRef.current) {
|
if (cwRef.current) {
|
||||||
|
|
Loading…
Reference in a new issue