Refech using getMany, reducing the number of API calls

This commit is contained in:
Deluan
2021-06-16 10:00:31 -04:00
parent 521d1ff2bf
commit fb7229a53e
3 changed files with 19 additions and 22 deletions
+3 -3
View File
@@ -27,9 +27,9 @@ export const useResourceRefresh = (...visibleResources) => {
if (resources) {
Object.keys(resources).forEach((r) => {
if (visibleResources.length === 0 || visibleResources?.includes(r)) {
resources[r]?.forEach((id) => {
dataProvider.getOne(r, { id })
})
if (resources[r]?.length > 0) {
dataProvider.getMany(r, { ids: resources[r] })
}
}
})
}