diff --git a/src/renderer/src/components/feed-list.tsx b/src/renderer/src/components/feed-list.tsx index b2848ded1..604b7d290 100644 --- a/src/renderer/src/components/feed-list.tsx +++ b/src/renderer/src/components/feed-list.tsx @@ -15,7 +15,7 @@ export function FeedList({ activedList: ActivedList, setActivedList: (value: ActivedList) => void }) { - const feeds = useFeeds() + const feeds = useFeeds(type) return (
@@ -69,7 +69,7 @@ function FeedCategory({ >
- + {data.name} diff --git a/src/renderer/src/lib/feeds.ts b/src/renderer/src/lib/feeds.ts index 45a419697..6342278c2 100644 --- a/src/renderer/src/lib/feeds.ts +++ b/src/renderer/src/lib/feeds.ts @@ -1,8 +1,17 @@ import { useQuery } from '@tanstack/react-query' -export const useFeeds = () => +const typeMap = { + 'Articles': ['Forum', 'News', 'Game', 'Shopping', 'Blog', 'Knowledge'], + 'Social Media': ['Twitter', 'Weibo'], + 'Pictures': ['Picture'], + 'Videos': ['bilibili', 'YouTube', 'Video'], + 'Audios': [], + 'Notifications': ['Software'], +} + +export const useFeeds = (type: string) => useQuery({ - queryKey: ['feeds'], + queryKey: ['feeds', type], queryFn: async () => { const feeds = await (await fetch(`${import.meta.env.VITE_MINIFLUX_ENDPOINT}/v1/feeds`, { headers: { @@ -20,18 +29,20 @@ export const useFeeds = () => unread: 0, } feeds?.forEach((feed) => { - if (!categories.list[feed.category.title]) { - categories.list[feed.category.title] = { - list: [], - unread: 0, - id: feed.category.id + if (typeMap[type].includes(feed.category.title)) { + if (!categories.list[feed.category.title]) { + categories.list[feed.category.title] = { + list: [], + unread: 0, + id: feed.category.id + } } + const unread = counters.unreads[feed.id] || 0 + feed.unread = unread + categories.list[feed.category.title].list.push(feed) + categories.list[feed.category.title].unread += unread + categories.unread += unread } - const unread = counters.unreads[feed.id] || 0 - feed.unread = unread - categories.list[feed.category.title].list.push(feed) - categories.list[feed.category.title].unread += unread - categories.unread += unread }) const list = Object.entries(categories.list).map(([name, list]: any) => ({ name,