Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed May 13, 2022
1 parent 4a07c10 commit 55202ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function DefaultEditorSideBarComponent({

// subscribe on external vis changes using browser history, for example press back button
useEffect(() => {
const resetHandler = (setIsDirty?: boolean) => dispatch(discardChanges(vis, setIsDirty));
const resetHandler = () => dispatch(discardChanges(vis));
eventEmitter.on('updateEditor', resetHandler);

return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ type AggId = IAggConfig['id'];
type AggParams = IAggConfig['params'];

type AddNewAgg = ActionType<EditorStateActionTypes.ADD_NEW_AGG, { schema: Schema }>;
type DiscardChanges = ActionType<
EditorStateActionTypes.DISCARD_CHANGES,
{ vis: Vis; setDirty: boolean }
>;
type DiscardChanges = ActionType<EditorStateActionTypes.DISCARD_CHANGES, { vis: Vis }>;
type ChangeAggType = ActionType<
EditorStateActionTypes.CHANGE_AGG_TYPE,
{ aggId: AggId; value: IAggConfig['type'] }
Expand Down Expand Up @@ -67,7 +64,7 @@ export type EditorAction =

export interface EditorActions {
addNewAgg(schema: Schema): AddNewAgg;
discardChanges(vis: Vis, setDirty?: boolean): DiscardChanges;
discardChanges(vis: Vis): DiscardChanges;
changeAggType(aggId: AggId, value: IAggConfig['type']): ChangeAggType;
setAggParamValue<T extends keyof AggParams>(
aggId: AggId,
Expand All @@ -91,9 +88,9 @@ const addNewAgg: EditorActions['addNewAgg'] = (schema) => ({
},
});

const discardChanges: EditorActions['discardChanges'] = (vis, setDirty = false) => ({
const discardChanges: EditorActions['discardChanges'] = (vis) => ({
type: EditorStateActionTypes.DISCARD_CHANGES,
payload: { vis, setDirty },
payload: { vis },
});

const changeAggType: EditorActions['changeAggType'] = (aggId, value) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export const useDataViewUpdates = (
dataView !== visInstance.vis.data.indexPattern?.id
) {
const selectedDataView = await services.dataViews.get(dataView);

if (selectedDataView) {
updateDataView(visInstance, selectedDataView);
eventEmitter.emit('updateEditor', setDirty);
visInstance.embeddableHandler.reload();
eventEmitter.emit('updateEditor');
}
}
};
Expand Down

0 comments on commit 55202ad

Please sign in to comment.