Line data Source code
1 : import { useLinkPresentationStore } from '@/stores/linkPresentationStore'
2 : import type { GraphScope } from '@comfyorg/graph-model/graphScopeId'
3 : import type { LinkId } from '@comfyorg/graph-model/linkId'
4 : import type { LinkPresentation } from '@comfyorg/graph-model/linkPresentation'
5 :
6 185 : export function getAgreedLinkPresentation(
7 : presentations: readonly (Readonly<LinkPresentation> | undefined)[]
8 : ): Readonly<LinkPresentation> | undefined {
9 185 : const [first] = presentations
10 185 : return presentations.every(
11 : (candidate) =>
12 : candidate?.hidden === first?.hidden && candidate?.label === first?.label
13 : )
14 : ? first
15 : : undefined
16 : }
17 :
18 270 : export function transferLinkPresentation(
19 : scope: GraphScope,
20 : source: Readonly<LinkPresentation> | undefined,
21 : targetId: LinkId | undefined
22 : ): void {
23 270 : if (targetId === undefined || !source) return
24 77 : useLinkPresentationStore().patch(scope, targetId, source)
25 : }
|