Skip to content

Commit

Permalink
fix: proper dispatch action
Browse files Browse the repository at this point in the history
  • Loading branch information
sareyu committed Aug 16, 2024
1 parent d936243 commit 0b1ad4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 0 additions & 7 deletions src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
goToPreviousQuery,
saveQueryToHistory,
setTenantPath,
updateQueryInHistory,
} from '../../../../store/reducers/executeQuery';
import {explainQueryApi} from '../../../../store/reducers/explainQuery/explainQuery';
import type {PreparedExplainResponse} from '../../../../store/reducers/explainQuery/types';
Expand Down Expand Up @@ -85,7 +84,6 @@ interface QueryEditorProps {
showPreview: boolean;
setShowPreview: (...args: Parameters<typeof setShowPreview>) => void;
saveQueryToHistory: (...args: Parameters<typeof saveQueryToHistory>) => void;
updateQueryInHistory: (...args: Parameters<typeof updateQueryInHistory>) => void;
}

function QueryEditor(props: QueryEditorProps) {
Expand Down Expand Up @@ -172,10 +170,6 @@ function QueryEditor(props: QueryEditorProps) {
schema,
enableTracingLevel,
queryId,
}).then((res) => {
if ('data' in res) {
props.updateQueryInHistory(res.data.stats, queryId);
}
});
setIsResultLoaded(true);
props.setShowPreview(false);
Expand Down Expand Up @@ -419,7 +413,6 @@ const mapStateToProps = (state: RootState) => {

const mapDispatchToProps = {
saveQueryToHistory,
updateQueryInHistory,
goToPreviousQuery,
goToNextQuery,
setShowPreview,
Expand Down
8 changes: 5 additions & 3 deletions src/store/reducers/executeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const executeQueryApi = api.injectEndpoints({
enableTracingLevel,
queryId,
},
{signal},
{signal, dispatch},
) => {
let action: ExecuteActions = 'execute';
let syntax: QuerySyntax = QUERY_SYNTAX.yql;
Expand Down Expand Up @@ -234,6 +234,8 @@ export const executeQueryApi = api.injectEndpoints({
}

const data = parseQueryAPIExecuteResponse(response);

dispatch(updateQueryInHistory(data.stats, queryId));
return {data};
} catch (error) {
return {error};
Expand All @@ -251,12 +253,12 @@ export const saveQueryToHistory = (queryText: string, queryId: string) => {
} as const;
};

export const updateQueryInHistory = (stats: IQueryResult['stats'], queryId: string) => {
export function updateQueryInHistory(stats: IQueryResult['stats'], queryId: string) {
return {
type: UPDATE_QUERY_IN_HISTORY,
data: {queryId, stats},
} as const;
};
}

export const goToPreviousQuery = () => {
return {
Expand Down

0 comments on commit 0b1ad4d

Please sign in to comment.