Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/public/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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')
Expand All @@ -103,6 +134,7 @@ export function SettingsIncomingCallsDialog() {
const [formData, setFormData] = useState({
ringtone: '',
outputDevice: '',
showNotification: true,
})

// Convert availableRingtones from store to local format
Expand All @@ -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
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -390,6 +444,32 @@ export function SettingsIncomingCallsDialog() {
</div>
</div>

{/* Show notification checkbox */}
<div className='flex flex-col gap-1 mt-3'>
<label className='flex items-center gap-2 cursor-pointer'>
<input
type='checkbox'
checked={formData.showNotification}
onChange={(e) =>
setFormData((prev) => ({
...prev,
showNotification: e.target.checked,
}))
}
className='h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500'
/>
<span className='text-sm font-medium'>
{t('Settings.ShowNotificationOnIncomingCall')}
</span>
</label>
<p className='text-xs text-gray-500 dark:text-gray-400 ml-6'>
{t('Settings.ShowNotificationOnIncomingCallDescription')}
</p>
</div>

{/* div>
</div>

{/* Action buttons */}
<div className='flex flex-col gap-3 mt-2'>
<Button
Expand Down
26 changes: 24 additions & 2 deletions src/renderer/src/pages/PhoneIslandPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,28 @@ export function PhoneIslandPage() {
const t = Number((top ?? '0px').replace('px', ''))
const l = Number((left ?? '0px').replace('px', ''))
const b = Number((bottom ?? '0px').replace('px', ''))

// Check if user wants to show Phone Island on incoming call
let shouldShowPhoneIsland = true
try {
const savedShowNotificationRaw = localStorage.getItem('phone-island-show-notification')
if (savedShowNotificationRaw) {
const parsed = JSON.parse(savedShowNotificationRaw)
shouldShowPhoneIsland = parsed.enabled !== false
}
} catch (error) {
Log.warning('Error reading show notification preference:', error)
}

// If user disabled notifications and there's a size change (incoming call), hide the Phone Island
let finalW = w
let finalH = h
if (!shouldShowPhoneIsland && w > 0 && h > 0) {
Log.info('Phone Island notification disabled by user - keeping window hidden')
finalW = 0
finalH = 0
}

const data = {
width,
height,
Expand All @@ -293,8 +315,8 @@ export function PhoneIslandPage() {
`)

window.api.resizePhoneIsland({
w: w + r + l,
h: h + t + b + transcription ,
w: finalW + r + l,
h: finalH + t + b + transcription ,
})
}
}
Expand Down