fixes: query chaining with events

This commit is contained in:
arpitnath 2023-09-06 01:50:10 +05:30
parent c5622a139b
commit 5040a7bc30
3 changed files with 7 additions and 13 deletions

View file

@ -350,7 +350,7 @@ const EditorComponent = (props) => {
};
const fetchDataQueries = async (id, selectFirstQuery = false, runQueriesOnAppLoad = false) => {
await useDataQueriesStore.getState().actions.fetchDataQueries(id, selectFirstQuery, runQueriesOnAppLoad, editorRef);
await useDataQueriesStore.getState().actions.fetchDataQueries(id, selectFirstQuery, runQueriesOnAppLoad);
};
const fetchDataSources = (id) => {
@ -646,9 +646,6 @@ const EditorComponent = (props) => {
currentVersionId: data?.editing_version?.id,
});
await fetchDataSources(data.editing_version?.id);
await fetchDataQueries(data.editing_version?.id, true, true);
const appDefData = buildAppDefinition(data);
const appJson = appDefData;
@ -676,6 +673,9 @@ const EditorComponent = (props) => {
isUpdatingEditorStateInProcess: false,
});
await fetchDataSources(data.editing_version?.id);
await fetchDataQueries(data.editing_version?.id, true, true);
const currentPageEvents = data.events.filter((event) => event.target === 'page' && event.sourceId === homePageId);
for (const currentEvent of currentPageEvents ?? []) {

View file

@ -29,7 +29,6 @@ export const EventManager = ({
eventSourceType,
eventMetaDefinition,
components,
excludeEvents,
popOverCallback,
popoverPlacement,
@ -51,14 +50,11 @@ export const EventManager = ({
const currentEvents = allAppEvents.filter((event) => event.sourceId === sourceId);
// console.log('----arpit currentEvents ', { currentEvents, allAppEvents, sourceId, eventSourceType });
const [events, setEvents] = useState([]);
const [focusedEventIndex, setFocusedEventIndex] = useState(null);
const { t } = useTranslation();
useEffect(() => {
console.log('----arpit current events changed ', { currentEvents, events });
if (_.isEqual(currentEvents, events)) return;
setEvents(currentEvents || []);
@ -224,10 +220,8 @@ export const EventManager = ({
newEvents[index] = updatedEvent;
const diffPatches = diff(currentEvents[index], updatedEvent);
const isDeepEqual = _.isEqual(currentEvents[index], updatedEvent);
setEvents(newEvents);
console.log('----moh handler changed-arpit ', { diffPatches, isDeepEqual });
setEvents(newEvents);
updateAppVersionEventHandlers(
[

View file

@ -26,7 +26,7 @@ export const useDataQueriesStore = create(
...initialState,
actions: {
// TODO: Remove editor state while changing currentState
fetchDataQueries: async (appId, selectFirstQuery = false, runQueriesOnAppLoad = false, editorRef) => {
fetchDataQueries: async (appId, selectFirstQuery = false, runQueriesOnAppLoad = false) => {
set({ loadingDataQueries: true });
const data = await dataqueryService.getAll(appId);
set((state) => ({
@ -34,7 +34,7 @@ export const useDataQueriesStore = create(
loadingDataQueries: false,
}));
// Runs query on loading application
if (runQueriesOnAppLoad) runQueries(data.data_queries, editorRef);
if (runQueriesOnAppLoad) runQueries(data.data_queries, {});
// Compute query state to be added in the current state
const { actions, selectedQuery } = useQueryPanelStore.getState();
if (selectFirstQuery) {