Quellcode durchsuchen

barrel export + deep equals

Benjamin Brandmeier vor 3 Jahren
Ursprung
Commit
9544791c6c

+ 1 - 1
tabby-core/src/api/index.ts

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

+ 3 - 2
tabby-settings/src/components/hotkeySettingsTab.component.ts

@@ -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 }

+ 4 - 7
tabby-settings/src/components/multiHotkeyInput.component.ts

@@ -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)
-    }
 }