diff --git a/package-lock.json b/package-lock.json index 01eee863..988be51f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,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.18.5", + "@nethesis/phone-island": "^0.18.9", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", @@ -5641,9 +5641,9 @@ } }, "node_modules/@nethesis/phone-island": { - "version": "0.18.5", - "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.18.5.tgz", - "integrity": "sha512-mItlpG48jGiM8/YsmEe/j4aqCvshJ1G2x/V9ga9/cyofw1zjQHLVAZPq5cwspJqEDomVY0/PBoEFzOj7eiBkSw==", + "version": "0.18.9", + "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.18.9.tgz", + "integrity": "sha512-uSZ2AYhr0VFcZy24e4X1bOq/STYxAFajOeV9kPjUgLQjuqji3aRDA0+Lh+5v1J/rw7J6nYT2k5hSxYJ1Oa1B/g==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 7fefad98..31aef694 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.18.5", + "@nethesis/phone-island": "^0.18.9", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 03cacd38..a3478966 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -334,6 +334,8 @@ "Devices": "Audio and Video", "IncomingCalls": "Incoming Calls", "Ringtone": "Ringtone", + "ShowNotificationOnIncomingCall": "Show notification on incoming call", + "ShowNotificationOnIncomingCallDescription": "Display the Phone Island when you receive an incoming call", "Time preferences": "Time preferences", "Login/logout preferences": "Login/logout preferences", "Logout from queue automatically": "Logout from queue automatically", diff --git a/public/locales/it/translations.json b/public/locales/it/translations.json index 6a803402..04f60f7d 100644 --- a/public/locales/it/translations.json +++ b/public/locales/it/translations.json @@ -334,6 +334,8 @@ "Devices": "Audio e Video", "IncomingCalls": "Chiamate in Arrivo", "Ringtone": "Suoneria", + "ShowNotificationOnIncomingCall": "Mostra notifica chiamata in arrivo", + "ShowNotificationOnIncomingCallDescription": "Visualizza la Phone Island quando ricevi una chiamata in entrata", "Time preferences": "Preferenze di tempo", "Login/logout preferences": "Preferenze di entrata/uscita", "Logout from queue automatically": "Esci dalla coda automaticamente", diff --git a/src/renderer/public/locales/en/translations.json b/src/renderer/public/locales/en/translations.json index 82137cb1..1099e7a4 100644 --- a/src/renderer/public/locales/en/translations.json +++ b/src/renderer/public/locales/en/translations.json @@ -334,6 +334,8 @@ "Devices": "Audio and Video", "IncomingCalls": "Incoming Calls", "Ringtone": "Ringtone", + "ShowNotificationOnIncomingCall": "Show notification on incoming call", + "ShowNotificationOnIncomingCallDescription": "Display the Phone Island when you receive an incoming call", "Time preferences": "Time preferences", "Login/logout preferences": "Login/logout preferences", "Logout from queue automatically": "Logout from queue automatically", diff --git a/src/renderer/public/locales/it/translations.json b/src/renderer/public/locales/it/translations.json index e398b953..ac62bfd0 100644 --- a/src/renderer/public/locales/it/translations.json +++ b/src/renderer/public/locales/it/translations.json @@ -334,6 +334,8 @@ "Devices": "Audio e Video", "IncomingCalls": "Chiamate in Arrivo", "Ringtone": "Suoneria", + "ShowNotificationOnIncomingCall": "Mostra notifica chiamata in arrivo", + "ShowNotificationOnIncomingCallDescription": "Visualizza la Phone Island quando ricevi una chiamata in entrata", "Time preferences": "Preferenze di tempo", "Login/logout preferences": "Preferenze di entrata/uscita", "Logout from queue automatically": "Esci dalla coda automaticamente", diff --git a/src/renderer/src/components/Modules/NethVoice/BaseModule/ProfileDialog/SettingsSettings/SettingsIncomingCallsDialog.tsx b/src/renderer/src/components/Modules/NethVoice/BaseModule/ProfileDialog/SettingsSettings/SettingsIncomingCallsDialog.tsx index f40e8206..2e063c0c 100644 --- a/src/renderer/src/components/Modules/NethVoice/BaseModule/ProfileDialog/SettingsSettings/SettingsIncomingCallsDialog.tsx +++ b/src/renderer/src/components/Modules/NethVoice/BaseModule/ProfileDialog/SettingsSettings/SettingsIncomingCallsDialog.tsx @@ -33,6 +33,7 @@ const capitalizeFirstLetter = (str: string): string => { const LOCALSTORAGE_KEYS = { ringtone: 'phone-island-ringing-tone', outputDevice: 'phone-island-ringing-tone-output', + showNotification: 'phone-island-show-notification', } as const const getRingtoneFromLocalStorage = (): string | null => { @@ -95,6 +96,36 @@ const setOutputDeviceToLocalStorage = (value: string): void => { } } +const getShowNotificationFromLocalStorage = (): boolean => { + try { + const rawValue = localStorage.getItem(LOCALSTORAGE_KEYS.showNotification) + if (!rawValue) return true + + try { + const parsed = JSON.parse(rawValue) + return parsed.enabled !== false + } catch (parseError) { + console.warn( + 'localStorage value for show notification is not valid JSON, using default:', + rawValue, + ) + return true + } + } catch (error) { + console.warn('Error reading show notification from localStorage:', error) + return true + } +} + +const setShowNotificationToLocalStorage = (value: boolean): void => { + try { + const jsonValue = JSON.stringify({ enabled: value }) + localStorage.setItem(LOCALSTORAGE_KEYS.showNotification, jsonValue) + } catch (error) { + console.warn('Error saving show notification to localStorage:', error) + } +} + export function SettingsIncomingCallsDialog() { const [, setIsIncomingCallsDialogOpen] = useNethlinkData('isIncomingCallsDialogOpen') const [availableRingtones] = useSharedState('availableRingtones') @@ -103,6 +134,7 @@ export function SettingsIncomingCallsDialog() { const [formData, setFormData] = useState({ ringtone: '', outputDevice: '', + showNotification: true, }) // Convert availableRingtones from store to local format @@ -114,13 +146,20 @@ export function SettingsIncomingCallsDialog() { useEffect(() => { initAudioOutputDevices() + // Request ringtone list from phone-island when dialog opens + Log.info('Requesting ringtone list from phone-island on dialog open') + const ringtoneListEvent = new CustomEvent(PHONE_ISLAND_EVENTS['phone-island-ringing-tone-list'], {}) + window.dispatchEvent(ringtoneListEvent) + // Load saved preferences from localStorage const savedRingtone = getRingtoneFromLocalStorage() const savedOutputDevice = getOutputDeviceFromLocalStorage() + const savedShowNotification = getShowNotificationFromLocalStorage() setFormData({ ringtone: savedRingtone || '', outputDevice: savedOutputDevice || '', + showNotification: savedShowNotification, }) // Listen for audio player closed via IPC @@ -131,6 +170,20 @@ export function SettingsIncomingCallsDialog() { return () => { // Cleanup IPC listener } + }, []) + + // Update form data when ringtones become available + useEffect(() => { + if (availableRingtones && availableRingtones.length > 0 && !formData.ringtone) { + const savedRingtone = getRingtoneFromLocalStorage() + if (savedRingtone) { + setFormData((prev) => ({ + ...prev, + ringtone: savedRingtone, + })) + Log.info('Updated ringtone in form after ringtones loaded:', savedRingtone) + } + } }, [availableRingtones]) const initAudioOutputDevices = async () => { @@ -170,6 +223,7 @@ export function SettingsIncomingCallsDialog() { // Save to localStorage setRingtoneToLocalStorage(formData.ringtone) setOutputDeviceToLocalStorage(formData.outputDevice) + setShowNotificationToLocalStorage(formData.showNotification) // Send IPC event to PhoneIslandPage to apply settings window.electron.send(IPC_EVENTS.CHANGE_RINGTONE_SETTINGS, { @@ -390,6 +444,32 @@ export function SettingsIncomingCallsDialog() { + {/* Show notification checkbox */} +
+ {t('Settings.ShowNotificationOnIncomingCallDescription')} +
+