mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +00:00
fix(editor): Fix inifnite loading in Resource Locator Dropdown under certain conditions (#16773)
This commit is contained in:
committed by
GitHub
parent
06f49c294a
commit
8e62c80d48
@@ -656,9 +656,13 @@ function loadResourcesDebounced() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setResponse(paramsKey: string, response: Partial<IResourceLocatorQuery>) {
|
function setResponse(paramsKey: string, response: Partial<IResourceLocatorQuery>) {
|
||||||
|
// Force reactivity by creating a completely new cached responses object
|
||||||
|
const existingResponse = cachedResponses.value[paramsKey] || {};
|
||||||
|
const newResponse = { ...existingResponse, ...response };
|
||||||
|
|
||||||
cachedResponses.value = {
|
cachedResponses.value = {
|
||||||
...cachedResponses.value,
|
...cachedResponses.value,
|
||||||
[paramsKey]: { ...cachedResponses.value[paramsKey], ...response },
|
[paramsKey]: newResponse,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,19 +733,28 @@ async function loadResources() {
|
|||||||
|
|
||||||
const response = await nodeTypesStore.getResourceLocatorResults(requestParams);
|
const response = await nodeTypesStore.getResourceLocatorResults(requestParams);
|
||||||
|
|
||||||
setResponse(paramsKey, {
|
const responseData = {
|
||||||
results: (cachedResponse?.results ?? []).concat(response.results),
|
results: (cachedResponse?.results ?? []).concat(response.results),
|
||||||
nextPageToken: response.paginationToken ?? null,
|
nextPageToken: response.paginationToken ?? null,
|
||||||
loading: false,
|
loading: false,
|
||||||
error: false,
|
error: false,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Store response under the original key to prevent cache pollution
|
||||||
|
setResponse(paramsKey, responseData);
|
||||||
|
|
||||||
|
// If the key changed during the request, also store under current key to prevent infinite loading
|
||||||
|
const currentKey = currentRequestKey.value;
|
||||||
|
if (currentKey !== paramsKey) {
|
||||||
|
setResponse(currentKey, responseData);
|
||||||
|
}
|
||||||
|
|
||||||
if (params.filter && !hasCompletedASearch.value) {
|
if (params.filter && !hasCompletedASearch.value) {
|
||||||
hasCompletedASearch.value = true;
|
hasCompletedASearch.value = true;
|
||||||
trackEvent('User searched resource locator list');
|
trackEvent('User searched resource locator list');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setResponse(paramsKey, {
|
const errorData = {
|
||||||
loading: false,
|
loading: false,
|
||||||
error: true,
|
error: true,
|
||||||
errorDetails: {
|
errorDetails: {
|
||||||
@@ -750,7 +763,16 @@ async function loadResources() {
|
|||||||
httpCode: e.httpCode,
|
httpCode: e.httpCode,
|
||||||
stackTrace: e.stacktrace,
|
stackTrace: e.stacktrace,
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Store error under the original key
|
||||||
|
setResponse(paramsKey, errorData);
|
||||||
|
|
||||||
|
// If the key changed during the request, also store under current key to prevent infinite loading
|
||||||
|
const currentKey = currentRequestKey.value;
|
||||||
|
if (currentKey !== paramsKey) {
|
||||||
|
setResponse(currentKey, errorData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user