Skip to content

Commit

Permalink
Feedback from review
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehenry committed Jul 8, 2024
1 parent 2356bb8 commit 38bbfc7
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@
if (options.deck !== undefined && options.group !== undefined) {
console.warn(
"options.deck and option.group are both set; " +
"options.deck will take priority"
"options.deck will take priority"
);
}

Expand All @@ -745,36 +745,41 @@
delete options.deck;
delete options.group;

Component.call(this, options);

this._deck = undefined;
this._group = undefined;
const self = this;

options = {
...(options || {}),
get deck() {
return self._deck;
},
set deck(value) {
if (Number.isInteger(value) && value > 0) {
self._deck = value;
self._group = `[Channel${value}]`;
}
},
get group() {
return self._deck;
},
set group(value) {
const deck = script.deckFromGroup(value);
if (deck > 0) {
self._deck = deck;
self._group = `[Channel${deck}]`;
}
Object.defineProperties(this, {
"deck": {
get() {
return this._deck;
},
set(value) {
if (Number.isInteger(value) && value > 0) {
this._deck = value;
this._group = `[Channel${value}]`;
this.reset();
}
},
},
};

Component.call(this, options);
"group": {
get() {
return this._group;
},
set(value) {
const deck = script.deckFromGroup(value);
if (deck > 0) {
this._deck = deck;
this._group = `[Channel${deck}]`;
this.reset();
}
},
}
});

this.deck = deck;

if (!this.deck) {
this.group = group; // try setting deck from group
}
Expand Down Expand Up @@ -806,7 +811,7 @@
},
inputWheel: function(_channel, _control, value, _status, _group) {
if (!this.deck) {
console.warn("no deck number; inputWheel() ignored");
return;
}

value = this.inValueScale(value);
Expand All @@ -818,7 +823,7 @@
},
inputTouch: function(channel, control, value, status, _group) {
if (!this.deck) {
console.warn("no deck number; inputTouch() ignored");
return;
}

if (this.isPress(channel, control, value, status) && this.vinylMode) {
Expand All @@ -835,6 +840,7 @@
throw "Called wrong input handler for " + status + ": " + control + ".\n" +
"Please bind jogwheel-related messages to inputWheel and inputTouch!\n";
},
reset() {},
});

const EffectUnit = function(unitNumbers, allowFocusWhenParametersHidden, colors) {
Expand Down

0 comments on commit 38bbfc7

Please sign in to comment.