From 5c68bf757253705f5983f9f6e905fab4de6bf39a Mon Sep 17 00:00:00 2001 From: Robbie Wagner Date: Tue, 10 Sep 2024 21:28:41 -0400 Subject: [PATCH] Remove touchbar support (#2206) --- app/components/kuler.ts | 20 ----------- app/routes/-private/application.ts | 18 ---------- electron-app/src/ipc-events.js | 5 --- electron-app/src/touchbar.js | 54 ------------------------------ 4 files changed, 97 deletions(-) delete mode 100644 electron-app/src/touchbar.js diff --git a/app/components/kuler.ts b/app/components/kuler.ts index f161a98ee..562e80220 100644 --- a/app/components/kuler.ts +++ b/app/components/kuler.ts @@ -74,8 +74,6 @@ export default class KulerComponent extends Component { this.ipcRenderer = ipcRenderer; - this._updateTouchbar(); - this.ipcRenderer.on( 'selectKulerColor', async (_event: unknown, colorIndex: number) => { @@ -174,8 +172,6 @@ export default class KulerComponent extends Component { this.selectedPalette.colors.mapBy('hex'), palette.selectedColorIndex, ); - - this._updateTouchbar(); } } @@ -206,8 +202,6 @@ export default class KulerComponent extends Component { this.selectedPalette.colors.mapBy('hex'), this.selectedPalette.selectedColorIndex, ); - - this._updateTouchbar(); } @action @@ -265,20 +259,6 @@ export default class KulerComponent extends Component { this.colorPicker.on('color:change', this._debouncedColorChange); this.colorPicker.on('color:setActive', this._onColorSetActive); } - - @action - _updateTouchbar(): void { - if (this.ipcRenderer) { - const itemsToShow = { - colorPicker: true, - kulerColors: { - colors: this.selectedPalette.colors, - }, - }; - - this.ipcRenderer.send('setTouchbar', itemsToShow); - } - } } declare module '@glint/environment-ember-loose/registry' { diff --git a/app/routes/-private/application.ts b/app/routes/-private/application.ts index 88910a4f6..f4526788f 100644 --- a/app/routes/-private/application.ts +++ b/app/routes/-private/application.ts @@ -4,8 +4,6 @@ import { service } from '@ember/service'; import type Session from 'ember-simple-auth/services/session'; -import type { IpcRenderer } from 'electron'; - import type DataService from 'swach/services/data'; export default class ApplicationRoute extends Route { @@ -13,22 +11,6 @@ export default class ApplicationRoute extends Route { @service declare router: Router; @service declare session: Session; - declare ipcRenderer: IpcRenderer; - - constructor() { - super(...arguments); - - if (typeof requireNode !== 'undefined') { - const { ipcRenderer } = requireNode('electron'); - - this.ipcRenderer = ipcRenderer; - - this.router.on('routeDidChange', () => { - this.ipcRenderer.send('setTouchbar', []); - }); - } - } - async beforeModel(): Promise { await this.session.setup(); diff --git a/electron-app/src/ipc-events.js b/electron-app/src/ipc-events.js index 2751738a3..772f13b5a 100644 --- a/electron-app/src/ipc-events.js +++ b/electron-app/src/ipc-events.js @@ -4,7 +4,6 @@ const fs = require('fs'); const { launchPicker } = require('./color-picker'); const { restartDialog } = require('./dialogs'); -const { setTouchbar } = require('./touchbar'); function setupEventHandlers(mb, store) { ipcMain.on('copyColorToClipboard', (channel, color) => { @@ -66,10 +65,6 @@ function setupEventHandlers(mb, store) { await launchPicker(mb); }); - ipcMain.on('setTouchbar', (event, itemsToShow) => { - setTouchbar(mb, itemsToShow); - }); - ipcMain.on('setShowDockIcon', async (channel, showDockIcon) => { store.set('showDockIcon', showDockIcon); await restartDialog(); diff --git a/electron-app/src/touchbar.js b/electron-app/src/touchbar.js deleted file mode 100644 index 7ee5c5fc7..000000000 --- a/electron-app/src/touchbar.js +++ /dev/null @@ -1,54 +0,0 @@ -const { TouchBar } = require('electron'); -const { debounce } = require('throttle-debounce'); -const { TouchBarButton, TouchBarColorPicker, TouchBarGroup } = TouchBar; - -function setTouchbar(mb, itemsToShow) { - if (process.platform === 'darwin') { - if (itemsToShow) { - const items = []; - - if (itemsToShow.colorPicker) { - const colorPicker = new TouchBarColorPicker({ - change: debounce(250, (color) => { - mb.window.webContents.send('updateKulerColor', color); - }), - }); - - items.push(colorPicker); - } - - if (itemsToShow.kulerColors) { - const colors = itemsToShow.kulerColors.colors; - const colorButtons = colors.map((color) => { - return new TouchBarButton({ - backgroundColor: color.hex, - label: color.hex, - click() { - mb.window.webContents.send( - 'selectKulerColor', - itemsToShow.kulerColors.colors.indexOf(color), - ); - }, - }); - }); - const kulerColors = new TouchBarGroup({ - items: new TouchBar({ items: colorButtons }), - }); - - items.push(kulerColors); - } - - const touchBar = new TouchBar({ - items, - }); - - mb.window.setTouchBar(touchBar); - } else { - mb.window.setTouchBar(null); - } - } -} - -module.exports = { - setTouchbar, -};