diff --git a/packages/uhk-agent/src/services/device.service.ts b/packages/uhk-agent/src/services/device.service.ts index c3e1390e..b1fa314b 100644 --- a/packages/uhk-agent/src/services/device.service.ts +++ b/packages/uhk-agent/src/services/device.service.ts @@ -662,35 +662,16 @@ export class DeviceService { } public async deleteHostConnection(event: Electron.IpcMainEvent, args: Array): Promise { - const {isConnectedDongleAddress, index, address} = args[0]; - this.logService.misc('[DeviceService] delete host connection', { isConnectedDongleAddress, index, address }); + const {index, address} = args[0]; + this.logService.misc('[DeviceService] delete host connection', { index, address }); try { await this.stopPollUhkDevice(); - let dongleUhkDevice: UhkHidDevice; - try { - if (isConnectedDongleAddress) { - const dongleHid = await getCurrentUhkDongleHID(); - if (dongleHid) { - dongleUhkDevice = new UhkHidDevice(this.logService, this.options, this.rootDir, dongleHid); - await dongleUhkDevice.deleteAllBonds(); - } - } - - await this.device.deleteBond(convertBleStringToNumberArray(address)); - this.logService.misc('[DeviceService] delete host connection success', { address }); - await snooze(1000); - event.sender.send(IpcEvents.device.deleteHostConnectionSuccess, {index, address}); - } - finally { - if (dongleUhkDevice) { - dongleUhkDevice.close(); - } - } + await this.device.deleteBond(convertBleStringToNumberArray(address)); + this.logService.misc('[DeviceService] delete host connection success', { address }); + await snooze(1000); + event.sender.send(IpcEvents.device.deleteHostConnectionSuccess, {index, address}); } catch (error) { - if (isConnectedDongleAddress) { - await this.forceReenumerateDongle(); - } await this.forceReenumerateDevice(); this.logService.misc('[DeviceService] delete host connection failed', { address, error }); event.sender.send(IpcEvents.device.deleteHostConnectionFailed, error.message); diff --git a/packages/uhk-web/src/app/services/device-renderer.service.ts b/packages/uhk-web/src/app/services/device-renderer.service.ts index d833a2f2..cd29f8a5 100644 --- a/packages/uhk-web/src/app/services/device-renderer.service.ts +++ b/packages/uhk-web/src/app/services/device-renderer.service.ts @@ -67,9 +67,8 @@ export class DeviceRendererService { this.ipcRenderer.send(IpcEvents.device.changeKeyboardLayout, layout, hardwareConfiguration.toJsonObject()); } - deleteHostConnection(data: DeleteHostConnectionPayload, isConnectedDongleAddress: boolean): void { + deleteHostConnection(data: DeleteHostConnectionPayload): void { this.ipcRenderer.send(IpcEvents.device.deleteHostConnection, { - isConnectedDongleAddress, index: data.index, address: data.hostConnection.address, }); diff --git a/packages/uhk-web/src/app/store/effects/dongle-pairing.effect.ts b/packages/uhk-web/src/app/store/effects/dongle-pairing.effect.ts index 6f764c25..30b6e6c8 100644 --- a/packages/uhk-web/src/app/store/effects/dongle-pairing.effect.ts +++ b/packages/uhk-web/src/app/store/effects/dongle-pairing.effect.ts @@ -1,8 +1,6 @@ import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType} from '@ngrx/effects'; -import { Store } from '@ngrx/store'; -import { map, tap, withLatestFrom } from 'rxjs/operators'; -import { HostConnections } from 'uhk-common'; +import { map, tap } from 'rxjs/operators'; import { NotificationType, runInElectron } from 'uhk-common'; import { DeviceRendererService } from '../../services/device-renderer.service'; @@ -16,7 +14,6 @@ import { DonglePairingFailedAction, DonglePairingSuccessAction, } from '../actions/dongle-pairing.action'; -import { AppState, getDongle } from '../index'; @Injectable() export class DonglePairingEffect { @@ -24,11 +21,9 @@ export class DonglePairingEffect { deleteHostConnection$ = createEffect(() => this.actions$ .pipe( ofType(ActionTypes.DeleteHostConnection), - withLatestFrom(this.store.select(getDongle)), - map(([action, dongle ]) => { + map((action ) => { if (runInElectron()) { - const isConnectedDongleAddress = action.payload.hostConnection.type === HostConnections.Dongle && dongle?.bleAddress === action.payload.hostConnection.address; - this.deviceRendererService.deleteHostConnection(action.payload, isConnectedDongleAddress); + this.deviceRendererService.deleteHostConnection(action.payload); return new EmptyAction(); } else { return new DeleteHostConnectionSuccessAction({ @@ -87,6 +82,5 @@ export class DonglePairingEffect { constructor(private actions$: Actions, private deviceRendererService: DeviceRendererService, - private store: Store, ){} }