Skip to content

Commit 04337ce

Browse files
authored
fix: no bidirectional audio on first call (#68)
1 parent a71b81f commit 04337ce

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands",
5050
"@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light",
5151
"@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid",
52-
"@nethesis/phone-island": "^0.14.6",
52+
"@nethesis/phone-island": "^0.14.7",
5353
"@tailwindcss/forms": "^0.5.7",
5454
"@types/lodash": "^4.14.202",
5555
"@types/node": "^18.19.9",

src/main/lib/ipcEvents.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,19 @@ export function registerIpcEvents() {
269269
}
270270
})
271271

272+
ipcMain.on(IPC_EVENTS.PHONE_ISLAND_READY, () => {
273+
Log.info('PhoneIsland is ready to receive events')
274+
const account = store.get('account') as Account
275+
276+
setTimeout(() => {
277+
Log.info('Send CHANGE_PREFERRED_DEVICES event with', account.preferredDevices)
278+
AccountController.instance.updatePreferredDevice(account.preferredDevices)
279+
PhoneIslandController.instance.window.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, account.preferredDevices)
280+
}, 250)
281+
})
282+
272283
ipcMain.on(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, (_, devices) => {
273-
Log.info('CHANGE_PREFERRED_DEVICES:', devices)
284+
Log.info('Received CHANGE_PREFERRED_DEVICES in ipcEvents:', devices)
274285
AccountController.instance.updatePreferredDevice(devices)
275286
PhoneIslandController.instance.window.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, devices)
276287
})

src/main/main.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,6 @@ async function createNethLink(show: boolean = true) {
682682
checkForUpdate()
683683
const account = store.get('account') as Account
684684
if (account) {
685-
// read preffered devices for phone-island
686-
Log.info("Preferred devices readed:", account.preferredDevices)
687-
if (account.preferredDevices) {
688-
ipcMain.emit(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, undefined, account.preferredDevices)
689-
}
690-
691685
// read shortcut from config and set it to app
692686
Log.info("Shortcut readed:", account.shortcut)
693687
if (account.shortcut && account.shortcut?.length > 0) {

src/renderer/src/hooks/usePhoneIslandEventListeners.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ export const usePhoneIslandEventListener = () => {
234234
...eventHandler(PHONE_ISLAND_EVENTS["phone-island-user-already-login"], () => {
235235
window.api.logout()
236236
}),
237-
...eventHandler(PHONE_ISLAND_EVENTS["phone-island-webrtc-registered"]),
237+
...eventHandler(PHONE_ISLAND_EVENTS["phone-island-webrtc-registered"], () => {
238+
setTimeout(() => {
239+
Log.info("phone-island-webrtc-registered", "send PHONE_ISLAND_READY event")
240+
window.electron.send(IPC_EVENTS.PHONE_ISLAND_READY)
241+
}, 500);
242+
}),
238243
...eventHandler(PHONE_ISLAND_EVENTS["phone-island-all-alerts-removed"]),
239244
...eventHandler(PHONE_ISLAND_EVENTS["phone-island-fullscreen-entered"], () => {
240245
window.electron.send(IPC_EVENTS.FULLSCREEN_ENTER)

src/renderer/src/pages/PhoneIslandPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function PhoneIslandPage() {
7272
})
7373

7474
window.electron.receive(IPC_EVENTS.CHANGE_PREFERRED_DEVICES, (devices: PreferredDevices) => {
75+
Log.info('Received CHANGE_PREFERRED_DEVICES in PhoneIslandPage:', devices)
7576
eventDispatch(PHONE_ISLAND_EVENTS['phone-island-audio-input-change'], { deviceId: devices.audioInput })
7677
eventDispatch(PHONE_ISLAND_EVENTS['phone-island-video-input-change'], { deviceId: devices.videoInput })
7778
eventDispatch(PHONE_ISLAND_EVENTS['phone-island-audio-output-change'], { deviceId: devices.audioOutput })

src/shared/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export enum IPC_EVENTS {
9292
SCREEN_SHARE_SOURCES = "SCREEN_SHARE_SOURCES",
9393
CHANGE_SHORTCUT = 'CHANGE_SHORTCUT',
9494
COPY_TO_CLIPBOARD = "COPY_TO_CLIPBOARD",
95-
CHANGE_PREFERRED_DEVICES = "CHANGE_PREFERRED_DEVICES"
95+
CHANGE_PREFERRED_DEVICES = "CHANGE_PREFERRED_DEVICES",
96+
PHONE_ISLAND_READY = "PHONE_ISLAND_READY"
9697
}
9798

9899
//PHONE ISLAND EVENTS

0 commit comments

Comments
 (0)