feat: get unreads

This commit is contained in:
DIYgod
2024-05-29 22:05:12 +08:00
parent b595c51f42
commit fb6b13693d
2 changed files with 21 additions and 2 deletions
+16
View File
@@ -43,6 +43,22 @@ declare const routes: hono_hono_base.HonoBase<hono.Env, {
outputFormat: "json";
status: 200;
};
$get: {
input: {
query: {
view: string;
};
};
output: {
code: 0;
data: {
feedId: string;
unread: number;
}[];
};
outputFormat: "json";
status: 200;
};
};
} & {
"/collections": {
+5 -2
View File
@@ -21,6 +21,10 @@ export const subscription = {
await apiClient.subscriptions.$get({ query: { view: String(view) } })
).json()
const unreads = await (
await apiClient.reads.$get({ query: { view: String(view) } })
).json()
const subscriptions = res.data as SubscriptionResponse
const categories = {
list: {},
@@ -69,8 +73,7 @@ export const subscription = {
unread: 0,
}
}
// const unread = counters.unreads[feed.id] || 0
const unread = 0
const unread = unreads.data.find((x) => x.feedId === subscription.feedId)?.unread || 0
subscription.unread = unread
categories.list[subscription.category].list.push(subscription)
categories.list[subscription.category].unread += unread