feat: inbox list api
This commit is contained in:
@@ -15,14 +15,14 @@ import {
|
||||
TableRow,
|
||||
} from "~/components/ui/table"
|
||||
import { apiClient } from "~/lib/api-fetch"
|
||||
import { FeedViewType } from "~/lib/enum"
|
||||
import { inboxActions, useInboxByView } from "~/store/inbox"
|
||||
import { useInboxList } from "~/queries/inboxes"
|
||||
import { inboxActions } from "~/store/inbox"
|
||||
|
||||
import { InboxForm } from "./inbox-form"
|
||||
|
||||
export function DiscoverInboxList() {
|
||||
const { t } = useTranslation()
|
||||
const inboxes = useInboxByView(FeedViewType.Articles)
|
||||
const inboxes = useInboxList()
|
||||
|
||||
const { present } = useModalStack()
|
||||
|
||||
@@ -50,7 +50,7 @@ export function DiscoverInboxList() {
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{inboxes.map((inbox) => (
|
||||
{inboxes.data?.map((inbox) => (
|
||||
<TableRow key={inbox.id}>
|
||||
<TableCell size="sm">{inbox.id}</TableCell>
|
||||
<TableCell size="sm">
|
||||
|
||||
@@ -178,9 +178,10 @@ function EntryColumnImpl() {
|
||||
}
|
||||
data-total-count={virtuosoOptions.totalCount}
|
||||
>
|
||||
{virtuosoOptions.totalCount === 0 && !entries.isLoading && !entries.error && (
|
||||
<AddFeedHelper />
|
||||
)}
|
||||
{virtuosoOptions.totalCount === 0 &&
|
||||
!entries.isLoading &&
|
||||
!entries.error &&
|
||||
feed?.type === "feed" && <AddFeedHelper />}
|
||||
|
||||
<EntryListHeader
|
||||
refetch={entries.refetch}
|
||||
|
||||
@@ -4,8 +4,12 @@ import { inboxActions } from "~/store/inbox"
|
||||
|
||||
export const inboxes = {
|
||||
byId: ({ id }: { id: string }) =>
|
||||
defineQuery(["lists", id], async () => inboxActions.fetchInboxById(id), {
|
||||
rootKey: ["lists"],
|
||||
defineQuery(["inboxes", id], async () => inboxActions.fetchInboxById(id), {
|
||||
rootKey: ["inboxes"],
|
||||
}),
|
||||
list: () =>
|
||||
defineQuery(["inboxes"], async () => inboxActions.fetchOwnedInboxes(), {
|
||||
rootKey: ["inboxes"],
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -13,3 +17,8 @@ export const useInbox = ({ id }: { id?: string }) =>
|
||||
useAuthQuery(inboxes.byId({ id: id! }), {
|
||||
enabled: !!id,
|
||||
})
|
||||
|
||||
export const useInboxList = () =>
|
||||
useAuthQuery(inboxes.list(), {
|
||||
enabled: true,
|
||||
})
|
||||
|
||||
@@ -47,6 +47,13 @@ class InboxActionStatic {
|
||||
delete state.inboxes[id]
|
||||
})
|
||||
}
|
||||
|
||||
async fetchOwnedInboxes() {
|
||||
const res = await apiClient.inboxes.list.$get()
|
||||
this.upsertMany(res.data)
|
||||
|
||||
return res.data
|
||||
}
|
||||
}
|
||||
|
||||
export const inboxActions = new InboxActionStatic()
|
||||
|
||||
@@ -4253,6 +4253,33 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
|
||||
status: 200;
|
||||
};
|
||||
};
|
||||
"/inboxes/list": {
|
||||
$get: {
|
||||
input: {};
|
||||
output: {
|
||||
code: 0;
|
||||
data: {
|
||||
type: "inbox";
|
||||
id: string;
|
||||
secret: string;
|
||||
description?: string | null | undefined;
|
||||
title?: string | null | undefined;
|
||||
image?: string | null | undefined;
|
||||
ownerUserId?: string | null | undefined;
|
||||
owner?: {
|
||||
name: string | null;
|
||||
id: string;
|
||||
emailVerified: string | null;
|
||||
image: string | null;
|
||||
handle: string | null;
|
||||
createdAt: string;
|
||||
} | null | undefined;
|
||||
}[];
|
||||
};
|
||||
outputFormat: "json" | "text";
|
||||
status: 200;
|
||||
};
|
||||
};
|
||||
} & {
|
||||
"/admin/clean": {
|
||||
$post: {
|
||||
|
||||
Reference in New Issue
Block a user