perf: refs #8647 paginate

This commit is contained in:
Jon Elias 2025-04-11 13:44:43 +02:00
parent 27691943d3
commit df39cd4eca
2 changed files with 9 additions and 10 deletions

View File

@ -146,22 +146,14 @@ const addFilter = async (filter, params) => {
};
async function fetch(params) {
if (params) {
for (let param in params) {
if (params[param]) arrayData.store[param] = params[param];
}
}
if (params) applyParams(params);
arrayData.resetPagination();
await arrayData.fetch({ append: false });
return emitStoreData();
}
async function update(params) {
if (params) {
for (let param in params) {
if (params[param]) arrayData.store[param] = params[param];
}
}
if (params) applyParams(params);
const { limit, skip } = store;
store.limit = limit + skip;
store.skip = 0;
@ -171,6 +163,12 @@ async function update(params) {
return emitStoreData();
}
const applyParams = (params) => {
for (let param in params) {
if (params[param]) arrayData.store[param] = params[param];
}
};
function emitStoreData() {
if (!store.hasMoreData) isLoading.value = false;
emit('onFetch', store.data);

View File

@ -21,6 +21,7 @@ export function useArrayData(key, userOptions) {
onMounted(() => {
setOptions();
reset(['skip']);
const query = route.query;
const searchUrl = store.searchUrl;
if (query[searchUrl]) {