| 10 | private touchbarState$ = new Subject<any>() |
| 11 | |
| 12 | private constructor ( |
| 13 | private app: AppService, |
| 14 | private hostApp: HostAppService, |
| 15 | private zone: NgZone, |
| 16 | ) { |
| 17 | if (this.hostApp.platform !== Platform.macOS) { |
| 18 | return |
| 19 | } |
| 20 | app.tabsChanged$.subscribe(() => this.update()) |
| 21 | app.activeTabChange$.subscribe(() => this.update()) |
| 22 | |
| 23 | app.tabOpened$.subscribe(tab => { |
| 24 | tab.titleChange$.subscribe(() => this.update()) |
| 25 | tab.activity$.pipe( |
| 26 | map(x => !x || tab === app.activeTab), |
| 27 | distinctUntilChanged(), |
| 28 | ).subscribe(() => this.update()) |
| 29 | }) |
| 30 | |
| 31 | ipcRenderer.on('touchbar-selection', (_event, index) => this.zone.run(() => { |
| 32 | this.app.selectTab(this.app.tabs[index]) |
| 33 | })) |
| 34 | |
| 35 | this.touchbarState$.pipe(distinctUntilChanged(deepEqual)).subscribe(state => { |
| 36 | ipcRenderer.send('window-set-touch-bar', ...state) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | update (): void { |
| 41 | if (this.hostApp.platform !== Platform.macOS) { |