mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(feed): gate feed cache to infinite scroll mode
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user