Do not set location hash until subgraph navigation

This commit is contained in:
Austin Mroz
2025-12-01 19:04:46 -08:00
parent 3142e5381d
commit db9627e02e

View File

@@ -165,7 +165,11 @@ export const useSubgraphNavigationStore = defineStore(
//Allow navigation with forward/back buttons
//TODO: Extend for dialogues?
//TODO: force update widget.promoted
async function navigateToHash(newHash: string | undefined | null) {
async function navigateToHash(
newHash: string | undefined | null,
oldHash: string | undefined | null
) {
if (!oldHash) return
const root = app.graph
const locatorId = newHash?.slice(1) ?? root.id
const canvas = canvasStore.getCanvas()
@@ -206,18 +210,17 @@ export const useSubgraphNavigationStore = defineStore(
async function updateHash() {
if (blockHashUpdate) return
if (!routeHash.value) {
if (initialLoad) {
initialLoad = false
await router.replace(
'#' + (window.location.hash.slice(1) || app.graph.id)
)
} else if (initialLoad) {
initialLoad = false
await navigateToHash(routeHash.value)
if (!routeHash.value) return
await navigateToHash(routeHash.value, 'placeholder')
const graph = canvasStore.getCanvas().graph
if (isSubgraph(graph)) workflowStore.activeSubgraph = graph
return
}
if (!routeHash.value) {
await router.replace('#' + app.graph.id)
}
const newId = canvasStore.getCanvas().graph?.id ?? ''
const currentId = window.location.hash.slice(1)
if (!newId || newId === (currentId || app.graph.id)) return