reorder records list watchers and cancel prev count requests

This commit is contained in:
Gani Georgiev
2026-04-19 08:15:58 +03:00
parent 3ad737e606
commit e41f43241b
6 changed files with 65 additions and 52 deletions

View File

@@ -16,6 +16,7 @@ function semaphoreAdd(fn) {
semaphoreProcess();
}
// release func that must be called manually after done with the loading
return () => {
semaphore.pending.delete(fn);
semaphore.processing.delete(fn);

View File

@@ -240,18 +240,6 @@ window.app.components.recordsList = function(propsArg = {}) {
return field.hidden;
}
// trigger load before mount and on props change
watchers.push(
watch(
() => JSON.stringify([props.collection?.id, props.filter, props.sort, props.reset]),
(newVal, oldVal) => {
if (newVal != oldVal) {
loadRecords(true);
}
},
),
);
let deleteRefreshTimeoutId;
const documentEvents = {
@@ -302,16 +290,45 @@ window.app.components.recordsList = function(propsArg = {}) {
}
watchers.push(
watch(() => props.collection?.id, (newId, oldId) => {
data.columnsPreferences = app.utils.getLocalHistory(
app.consts.COLUMNS_STORAGE_PREFIX + newId,
{},
);
watch(
() => props.collection?.id,
(newId, oldId) => {
data.columnsPreferences = app.utils.getLocalHistory(
app.consts.COLUMNS_STORAGE_PREFIX + newId,
{},
);
if (oldId && oldId != newId) {
clearList();
}
}),
if (oldId && oldId != newId) {
clearList();
}
},
),
);
// trigger load on props change
watchers.push(
watch(
() =>
(props.collection?.id || "") + (props.filter || "") + (props.sort || "")
+ (props.reset || ""),
(newVal, oldVal) => {
if (newVal != oldVal) {
loadRecords(true);
}
},
),
);
// always scroll to top on first page load
watchers.push(
watch(
() => data.lastPage,
(page) => {
if (page == 1 && el) {
el.scrollTop = 0;
}
},
),
);
watchers.push(
@@ -327,17 +344,6 @@ window.app.components.recordsList = function(propsArg = {}) {
},
),
);
watchers.push(
watch(
() => data.lastPage,
(page) => {
if (page == 1 && el) {
el.scrollTop = 0;
}
},
),
);
},
onunmount: () => {
app.pb.cancelRequest(uniqueId);