store script state in hash and not query

This commit is contained in:
Ruben Fiszel
2023-08-23 02:31:39 +02:00
parent afc0328e47
commit d5984703ca
3 changed files with 5 additions and 4 deletions
@@ -5,7 +5,7 @@
import { inferArgs } from '$lib/infer'
import { initialCode } from '$lib/script_helpers'
import { enterpriseLicense, userStore, workerTags, workspaceStore } from '$lib/stores'
import { emptySchema, encodeState, getModifierKey, setQueryWithoutLoad } from '$lib/utils'
import { emptySchema, encodeState, getModifierKey } from '$lib/utils'
import Path from './Path.svelte'
import ScriptEditor from './ScriptEditor.svelte'
import ScriptSchema from './ScriptSchema.svelte'
@@ -117,9 +117,10 @@
$page.url.searchParams.delete(x)
}
})
setQueryWithoutLoad($page.url, [{ key: 'state', value: encodeState(script) }])
}
$: window.history.replaceState(null, '', '#' + encodeState(script))
if (script.content == '') {
initContent(script.language, script.kind, template)
}
@@ -17,7 +17,7 @@
const path = $page.url.searchParams.get('path')
const initialState = $page.url.searchParams.get('state')
const initialState = $page.url.hash != '' ? $page.url.hash.slice(1) : undefined
let scriptBuilder: ScriptBuilder | undefined = undefined
@@ -9,7 +9,7 @@
import { sendUserToast } from '$lib/toast'
import DiffDrawer from '$lib/components/DiffDrawer.svelte'
const initialState = $page.url.searchParams.get('state')
const initialState = $page.url.hash != '' ? $page.url.hash.slice(1) : undefined
let initialArgs = {}
if ($runFormStore) {
initialArgs = $runFormStore