feat: filter the reblog statuses from my status

This commit is contained in:
sevichecc 2023-04-17 22:58:48 +08:00
parent fff1f02d8a
commit b007eea53d
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000
2 changed files with 16 additions and 9 deletions

View file

@ -10,7 +10,7 @@ const cache = new Cache();
export default function ViewStatusCommand() {
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);
useEffect(() => {
@ -19,7 +19,7 @@ export default function ViewStatusCommand() {
await getAccessToken();
showToast(Toast.Style.Animated, "Loading Status...ε=ε=┌( >_<)┘");
const status = await apiServer.fetchUserStatus();
setStatus(status);
setStatuses(statuses);
showToast(Toast.Style.Success, "Statuses has been loaded ٩(•̤̀ᵕ•̤́๑)ᵒᵏᵎᵎᵎᵎ");
cache.set("latest_statuses", JSON.stringify(status));
} catch (error) {
@ -32,9 +32,11 @@ export default function ViewStatusCommand() {
getBookmark();
}, []);
const filterReblog = (statuses:Status[]) => statuses.filter((status)=>!status.reblog)
return (
<List isShowingDetail isLoading={isLoading} searchBarPlaceholder="Search your status">
{status?.map((status) => (
{filterReblog(statuses)?.map((status) => (
<List.Item
title={status.akkoma.source.content}
key={status.id}

View file

@ -64,12 +64,7 @@ export interface StatusRequest {
export interface Status {
created_at: Date;
media_attachments: UploadAttachResponse[];
akkoma: {
source: {
content: string;
mediaType: "text/markdown" | "text/plain" | "text/bbcode" | "text/html" | "x.misskeymarkdown";
};
};
akkoma: AkkomaSource
account: {
acct: string;
};
@ -83,8 +78,18 @@ export interface Status {
};
id: 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
export interface ApiResponse {
id: number;