mirror of
https://github.com/Sevichecc/raycast-akkoma-extension.git
synced 2025-04-30 22:49:30 +08:00
feat: filter the reblog statuses from my status
This commit is contained in:
parent
fff1f02d8a
commit
b007eea53d
2 changed files with 16 additions and 9 deletions
|
@ -10,7 +10,7 @@ const cache = new Cache();
|
||||||
|
|
||||||
export default function ViewStatusCommand() {
|
export default function ViewStatusCommand() {
|
||||||
const cached = cache.get("latest_statuses");
|
const cached = cache.get("latest_statuses");
|
||||||
const [status, setStatus] = useState<Status[]>(cached ? JSON.parse(cached) : []);
|
const [statuses, setStatuses] = useState<Status[]>(cached ? JSON.parse(cached) : []);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -19,7 +19,7 @@ export default function ViewStatusCommand() {
|
||||||
await getAccessToken();
|
await getAccessToken();
|
||||||
showToast(Toast.Style.Animated, "Loading Status...ε=ε=┌( >_<)┘");
|
showToast(Toast.Style.Animated, "Loading Status...ε=ε=┌( >_<)┘");
|
||||||
const status = await apiServer.fetchUserStatus();
|
const status = await apiServer.fetchUserStatus();
|
||||||
setStatus(status);
|
setStatuses(statuses);
|
||||||
showToast(Toast.Style.Success, "Statuses has been loaded ٩(•̤̀ᵕ•̤́๑)ᵒᵏᵎᵎᵎᵎ");
|
showToast(Toast.Style.Success, "Statuses has been loaded ٩(•̤̀ᵕ•̤́๑)ᵒᵏᵎᵎᵎᵎ");
|
||||||
cache.set("latest_statuses", JSON.stringify(status));
|
cache.set("latest_statuses", JSON.stringify(status));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -32,9 +32,11 @@ export default function ViewStatusCommand() {
|
||||||
getBookmark();
|
getBookmark();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const filterReblog = (statuses:Status[]) => statuses.filter((status)=>!status.reblog)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search your status">
|
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search your status">
|
||||||
{status?.map((status) => (
|
{filterReblog(statuses)?.map((status) => (
|
||||||
<List.Item
|
<List.Item
|
||||||
title={status.akkoma.source.content}
|
title={status.akkoma.source.content}
|
||||||
key={status.id}
|
key={status.id}
|
||||||
|
|
|
@ -64,12 +64,7 @@ export interface StatusRequest {
|
||||||
export interface Status {
|
export interface Status {
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
media_attachments: UploadAttachResponse[];
|
media_attachments: UploadAttachResponse[];
|
||||||
akkoma: {
|
akkoma: AkkomaSource
|
||||||
source: {
|
|
||||||
content: string;
|
|
||||||
mediaType: "text/markdown" | "text/plain" | "text/bbcode" | "text/html" | "x.misskeymarkdown";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
account: {
|
account: {
|
||||||
acct: string;
|
acct: string;
|
||||||
};
|
};
|
||||||
|
@ -83,8 +78,18 @@ export interface Status {
|
||||||
};
|
};
|
||||||
id: string;
|
id: string;
|
||||||
fqn: string;
|
fqn: string;
|
||||||
|
reblog: {
|
||||||
|
content: string
|
||||||
|
akkoma: AkkomaSource
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AkkomaSource {
|
||||||
|
source: {
|
||||||
|
content: string;
|
||||||
|
mediaType: "text/markdown" | "text/plain" | "text/bbcode" | "text/html" | "x.misskeymarkdown";
|
||||||
|
};
|
||||||
|
}
|
||||||
// API Responses
|
// API Responses
|
||||||
export interface ApiResponse {
|
export interface ApiResponse {
|
||||||
id: number;
|
id: number;
|
||||||
|
|
Loading…
Reference in a new issue