mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 14:49:29 +08:00
fix: fqn do not show
This commit is contained in:
parent
ef3368abb1
commit
51a30401ef
2 changed files with 19 additions and 15 deletions
|
@ -44,7 +44,7 @@ const refreshToken = async (
|
|||
return tokenResponse;
|
||||
};
|
||||
|
||||
export const authorize = async (cache: Cache): Promise<void> => {
|
||||
export const authorize = async (): Promise<void> => {
|
||||
const { instance } = getPreferenceValues<Preference>();
|
||||
const tokenSet = await client.getTokens();
|
||||
|
||||
|
@ -67,5 +67,5 @@ export const authorize = async (cache: Cache): Promise<void> => {
|
|||
await client.setTokens(await requestAccessToken(client_id, client_secret, authRequest, authorizationCode));
|
||||
|
||||
const { fqn } = await apiServer.fetchAccountInfo();
|
||||
cache.set("account-fqn", fqn);
|
||||
await LocalStorage.setItem("account-fqn", fqn);
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
Icon,
|
||||
getPreferenceValues,
|
||||
LaunchProps,
|
||||
LocalStorage,
|
||||
} from "@raycast/api";
|
||||
import apiServer from "./api";
|
||||
import { AkkomaError, StatusResponse, Preference, Status } from "./types";
|
||||
|
@ -29,15 +30,6 @@ interface StatusForm extends Status {
|
|||
description?: string;
|
||||
}
|
||||
|
||||
const init = async (cache: Cache, setFqn: (fqn: string) => void) => {
|
||||
try {
|
||||
await authorize(cache);
|
||||
setFqn(cache.get("account-fqn") ?? "");
|
||||
} catch (error) {
|
||||
console.error("Error during authorization or fetching account-fqn:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const labelText = (time: Date) => {
|
||||
return new Intl.DateTimeFormat("default", {
|
||||
hour: "numeric",
|
||||
|
@ -61,13 +53,25 @@ export default function SimpleCommand(props: CommandProps) {
|
|||
fqn: "",
|
||||
});
|
||||
|
||||
const cachedInfo = cache.get("latest_published_status");
|
||||
const [statusInfo, setStatusInfo] = useState<StatusResponse>(cachedInfo ? JSON.parse(cachedInfo) : null);
|
||||
const cached = cache.get("latest_published_status");
|
||||
const [statusInfo, setStatusInfo] = useState<StatusResponse>(cached ? JSON.parse(cached) : null);
|
||||
|
||||
const cwRef = useRef<Form.TextField>(null);
|
||||
|
||||
useEffect(() => {
|
||||
init(cache, (fqn) => setState((prevState) => ({ ...prevState, fqn })));
|
||||
const init = async () => {
|
||||
try {
|
||||
await authorize();
|
||||
const newFqn = (await LocalStorage.getItem<string>("account-fqn")) ?? "";
|
||||
setState((prevState) => ({
|
||||
...prevState,
|
||||
fqn: newFqn,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Error during authorization or fetching account-fqn:", error);
|
||||
}
|
||||
};
|
||||
init();
|
||||
}, []);
|
||||
|
||||
const handleSubmit = async ({ spoiler_text, status, scheduled_at, visibility, files, description }: StatusForm) => {
|
||||
|
|
Loading…
Reference in a new issue