diff --git a/phone/src/apps/settings/components/SettingsApp.tsx b/phone/src/apps/settings/components/SettingsApp.tsx index 235984d..380928d 100644 --- a/phone/src/apps/settings/components/SettingsApp.tsx +++ b/phone/src/apps/settings/components/SettingsApp.tsx @@ -155,7 +155,6 @@ export const SettingsApp = () => { } /> - , { const { t } = useTranslation(); const history = useHistory(); - const { addNotificationAlert, removeId } = useNotifications(); + const { + addNotificationAlert, + removeId, + addNotification, + } = useNotifications(); - const { play, stop, playing } = useRingtoneSound(); + const { play, stop } = useRingtoneSound(); const { icon, notificationIcon } = useApp('DIALER'); @@ -28,37 +31,28 @@ export const useCallNotifications = () => { notificationIcon, }; - const { call } = useCall(); - const setNotification = (call: CallProps) => { + stop(); if (!call || !call.active) { - stop(); removeId(NOTIFICATION_ID); return; } if (call.accepted) { - stop(); removeId(NOTIFICATION_ID); - addNotificationAlert( - { - ...callNotificationBase, - keepWhenPhoneClosed: true, - content: ( - - {t('APPS_DIALER_CURRENT_CALL_WITH', { - transmitter: call.transmitter, - })} - - ), - title: t('APPS_DIALER_CURRENT_CALL_TITLE'), - }, - true - ); + addNotification({ + ...callNotificationBase, + content: ( + + {t('APPS_DIALER_CURRENT_CALL_WITH', { + transmitter: call.transmitter, + })} + + ), + title: t('APPS_DIALER_CURRENT_CALL_TITLE'), + }); } if (!call.isTransmitter && !call.accepted) { - if (!playing()) { - play(); - } + play(); removeId(NOTIFICATION_ID); addNotificationAlert( { @@ -80,7 +74,5 @@ export const useCallNotifications = () => { } }; - const resetCallNotification = () => setNotification(call); - - return { setNotification, resetCallNotification }; + return { setNotification }; }; diff --git a/phone/src/os/phone/hooks/usePhone.ts b/phone/src/os/phone/hooks/usePhone.ts index acdde8d..b511a69 100644 --- a/phone/src/os/phone/hooks/usePhone.ts +++ b/phone/src/os/phone/hooks/usePhone.ts @@ -1,7 +1,6 @@ import { useRecoilValue } from 'recoil'; import { IServerConfig } from '../../../common/typings/config'; import ServerConfig from '../../../config.autogen.json'; -import { useCallNotifications } from '../../call/hooks/useCallNotifications'; import { useNotifications } from '../../notifications/hooks/useNotifications'; import Nui from '../../nui-events/utils/Nui'; import { phoneState } from './state'; @@ -17,11 +16,9 @@ export const usePhone = (): IUsePhone => { const isPhoneOpen = useRecoilValue(phoneState.visibility); const { removeAlerts } = useNotifications(); - const { resetCallNotification } = useCallNotifications(); const closePhone = () => { removeAlerts(); - resetCallNotification(); Nui.send('phone:close'); }; const openPhone = () => { diff --git a/phone/src/os/sound/hooks/useRingtoneSound.ts b/phone/src/os/sound/hooks/useRingtoneSound.ts index 3792ccf..a016d97 100644 --- a/phone/src/os/sound/hooks/useRingtoneSound.ts +++ b/phone/src/os/sound/hooks/useRingtoneSound.ts @@ -1,4 +1,4 @@ -import { useCallback, useContext, useEffect, useMemo } from 'react'; +import { useContext, useEffect, useMemo } from 'react'; import { useSettings } from '../../../apps/settings/hooks/useSettings'; import { soundContext } from '../providers/SoundProvider'; import { getSoundSettings } from '../utils/getSoundSettings'; @@ -24,24 +24,9 @@ export const useRingtoneSound = () => { context.volume(options.sound, options.volume); }, [context, options.sound, options.volume]); - const play = useCallback(() => { - context.play(options.sound, options.volume, true); - }, [context, options.sound, options.volume]); - - const stop = useCallback(() => { - context.stop(options.sound); - }, [context, options.sound]); - - const playing = useCallback(() => { - return context.playing(options.sound); - }, [context, options.sound]); - - return useMemo( - () => ({ - play, - stop, - playing, - }), - [play, playing, stop] - ); + return { + play: () => context.play(options.sound, options.volume, true), + stop: () => context.stop(options.sound), + playing: () => context.playing(options.sound), + }; };