From 955fbd400e4f1096e86841a52dc152e44c1d8f68 Mon Sep 17 00:00:00 2001 From: sevichecc <91365763+Sevichecc@users.noreply.github.com> Date: Sat, 15 Apr 2023 02:08:23 +0800 Subject: [PATCH] feat: open the last publish status in browser --- src/simple-status.tsx | 25 +++++++++++++++++++------ src/types.ts | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/simple-status.tsx b/src/simple-status.tsx index 1fc1f57..02d699e 100644 --- a/src/simple-status.tsx +++ b/src/simple-status.tsx @@ -1,17 +1,24 @@ import { useEffect, useState } from "react"; -import { Form, ActionPanel, Action, showToast, popToRoot, LaunchProps, Toast } from "@raycast/api"; +import { Form, ActionPanel, Action, showToast, popToRoot, LaunchProps, Toast, Cache ,Icon} from "@raycast/api"; import { postNewStatus } from "./api"; -import { Status, AkkomaError } from "./types"; +import { Status, AkkomaError, StatusResponse } from "./types"; import { authorize } from "./oauth"; import VisibilityDropdown from "./components/VisibilityDropdown"; import StatusContent from "./components/statusContent"; +const cache = new Cache(); + export default function Command(props: LaunchProps<{ draftValues: Partial }>) { const { draftValues } = props; const [cw, setCw] = useState(draftValues?.spoiler_text || ""); const [isMarkdown, setIsMarkdown] = useState(true); + const cached = cache.get("latest-pubished-status"); + + const [statusInfo, setStatusInfo] = useState(cached ? JSON.parse(cached) : ""); + const [openActionText, setOpenActionText] = useState("Open the last published status"); + useEffect(() => { authorize(); }, []); @@ -21,13 +28,18 @@ export default function Command(props: LaunchProps<{ draftValues: Partial { + popToRoot(); + }, 1000); } catch (error) { const requestErr = error as AkkomaError; showToast(Toast.Style.Failure, "Error", requestErr.message); @@ -39,7 +51,8 @@ export default function Command(props: LaunchProps<{ draftValues: Partial - + + } > diff --git a/src/types.ts b/src/types.ts index 144c569..d500c71 100644 --- a/src/types.ts +++ b/src/types.ts @@ -68,4 +68,5 @@ export interface StatusResponse { create_at: Date; content: string; application: Application; + url: string; }