From 3572da9972d4388eb046a56d1b6008e13b746272 Mon Sep 17 00:00:00 2001 From: Edoardo Spadoni Date: Wed, 2 Jul 2025 15:40:43 +0200 Subject: [PATCH 1/2] fix: no bidirectional audio on first call --- src/main/lib/ipcEvents.ts | 12 +++++++++++- src/main/main.ts | 6 ------ .../src/hooks/usePhoneIslandEventListeners.ts | 7 ++++++- src/renderer/src/pages/PhoneIslandPage.tsx | 1 + src/shared/constants.ts | 3 ++- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/lib/ipcEvents.ts b/src/main/lib/ipcEvents.ts index eaedf640..d4878772 100644 --- a/src/main/lib/ipcEvents.ts +++ b/src/main/lib/ipcEvents.ts @@ -269,8 +269,18 @@ 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) + 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..756c6fcd 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) + }, 250); + }), ...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 From c48256c3d1df4114424d901664cdf22c9767a163 Mon Sep 17 00:00:00 2001 From: Edoardo Spadoni Date: Wed, 2 Jul 2025 17:59:43 +0200 Subject: [PATCH 2/2] fix: added missing account preferences --- package-lock.json | 8 ++++---- package.json | 2 +- src/main/lib/ipcEvents.ts | 1 + src/renderer/src/hooks/usePhoneIslandEventListeners.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) 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 d4878772..213f6292 100644 --- a/src/main/lib/ipcEvents.ts +++ b/src/main/lib/ipcEvents.ts @@ -275,6 +275,7 @@ export function registerIpcEvents() { 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) }) diff --git a/src/renderer/src/hooks/usePhoneIslandEventListeners.ts b/src/renderer/src/hooks/usePhoneIslandEventListeners.ts index 756c6fcd..524b41c8 100644 --- a/src/renderer/src/hooks/usePhoneIslandEventListeners.ts +++ b/src/renderer/src/hooks/usePhoneIslandEventListeners.ts @@ -238,7 +238,7 @@ export const usePhoneIslandEventListener = () => { setTimeout(() => { Log.info("phone-island-webrtc-registered", "send PHONE_ISLAND_READY event") window.electron.send(IPC_EVENTS.PHONE_ISLAND_READY) - }, 250); + }, 500); }), ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-all-alerts-removed"]), ...eventHandler(PHONE_ISLAND_EVENTS["phone-island-fullscreen-entered"], () => {