fix: bug
This commit is contained in:
@@ -73,10 +73,16 @@ export const useTemplateGenerations = () => {
|
||||
hasMoreRef.current = newGenerations.length >= (params?.limit || 20)
|
||||
currentPageRef.current = nextPage
|
||||
|
||||
setData((prev) => ({
|
||||
...newData,
|
||||
data: [...(prev?.data || []), ...newGenerations],
|
||||
}))
|
||||
// 合并数据并去重
|
||||
setData((prev) => {
|
||||
const existingIds = new Set((prev?.data || []).map(item => item.id))
|
||||
const uniqueNewGenerations = newGenerations.filter(item => !existingIds.has(item.id))
|
||||
|
||||
return {
|
||||
...newData,
|
||||
data: [...(prev?.data || []), ...uniqueNewGenerations],
|
||||
}
|
||||
})
|
||||
setLoadingMore(false)
|
||||
return { data: newData, error: null }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user