Skip to content

Commit

Permalink
fix also watch data-less constant pin
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmtimbo committed Aug 15, 2024
1 parent 9f3779b commit 2d0ef9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
23 changes: 4 additions & 19 deletions src/Class/Graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3699,17 +3699,12 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>

let unit_pin_data_listener: Dict<IOOf<Dict<Function>>> = {}

const setup_unit_contant_pin = (
const setup_unit_constant_pin = (
type: IO,
pinId: string,
data: any,
fork: boolean = true,
bubble: boolean = true
) => {
if (data === undefined) {
return
}

const pin = this.getUnitPin(unitId, type, pinId)

fork && this._fork(undefined, true, bubble)
Expand Down Expand Up @@ -3737,22 +3732,12 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>

forEach(inputs, (pinId) => {
if (unit.isPinConstant('input', pinId)) {
setup_unit_contant_pin(
'input',
pinId,
unit.getPinData('input', pinId),
false
)
setup_unit_constant_pin('input', pinId, false)
}
})
forEach(outputs, (pinId) => {
if (unit.isPinConstant('output', pinId)) {
setup_unit_contant_pin(
'output',
pinId,
unit.getPinData('output', pinId),
false
)
setup_unit_constant_pin('output', pinId, false)
}
})

Expand Down Expand Up @@ -3784,7 +3769,7 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>
const data = this.getUnitPinData(unitId, type, pinId)

if (constant) {
setup_unit_contant_pin(type, pinId, data)
setup_unit_constant_pin(type, pinId, data)
} else {
const pin_data_unlisten = deepGetOrDefault(
unit_pin_data_listener,
Expand Down
26 changes: 18 additions & 8 deletions src/system/platform/component/app/Editor/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28269,7 +28269,7 @@ export class Editor_ extends Element<HTMLDivElement, _Props> {
if (constant) {
const global_ref = this._unit_ref_pin_global_ref[pin_node_id]

this._watch_constant_input_ref(unitId, type, pinId, global_ref)
this._watch_constant_ref_pin(unitId, type, pinId, global_ref)
} else {
this._unwatch_constant_input_ref(unitId, type, pinId)
}
Expand Down Expand Up @@ -56929,7 +56929,7 @@ export class Editor_ extends Element<HTMLDivElement, _Props> {
private _constant_input_ref_unlisten: Dict<Dict<Unlisten>> = {}
private _constant_input_ref_interval: Dict<Dict<number>> = {}

private _watch_constant_input_ref = (
private _watch_constant_ref_pin = (
unit_id: string,
type: 'input',
pin_id: string,
Expand Down Expand Up @@ -57460,6 +57460,19 @@ export class Editor_ extends Element<HTMLDivElement, _Props> {

private _unit_ref_pin_global_ref: Dict<GlobalRefSpec> = {}

private _should_watch_ref_pin = (
pin_node_id: string,
unitId: string,
type: IO,
pinId: string
): boolean => {
return (
this._is_input_pin_node_id(pin_node_id) &&
this._is_link_pin_ref(pin_node_id) &&
this._spec_is_link_pin_constant(unitId, type, pinId)
)
}

private _on_graph_unit_ref_link_pin_data_moment = (
_data: GraphUnitPinDataMomentData
) => {
Expand All @@ -57473,13 +57486,10 @@ export class Editor_ extends Element<HTMLDivElement, _Props> {

this._unit_ref_pin_global_ref[pin_node_id] = _data.data

if (
this._is_input_pin_node_id(pin_node_id) &&
this._spec_is_link_pin_constant(unitId, type, pinId)
) {
if (this._should_watch_ref_pin(pin_node_id, unitId, type, pinId)) {
this._tick_constant_input_ref(unitId, pinId, _data.data)

this._watch_constant_input_ref(unitId, 'input', pinId, _data.data)
this._watch_constant_ref_pin(unitId, 'input', pinId, _data.data)
}

if (this._pin_to_datum[pin_node_id]) {
Expand Down Expand Up @@ -57786,7 +57796,7 @@ export class Editor_ extends Element<HTMLDivElement, _Props> {
pin_node_id: string,
tree: TreeNode
): void => {
// console.log('Graph', '_graph_debug_set_pin_data', pin_node_id, data)
// console.log('Graph', '_graph_debug_set_pin_data', pin_node_id, tree)

const { parent } = this.$props

Expand Down

0 comments on commit 2d0ef9e

Please sign in to comment.