barrel export + deep equals

This commit is contained in:
Benjamin Brandmeier 2022-12-18 21:31:50 +01:00 committed by Eugene
parent 72bc58332d
commit 9544791c6c
3 changed files with 8 additions and 10 deletions

View File

@ -5,7 +5,7 @@ export { SplitTabComponent, SplitContainer, SplitDirection, SplitOrientation } f
export { TabRecoveryProvider, RecoveryToken } from './tabRecovery' export { TabRecoveryProvider, RecoveryToken } from './tabRecovery'
export { ToolbarButtonProvider, ToolbarButton } from './toolbarButtonProvider' export { ToolbarButtonProvider, ToolbarButton } from './toolbarButtonProvider'
export { ConfigProvider } from './configProvider' export { ConfigProvider } from './configProvider'
export { HotkeyProvider, HotkeyDescription } from './hotkeyProvider' export { HotkeyProvider, HotkeyDescription, Hotkey } from './hotkeyProvider'
export { Theme } from './theme' export { Theme } from './theme'
export { TabContextMenuItemProvider } from './tabContextMenuProvider' export { TabContextMenuItemProvider } from './tabContextMenuProvider'
export { SelectorOption } from './selector' export { SelectorOption } from './selector'

View File

@ -3,11 +3,12 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
import { Component, NgZone } from '@angular/core' import { Component, NgZone } from '@angular/core'
import { import {
ConfigService, ConfigService,
Hotkey,
HotkeyDescription, HotkeyDescription,
HotkeysService, HotkeysService,
HostAppService, HostAppService,
} from 'tabby-core' } from 'tabby-core'
import { Hotkey } from 'tabby-core/src/api/hotkeyProvider' import deepEqual from 'deep-equal'
_('Search hotkeys') _('Search hotkeys')
@ -66,7 +67,7 @@ export class HotkeySettingsTabComponent {
.flat() .flat()
const isDuplicate = allHotkeys const isDuplicate = allHotkeys
.filter(hotkey => JSON.stringify(hotkey) === JSON.stringify(strokes)) .filter(hotkey => deepEqual(hotkey, strokes))
.length > 1 .length > 1
return { strokes, isDuplicate } return { strokes, isDuplicate }

View File

@ -1,7 +1,8 @@
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core' import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { HotkeyInputModalComponent } from './hotkeyInputModal.component' import { HotkeyInputModalComponent } from './hotkeyInputModal.component'
import { Hotkey } from 'tabby-core/src/api/hotkeyProvider' import { Hotkey } from 'tabby-core'
import deepEqual from 'deep-equal'
/** @hidden */ /** @hidden */
@Component({ @Component({
@ -24,7 +25,7 @@ export class MultiHotkeyInputComponent {
editItem (item: Hotkey): void { editItem (item: Hotkey): void {
this.ngbModal.open(HotkeyInputModalComponent).result.then((newStrokes: string[]) => { this.ngbModal.open(HotkeyInputModalComponent).result.then((newStrokes: string[]) => {
this.hotkeys.find(hotkey => this.isEqual(hotkey, item))!.strokes = newStrokes this.hotkeys.find(hotkey => deepEqual(hotkey.strokes, item.strokes))!.strokes = newStrokes
this.storeUpdatedHotkeys() this.storeUpdatedHotkeys()
}) })
} }
@ -44,8 +45,4 @@ export class MultiHotkeyInputComponent {
private storeUpdatedHotkeys () { private storeUpdatedHotkeys () {
this.hotkeysChange.emit(this.hotkeys) this.hotkeysChange.emit(this.hotkeys)
} }
private isEqual (h: Hotkey, item: Hotkey) {
return JSON.stringify(h.strokes) === JSON.stringify(item.strokes)
}
} }