diff --git a/package-lock.json b/package-lock.json index c357eac5..b5b20765 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.14.6", + "@nethesis/phone-island": "^0.14.7", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", @@ -5639,9 +5639,9 @@ } }, "node_modules/@nethesis/phone-island": { - "version": "0.14.6", - "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.14.6.tgz", - "integrity": "sha512-G+wdtFKJ6hIYMjmVkcYMNPRvjVrAsqFcTtykGujBPXURtkteHzaDUMOLJzWrjiQsLocztrHYmBBloWYLPykXTg==", + "version": "0.14.7", + "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.14.7.tgz", + "integrity": "sha512-jhZPaAvwP3d16gwudDDX5OGY5/82uvMmnOcdDW1zCgkkI8lg4mq7ytg6Kzn0Xbf/zw0OHACRw8b8RiXFhgMpww==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 285afff3..70c87127 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.14.6", + "@nethesis/phone-island": "^0.14.7", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", diff --git a/src/main/lib/ipcEvents.ts b/src/main/lib/ipcEvents.ts index eaedf640..213f6292 100644 --- a/src/main/lib/ipcEvents.ts +++ b/src/main/lib/ipcEvents.ts @@ -269,8 +269,19 @@ export function registerIpcEvents() { } }) + ipcMain.on(IPC_EVENTS.PHONE_ISLAND_READY, () => { + Log.info('PhoneIsland is ready to receive events') + const account = store.get('account') as Account + + setTimeout(() => { + Log.info('Send CHANGE_PREFERRED_DEVICES event with', account.preferredDevices) + AccountController.instance.updatePreferredDevice(account.preferredDevices) + PhoneIslandController.instance.window.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, account.preferredDevices) + }, 250) + }) + ipcMain.on(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, (_, devices) => { - Log.info('CHANGE_PREFERRED_DEVICES:', devices) + Log.info('Received CHANGE_PREFERRED_DEVICES in ipcEvents:', devices) AccountController.instance.updatePreferredDevice(devices) PhoneIslandController.instance.window.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, devices) }) diff --git a/src/main/main.ts b/src/main/main.ts index db65a0aa..93ba78e5 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -682,12 +682,6 @@ async function createNethLink(show: boolean = true) { checkForUpdate() const account = store.get('account') as Account if (account) { - // read preffered devices for phone-island - Log.info("Preferred devices readed:", account.preferredDevices) - if (account.preferredDevices) { - ipcMain.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, undefined, account.preferredDevices) - } - // read shortcut from config and set it to app Log.info("Shortcut readed:", account.shortcut) if (account.shortcut && account.shortcut?.length > 0) { diff --git a/src/renderer/src/hooks/usePhoneIslandEventListeners.ts b/src/renderer/src/hooks/usePhoneIslandEventListeners.ts index 04746f76..524b41c8 100644 --- a/src/renderer/src/hooks/usePhoneIslandEventListeners.ts +++ b/src/renderer/src/hooks/usePhoneIslandEventListeners.ts @@ -234,7 +234,12 @@ export const usePhoneIslandEventListener = () => { ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-user-already-login"], () => { window.api.logout() }), - ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-webrtc-registered"]), + ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-webrtc-registered"], () => { + setTimeout(() => { + Log.info("phone-island-webrtc-registered", "send PHONE_ISLAND_READY event") + window.electron.send(IPC_EVENTS.PHONE_ISLAND_READY) + }, 500); + }), ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-all-alerts-removed"]), ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-fullscreen-entered"], () => { window.electron.send(IPC_EVENTS.FULLSCREEN_ENTER) diff --git a/src/renderer/src/pages/PhoneIslandPage.tsx b/src/renderer/src/pages/PhoneIslandPage.tsx index cb3c0a6b..fbf3f693 100644 --- a/src/renderer/src/pages/PhoneIslandPage.tsx +++ b/src/renderer/src/pages/PhoneIslandPage.tsx @@ -72,6 +72,7 @@ export function PhoneIslandPage() { }) window.electron.receive(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, (devices: PreferredDevices) => { + Log.info('Received CHANGE_PREFERRED_DEVICES in PhoneIslandPage:', devices) eventDispatch(PHONE_ISLAND_EVENTS['phone-island-audio-input-change'], { deviceId: devices.audioInput }) eventDispatch(PHONE_ISLAND_EVENTS['phone-island-video-input-change'], { deviceId: devices.videoInput }) eventDispatch(PHONE_ISLAND_EVENTS['phone-island-audio-output-change'], { deviceId: devices.audioOutput }) diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 782085d5..a4eb0d33 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -92,7 +92,8 @@ export enum IPC_EVENTS { SCREEN_SHARE_SOURCES = "SCREEN_SHARE_SOURCES", CHANGE_SHORTCUT = 'CHANGE_SHORTCUT', COPY_TO_CLIPBOARD = "COPY_TO_CLIPBOARD", - CHANGE_PREFERRED_DEVICES = "CHANGE_PREFERRED_DEVICES" + CHANGE_PREFERRED_DEVICES = "CHANGE_PREFERRED_DEVICES", + PHONE_ISLAND_READY = "PHONE_ISLAND_READY" } //PHONE ISLAND EVENTS