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

@@ -3,11 +3,12 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
import { Component, NgZone } from '@angular/core'
import {
ConfigService,
Hotkey,
HotkeyDescription,
HotkeysService,
HostAppService,
} from 'tabby-core'
import { Hotkey } from 'tabby-core/src/api/hotkeyProvider'
import deepEqual from 'deep-equal'
_('Search hotkeys')
@@ -66,7 +67,7 @@ export class HotkeySettingsTabComponent {
.flat()
const isDuplicate = allHotkeys
.filter(hotkey => JSON.stringify(hotkey) === JSON.stringify(strokes))
.filter(hotkey => deepEqual(hotkey, strokes))
.length > 1
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 { HotkeyInputModalComponent } from './hotkeyInputModal.component'
import { Hotkey } from 'tabby-core/src/api/hotkeyProvider'
import { Hotkey } from 'tabby-core'
import deepEqual from 'deep-equal'
/** @hidden */
@Component({
@@ -24,7 +25,7 @@ export class MultiHotkeyInputComponent {
editItem (item: Hotkey): void {
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()
})
}
@@ -44,8 +45,4 @@ export class MultiHotkeyInputComponent {
private storeUpdatedHotkeys () {
this.hotkeysChange.emit(this.hotkeys)
}
private isEqual (h: Hotkey, item: Hotkey) {
return JSON.stringify(h.strokes) === JSON.stringify(item.strokes)
}
}