moved filter autocomplete to worker

This commit is contained in:
Gani Georgiev
2024-02-24 13:46:16 +02:00
parent 4f46222de9
commit 20fba0f686
40 changed files with 2990 additions and 2918 deletions

View File

@@ -0,0 +1,39 @@
import CommonHelper from "@/utils/CommonHelper";
const maxKeys = 11000;
onmessage = (e) => {
if (!e.data.collections) {
return;
}
const result = {};
result.baseKeys = CommonHelper.getCollectionAutocompleteKeys(e.data.collections, e.data.baseCollection?.name);
result.baseKeys = limitArray(result.baseKeys.sort(keysSort), maxKeys);
if (!e.data.disableRequestKeys) {
result.requestKeys = CommonHelper.getRequestAutocompleteKeys(e.data.collections, e.data.baseCollection?.name);
result.requestKeys = limitArray(result.requestKeys.sort(keysSort), maxKeys);
}
if (!e.data.disableCollectionJoinKeys) {
result.collectionJoinKeys = CommonHelper.getCollectionJoinAutocompleteKeys(e.data.collections);
result.collectionJoinKeys = limitArray(result.collectionJoinKeys.sort(keysSort), maxKeys);
}
postMessage(result);
};
// sort shorter keys first
function keysSort(a, b) {
return a.length - b.length;
}
function limitArray(arr, max) {
if (arr.length > max) {
return arr.slice(0, max);
}
return arr;
}