Skip to content

Commit ea8f500

Browse files
committed
fix: fix for complex remaining_* configs
1 parent f575796 commit ea8f500

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

src/chart.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,31 @@ export class Chart extends LitElement {
118118
return;
119119
}
120120
const { parent, child } = connection;
121-
if (parent.type === 'remaining_child_state') {
122-
this.connectionsByParent.get(parent)!.forEach((c) => {
123-
if (!c.ready) {
124-
this.connectionsByChild.get(c.child)?.forEach((conn) => {
125-
if (conn.parent !== connection.parent) {
126-
this._calcConnection(conn, accountedIn, accountedOut);
127-
}
128-
});
129-
}
130-
});
131-
}
132-
if (child.type === 'remaining_parent_state') {
133-
this.connectionsByChild.get(child)!.forEach((c) => {
134-
if (!c.ready) {
135-
this.connectionsByParent.get(c.parent)?.forEach((conn) => {
136-
if (conn.child !== connection.child) {
137-
this._calcConnection(conn, accountedIn, accountedOut);
138-
}
139-
});
140-
}
141-
});
142-
}
143-
121+
[parent, child].forEach(ent => {
122+
if (ent.type === 'remaining_child_state') {
123+
this.connectionsByParent.get(ent)!.forEach((c) => {
124+
if (!c.ready) {
125+
this.connectionsByChild.get(c.child)?.forEach((conn) => {
126+
if (conn.parent !== parent) {
127+
this._calcConnection(conn, accountedIn, accountedOut);
128+
}
129+
});
130+
}
131+
});
132+
}
133+
if (ent.type === 'remaining_parent_state') {
134+
this.connectionsByChild.get(ent)!.forEach((c) => {
135+
if (!c.ready) {
136+
this.connectionsByParent.get(c.parent)?.forEach((conn) => {
137+
if (conn.child !== child) {
138+
this._calcConnection(conn, accountedIn, accountedOut);
139+
}
140+
});
141+
}
142+
});
143+
}
144+
});
145+
144146
const parentStateNormalized = this._getMemoizedState(parent);
145147
const parentStateFull = parentStateNormalized.state ?? 0;
146148
connection.prevParentState = accountedOut.get(parent) ?? 0;
@@ -149,6 +151,7 @@ export class Chart extends LitElement {
149151
const childStateFull = childStateNormalized.state ?? 0;
150152
connection.prevChildState = accountedIn.get(child) ?? 0;
151153
const childState = Math.max(0, childStateFull - connection.prevChildState);
154+
152155
if (!parentState || !childState) {
153156
connection.state = 0;
154157
} else {

0 commit comments

Comments
 (0)