From 6491f6832458f7a625f0a0afa9168174a71423f7 Mon Sep 17 00:00:00 2001
From: sevichecc <91365763+Sevichecc@users.noreply.github.com>
Date: Sun, 16 Apr 2023 12:08:12 +0800
Subject: [PATCH] feat: show scheduled time in toast
---
src/components/Actions.tsx | 5 -----
src/components/StatusPreview.tsx | 7 -------
src/detail-status.tsx | 2 +-
src/simple-status.tsx | 30 +++++++++++++++++++-----------
4 files changed, 20 insertions(+), 24 deletions(-)
delete mode 100644 src/components/Actions.tsx
delete mode 100644 src/components/StatusPreview.tsx
diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx
deleted file mode 100644
index 16404d6..0000000
--- a/src/components/Actions.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-const Actions = () => {
- return <>>;
-};
-
-export default Actions;
diff --git a/src/components/StatusPreview.tsx b/src/components/StatusPreview.tsx
deleted file mode 100644
index 9b5738e..0000000
--- a/src/components/StatusPreview.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Detail } from "@raycast/api";
-
-const StatusPreview = () => {
- return
;
-};
-
-export default StatusPreview;
diff --git a/src/detail-status.tsx b/src/detail-status.tsx
index 26af281..39956de 100644
--- a/src/detail-status.tsx
+++ b/src/detail-status.tsx
@@ -10,7 +10,7 @@ export default function DetailCommand(props: LaunchProps<{ draftValues: Partial<
return (
- {files.length !== 0 && }
+ {files.length === 1 &&}
diff --git a/src/simple-status.tsx b/src/simple-status.tsx
index e8bc767..9630819 100644
--- a/src/simple-status.tsx
+++ b/src/simple-status.tsx
@@ -67,7 +67,6 @@ export default function SimpleCommand(props: CommandProps) {
})
);
- console.log(scheduled_at);
const newStatus: Partial = {
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) {