0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00

add state updaet

This commit is contained in:
eric 2024-11-08 17:37:07 -05:00
parent a008e95b8f
commit b19619c2d2

View File

@ -23,6 +23,7 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
props({} as MultitabEditorLogicProps), props({} as MultitabEditorLogicProps),
actions({ actions({
setQueryInput: (queryInput: string) => ({ queryInput }), setQueryInput: (queryInput: string) => ({ queryInput }),
updateState: true,
runQuery: (queryOverride?: string) => ({ queryOverride }), runQuery: (queryOverride?: string) => ({ queryOverride }),
setActiveQuery: (query: string) => ({ query }), setActiveQuery: (query: string) => ({ query }),
setTabs: (tabs: Uri[]) => ({ tabs }), setTabs: (tabs: Uri[]) => ({ tabs }),
@ -178,6 +179,22 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
} }
} }
}, },
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 }) => { runQuery: ({ queryOverride }) => {
actions.setActiveQuery(queryOverride || values.queryInput) actions.setActiveQuery(queryOverride || values.queryInput)
}, },