Skip to content

Commit

Permalink
fix(colors): safe overwrite of method
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelass committed Jul 30, 2023
1 parent f6d89ca commit 58ded92
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions extensions/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ function colorByType(app) {

function colorPositiveNegative(app) {
app.graph._nodes.forEach((node) => {
// const onPropertyChanged = node.onPropertyChanged;
// node.onPropertyChanged = function () {};
if (node.title.toLowerCase().includes("positive")) {
const bgcolor = hslToHex(120 / 360, 0.4, 0.3);
const color = hslToHex(120 / 360, 0.4, 0.2);
Expand All @@ -146,30 +148,34 @@ function colorPositiveNegative(app) {
/**
* Colors
*/

let afterChange;
function setColorMode(value, app) {
switch (value) {
case 1:
app.graph.afterChange = () => {
app.graph.afterChange = function () {
uncolor(app);
return applyChanges?.apply(this, arguments);
};
uncolor(app);
break;
case 2:
app.graph.afterChange = () => {
app.graph.afterChange = function () {
rainbowify(app);
return applyChanges?.apply(this, arguments);
};
rainbowify(app);
break;
case 3:
app.graph.afterChange = () => {
app.graph.afterChange = function () {
colorByType(app);
return applyChanges?.apply(this, arguments);
};
colorByType(app);
break;
case 4:
app.graph.afterChange = () => {
app.graph.afterChange = function () {
colorPositiveNegative(app);
return applyChanges?.apply(this, arguments);
};
colorPositiveNegative(app);
break;
Expand All @@ -178,7 +184,6 @@ function setColorMode(value, app) {
break;
}
}
let afterChange;

const colorModes = ["default", "plain", "rainbow", "type", "positive/negative"];
const colorsName = "Failfast.colors";
Expand Down

0 comments on commit 58ded92

Please sign in to comment.