mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 14:49:29 +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 (
|
||||
<SimpleCommand {...props}>
|
||||
<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"/>
|
||||
<VisibilityDropdown />
|
||||
</SimpleCommand>
|
||||
|
|
|
@ -67,7 +67,6 @@ export default function SimpleCommand(props: CommandProps) {
|
|||
})
|
||||
);
|
||||
|
||||
console.log(scheduled_at);
|
||||
const newStatus: Partial<Status> = {
|
||||
spoiler_text,
|
||||
status,
|
||||
|
@ -79,24 +78,33 @@ export default function SimpleCommand(props: CommandProps) {
|
|||
};
|
||||
|
||||
const response = await apiServer.postNewStatus(newStatus);
|
||||
|
||||
setStatusInfo(response);
|
||||
|
||||
if (!scheduled_at) {
|
||||
if (scheduled_at) {
|
||||
showToast(Toast.Style.Success, "Scheduled", labelText(scheduled_at));
|
||||
} else {
|
||||
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(() => {
|
||||
popToRoot();
|
||||
}, 1000);
|
||||
setStatusInfo(response)
|
||||
setCw("");
|
||||
setTimeout(()=> popToRoot, 2000)
|
||||
} catch (error) {
|
||||
const requestErr = error as AkkomaError;
|
||||
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) => {
|
||||
setSensitive(value);
|
||||
if (cwRef.current) {
|
||||
|
|
Loading…
Reference in a new issue