From b19619c2d231ab6372f66e862fbf3d6589e8a542 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 8 Nov 2024 17:37:07 -0500 Subject: [PATCH] add state updaet --- .../editor/multitabEditorLogic.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.ts b/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.ts index 58f2c86be24..0b33865b20c 100644 --- a/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.ts +++ b/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.ts @@ -23,6 +23,7 @@ export const multitabEditorLogic = kea([ props({} as MultitabEditorLogicProps), actions({ setQueryInput: (queryInput: string) => ({ queryInput }), + updateState: true, runQuery: (queryOverride?: string) => ({ queryOverride }), setActiveQuery: (query: string) => ({ query }), setTabs: (tabs: Uri[]) => ({ tabs }), @@ -178,6 +179,22 @@ export const multitabEditorLogic = kea([ } } }, + setQueryInput: () => { + actions.updateState() + }, + updateState: async (_, breakpoint) => { + await breakpoint(100) + const queries = values.allTabs.map((model) => { + return { + query: props.monaco?.editor.getModel(model)?.getValue() || { + kind: NodeKind.HogQLQuery, + query: '', + }, + path: model.path.split('/').pop(), + } + }) + localStorage.setItem(editorModelsStateKey(props.key), JSON.stringify(queries)) + }, runQuery: ({ queryOverride }) => { actions.setActiveQuery(queryOverride || values.queryInput) },