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() { 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}

View file

@ -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;