From 07d6a6cc7b3f45c3e1c1c45208bccfe69860fe56 Mon Sep 17 00:00:00 2001 From: arpitnath Date: Fri, 5 Apr 2024 17:25:19 +0530 Subject: [PATCH] clean up --- frontend/src/Editor/Editor.jsx | 34 +++++++++------------------- frontend/src/_helpers/appUtils.js | 16 +++++++------ frontend/src/_stores/appDataStore.js | 11 ++++----- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index 25d087a3aa..8c2639cc87 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -792,29 +792,17 @@ const EditorComponent = (props) => { let dataQueries = JSON.parse(JSON.stringify(useDataQueriesStore.getState().dataQueries)); let allEvents = JSON.parse(JSON.stringify(useAppDataStore.getState().events)); - const entityReferencesInComponentDefinitions = findAllEntityReferences(currentComponents, []) - ?.map((entity) => { - if (entity && isValidUUID(entity)) { - return entity; - } - }) - ?.filter((e) => e !== undefined); + const entityReferencesInComponentDefinitions = findAllEntityReferences(currentComponents, [])?.filter( + (entity) => entity && isValidUUID(entity) + ); - const entityReferencesInQueryoOptions = findAllEntityReferences(dataQueries, []) - ?.map((entity) => { - if (entity && isValidUUID(entity)) { - return entity; - } - }) - ?.filter((e) => e !== undefined); + const entityReferencesInQueryOptions = findAllEntityReferences(dataQueries, [])?.filter( + (entity) => entity && isValidUUID(entity) + ); - const entityReferencesInEvents = findAllEntityReferences(allEvents, []) - ?.map((entity) => { - if (entity && isValidUUID(entity)) { - return entity; - } - }) - ?.filter((e) => e !== undefined); + const entityReferencesInEvents = findAllEntityReferences(allEvents, [])?.filter( + (entity) => entity && isValidUUID(entity) + ); const manager = useResolveStore.getState().referenceMapper; @@ -843,14 +831,14 @@ const EditorComponent = (props) => { }); } - if (Array.isArray(entityReferencesInQueryoOptions) && entityReferencesInQueryoOptions?.length > 0) { + if (Array.isArray(entityReferencesInQueryOptions) && entityReferencesInQueryOptions?.length > 0) { let newQueryOptions = {}; dataQueries?.forEach((query) => { newQueryOptions[query.id] = query.options; ``; }); - entityReferencesInQueryoOptions.forEach((entity) => { + entityReferencesInQueryOptions.forEach((entity) => { const entityrefExists = manager.has(entity); if (entityrefExists) { diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index beebecae5a..e1ddd1bc2c 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -1300,14 +1300,16 @@ export function runQuery( }, }); - useResolveStore.getState().actions.addAppSuggestions({ - queries: { - [queryName]: { - data: finalData, - isLoading: false, + if (mode === 'edit') { + useResolveStore.getState().actions.addAppSuggestions({ + queries: { + [queryName]: { + data: finalData, + isLoading: false, + }, }, - }, - }); + }); + } const basePath = `queries.${queryName}`; diff --git a/frontend/src/_stores/appDataStore.js b/frontend/src/_stores/appDataStore.js index f8227587c1..9cf9365fe5 100644 --- a/frontend/src/_stores/appDataStore.js +++ b/frontend/src/_stores/appDataStore.js @@ -111,13 +111,10 @@ export const useAppDataStore = create( } }); - const entityReferencesInEvents = findAllEntityReferences(updatedEvents, []) - ?.map((entity) => { - if (entity && isValidUUID(entity)) { - return entity; - } - }) - ?.filter((e) => e !== undefined); + const entityReferencesInEvents = findAllEntityReferences(updatedEvents, [])?.filter( + (entity) => entity && isValidUUID(entity) + ); + const manager = useResolveStore.getState().referenceMapper; let newEvents = JSON.parse(JSON.stringify(updatedEvents));