mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
Navigation cleanup, fix test
This commit is contained in:
@@ -157,6 +157,8 @@ export const useSubgraphNavigationStore = defineStore(
|
||||
onNavigated(newValue, oldValue)
|
||||
}
|
||||
)
|
||||
|
||||
//Allow navigation with forward/back buttons
|
||||
const routeHash = ref(window.location.hash)
|
||||
const originalOnHashChange = window.onhashchange
|
||||
window.onhashchange = (...args) => {
|
||||
@@ -166,16 +168,9 @@ export const useSubgraphNavigationStore = defineStore(
|
||||
let blockHashUpdate = false
|
||||
let initialLoad = true
|
||||
|
||||
//Allow navigation with forward/back buttons
|
||||
//TODO: Extend for dialogues?
|
||||
//TODO: force update widget.promoted
|
||||
async function navigateToHash(
|
||||
newHash: string | undefined | null,
|
||||
oldHash: string | undefined | null
|
||||
) {
|
||||
if (!oldHash) return
|
||||
async function navigateToHash(newHash: string) {
|
||||
const root = app.rootGraph
|
||||
const locatorId = newHash?.slice(1) ?? root.id
|
||||
const locatorId = newHash?.slice(1) || root.id
|
||||
const canvas = canvasStore.getCanvas()
|
||||
if (canvas.graph?.id === locatorId) return
|
||||
const targetGraph =
|
||||
@@ -217,7 +212,7 @@ export const useSubgraphNavigationStore = defineStore(
|
||||
if (initialLoad) {
|
||||
initialLoad = false
|
||||
if (!routeHash.value) return
|
||||
await navigateToHash(routeHash.value, 'placeholder')
|
||||
await navigateToHash(routeHash.value)
|
||||
const graph = canvasStore.getCanvas().graph
|
||||
if (isSubgraph(graph)) workflowStore.activeSubgraph = graph
|
||||
return
|
||||
@@ -229,6 +224,7 @@ export const useSubgraphNavigationStore = defineStore(
|
||||
const currentId = window.location.hash.slice(1)
|
||||
if (!newId || newId === (currentId || app.rootGraph.id)) return
|
||||
await router.push('#' + newId)
|
||||
routeHash.value = '#' + newId
|
||||
}
|
||||
//update navigation hash
|
||||
//NOTE: Doesn't apply on workflow load
|
||||
|
||||
@@ -4,10 +4,11 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { ComfyNodeDef as ComfyNodeDefV1 } from '@/schemas/nodeDefSchema'
|
||||
import { api } from '@/scripts/api'
|
||||
import { app as comfyApp } from '@/scripts/app'
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
import { useNodeDefStore } from '@/stores/nodeDefStore'
|
||||
import { useSubgraphStore } from '@/stores/subgraphStore'
|
||||
|
||||
import { useLitegraphService } from '@/services/litegraphService'
|
||||
|
||||
import {
|
||||
createTestSubgraph,
|
||||
createTestSubgraphNode
|
||||
|
||||
Reference in New Issue
Block a user