fixed hotkey race condition

This commit is contained in:
Eugene Pankov 2021-08-08 17:54:53 +02:00
parent 79de7ec015
commit 434bacf185
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -72,20 +72,21 @@ export class HotkeysService {
@Inject(HotkeyProvider) private hotkeyProviders: HotkeyProvider[],
hostApp: HostAppService,
) {
const events = ['keydown', 'keyup']
events.forEach(eventType => {
document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => {
this._keyEvent.next(nativeEvent)
this.pushKeyEvent(eventType, nativeEvent)
if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) {
nativeEvent.preventDefault()
nativeEvent.stopPropagation()
}
})
})
this.config.ready$.toPromise().then(async () => {
const hotkeys = await this.getHotkeyDescriptions()
this.hotkeyDescriptions = hotkeys
const events = ['keydown', 'keyup']
events.forEach(eventType => {
document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => {
this._keyEvent.next(nativeEvent)
this.pushKeyEvent(eventType, nativeEvent)
if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) {
nativeEvent.preventDefault()
nativeEvent.stopPropagation()
}
})
})
})
// deprecated