moved deep-equal dependency out

This commit is contained in:
Eugene Pankov
2021-08-19 23:14:12 +02:00
parent 8d5eef6fa7
commit 38691b80f2
10 changed files with 147 additions and 1130 deletions

View File

@@ -1,3 +1,5 @@
import deepEqual from 'deep-equal'
import { Subject, distinctUntilChanged } from 'rxjs'
import { ipcRenderer } from 'electron'
import { Injectable, NgZone } from '@angular/core'
import { AppService, HostAppService, Platform } from 'tabby-core'
@@ -5,6 +7,8 @@ import { AppService, HostAppService, Platform } from 'tabby-core'
/** @hidden */
@Injectable({ providedIn: 'root' })
export class TouchbarService {
private touchbarState$ = new Subject<any>()
private constructor (
private app: AppService,
private hostApp: HostAppService,
@@ -24,6 +28,10 @@ export class TouchbarService {
ipcRenderer.on('touchbar-selection', (_event, index) => this.zone.run(() => {
this.app.selectTab(this.app.tabs[index])
}))
this.touchbarState$.pipe(distinctUntilChanged(deepEqual)).subscribe(state => {
ipcRenderer.send('window-set-touch-bar', ...state)
})
}
update (): void {
@@ -36,7 +44,7 @@ export class TouchbarService {
hasActivity: this.app.activeTab !== tab && tab.hasActivity,
}))
ipcRenderer.send('window-set-touch-bar', tabSegments, this.app.activeTab ? this.app.tabs.indexOf(this.app.activeTab) : undefined)
this.touchbarState$.next([tabSegments, this.app.activeTab ? this.app.tabs.indexOf(this.app.activeTab) : undefined])
}
private shortenTitle (title: string): string {