Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clear prevEntryIds after refreshing and fetching #141

Merged
merged 9 commits into from
Jul 18, 2024
Prev Previous commit
Next Next commit
feat: remove unnecessary effect
  • Loading branch information
DIYgod committed Jul 18, 2024
commit fe63d01c0736ab84d03fa9c25f22cd77f2b06754
11 changes: 2 additions & 9 deletions src/renderer/src/modules/entry-column/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,10 @@ export const useEntriesByView = ({
if (!query.isFetching && query.isSuccess) {
prevEntryIdsRef.current = entryIds
setMergedEntries(entryIds)
onReset?.()
}
}, [query.isFetching])

useEffect(() => {
prevEntryIdsRef.current = []
onReset?.()
}, [feedId, view, unreadOnly])

const [mergedEntries, setMergedEntries] = useState<string[]>([])

const entryIdsAsDeps = entryIds.toString()
Expand All @@ -147,11 +143,8 @@ export const useEntriesByView = ({
...query,

refetch: useCallback(() => {
onReset?.()
prevEntryIdsRef.current = []
setMergedEntries(entryIds)
query.refetch()
}, [entryIds, query, onReset]),
}, [query]),
entriesIds: sortEntries(),
totalCount: query.data?.pages?.[0]?.total ?? mergedEntries.length,
}
Expand Down
Loading