refactor(feed): gate feed cache to infinite scroll mode

This commit is contained in:
plebeius
2026-02-21 12:14:10 +08:00
parent eee1df749b
commit 082076ba83
3 changed files with 171 additions and 45 deletions
+7
View File
@@ -11,6 +11,7 @@ interface FeedCacheState {
maxCacheSize: number;
accessFeed: (key: string, type: 'board' | 'catalog') => void;
removeFeed: (key: string) => void;
clearFeeds: () => void;
isFeedCached: (key: string) => boolean;
}
@@ -45,6 +46,12 @@ const useFeedCacheStore = create<FeedCacheState>((set, get) => ({
set({ cachedFeeds: cachedFeeds.filter((feed) => feed.key !== key) });
},
clearFeeds: () => {
const { cachedFeeds } = get();
if (cachedFeeds.length === 0) return;
set({ cachedFeeds: [] });
},
isFeedCached: (key: string) => {
const { cachedFeeds } = get();
return cachedFeeds.some((feed) => feed.key === key);