initial work on updating touch bar item config without rerender

This commit is contained in:
Samuel Attard 2016-12-16 17:24:51 +11:00 committed by Kevin Sawicki
parent 61949657f0
commit dd09c91cf2
10 changed files with 98 additions and 27 deletions

View file

@ -212,6 +212,12 @@ BrowserWindow.prototype.setTouchBar = function (touchBar) {
} else {
this._setTouchBar(touchBar.toJSON())
}
touchBar._owner = this
touchBar.items.forEach((item) => { item._owner = this; })
}
BrowserWindow.prototype._updateTouchBarItem = function (itemID) {
this._refreshTouchBarItem(itemID);
}
module.exports = BrowserWindow

View file

@ -44,6 +44,16 @@ class TouchBarItem {
}
}
updateConfig(newConfig) {
if (!this._owner) {
throw new Error('Cannot call methods on TouchBarItems without assigning to a BrowserWindow');
}
const dupConfig = Object.assign({}, newConfig);
delete dupConfig.id;
Object.assign(this.config, dupConfig);
this._owner._updateTouchBarItem(this.toJSON());
}
toJSON () {
return this.config
}