Fix too many useless angular detection changes
This commit is contained in:
parent
2177995056
commit
b6dd016601
|
@ -1,6 +1,6 @@
|
|||
// Thanks to https://github.com/brtnshrdr/angular2-hotkeys
|
||||
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Injectable, NgZone } from '@angular/core'
|
||||
import { Hotkey } from './hotkey.model'
|
||||
import { Subject } from 'rxjs'
|
||||
import { tinykeys } from 'tinykeys'
|
||||
|
@ -19,7 +19,7 @@ export class HotkeysService {
|
|||
|
||||
private removeTinyKeysStore = new Map<Hotkey, (() => void)[]>()
|
||||
|
||||
constructor () {
|
||||
constructor (private zone: NgZone) {
|
||||
this.initCheatSheet()
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ export class HotkeysService {
|
|||
for (const combo of hotkey.combo) {
|
||||
debugLogger('Adding hotkey ' + hotkey.formatted)
|
||||
|
||||
this.zone.runOutsideAngular(() => {
|
||||
const removeTinyKey = tinykeys(window, {
|
||||
[combo]: event => {
|
||||
if (this.disabled) return
|
||||
|
@ -79,6 +80,7 @@ export class HotkeysService {
|
|||
}
|
||||
|
||||
this.removeTinyKeysStore.get(hotkey).push(removeTinyKey)
|
||||
})
|
||||
}
|
||||
|
||||
return hotkey
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { uniq } from 'lodash-es'
|
||||
import { Observable } from 'rxjs'
|
||||
import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'
|
||||
import { Observable, timer } from 'rxjs'
|
||||
import { buffer, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'
|
||||
|
||||
function buildBulkObservable <P extends number | string, R> (options: {
|
||||
notifierObservable: Observable<P>
|
||||
|
@ -11,7 +11,7 @@ function buildBulkObservable <P extends number | string, R> (options: {
|
|||
|
||||
return notifierObservable.pipe(
|
||||
distinctUntilChanged(),
|
||||
bufferTime(time),
|
||||
buffer(timer(time)),
|
||||
filter(params => params.length !== 0),
|
||||
map(params => uniq(params)),
|
||||
switchMap(params => {
|
||||
|
|
|
@ -136,7 +136,7 @@ export class FindInBulkService {
|
|||
notifier,
|
||||
|
||||
result: buildBulkObservable({
|
||||
time: 500,
|
||||
time: 100,
|
||||
bulkGet,
|
||||
notifierObservable: notifier.asObservable()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue