mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Remove comma from hell and improve useRingtoneSound (#127)
This commit is contained in:
1 parent
4eda44b9c2
commit
e9e22ce9bc
4 files changed
+26
-53
No files matched your search
@@ -155,7 +155,6 @@ export const SettingsApp = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
,
|
|
||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
|
|||||||
@@ -6,16 +6,19 @@ import { useApp } from '../../apps/hooks/useApps';
|
|||||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||||
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
||||||
import { CallNotification } from '../components/CallNotification';
|
import { CallNotification } from '../components/CallNotification';
|
||||||
import { useCall } from './useCall';
|
|
||||||
|
|
||||||
const NOTIFICATION_ID = 'call:current';
|
const NOTIFICATION_ID = 'call:current';
|
||||||
|
|
||||||
export const useCallNotifications = () => {
|
export const useCallNotifications = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const history = useHistory();
|
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');
|
const { icon, notificationIcon } = useApp('DIALER');
|
||||||
|
|
||||||
@@ -28,37 +31,28 @@ export const useCallNotifications = () => {
|
|||||||
notificationIcon,
|
notificationIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { call } = useCall();
|
|
||||||
|
|
||||||
const setNotification = (call: CallProps) => {
|
const setNotification = (call: CallProps) => {
|
||||||
|
stop();
|
||||||
if (!call || !call.active) {
|
if (!call || !call.active) {
|
||||||
stop();
|
|
||||||
removeId(NOTIFICATION_ID);
|
removeId(NOTIFICATION_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (call.accepted) {
|
if (call.accepted) {
|
||||||
stop();
|
|
||||||
removeId(NOTIFICATION_ID);
|
removeId(NOTIFICATION_ID);
|
||||||
addNotificationAlert(
|
addNotification({
|
||||||
{
|
...callNotificationBase,
|
||||||
...callNotificationBase,
|
content: (
|
||||||
keepWhenPhoneClosed: true,
|
<CallNotification>
|
||||||
content: (
|
{t('APPS_DIALER_CURRENT_CALL_WITH', {
|
||||||
<CallNotification>
|
transmitter: call.transmitter,
|
||||||
{t('APPS_DIALER_CURRENT_CALL_WITH', {
|
})}
|
||||||
transmitter: call.transmitter,
|
</CallNotification>
|
||||||
})}
|
),
|
||||||
</CallNotification>
|
title: t('APPS_DIALER_CURRENT_CALL_TITLE'),
|
||||||
),
|
});
|
||||||
title: t('APPS_DIALER_CURRENT_CALL_TITLE'),
|
|
||||||
},
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!call.isTransmitter && !call.accepted) {
|
if (!call.isTransmitter && !call.accepted) {
|
||||||
if (!playing()) {
|
play();
|
||||||
play();
|
|
||||||
}
|
|
||||||
removeId(NOTIFICATION_ID);
|
removeId(NOTIFICATION_ID);
|
||||||
addNotificationAlert(
|
addNotificationAlert(
|
||||||
{
|
{
|
||||||
@@ -80,7 +74,5 @@ export const useCallNotifications = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetCallNotification = () => setNotification(call);
|
return { setNotification };
|
||||||
|
|
||||||
return { setNotification, resetCallNotification };
|
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { IServerConfig } from '../../../common/typings/config';
|
import { IServerConfig } from '../../../common/typings/config';
|
||||||
import ServerConfig from '../../../config.autogen.json';
|
import ServerConfig from '../../../config.autogen.json';
|
||||||
import { useCallNotifications } from '../../call/hooks/useCallNotifications';
|
|
||||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||||
import Nui from '../../nui-events/utils/Nui';
|
import Nui from '../../nui-events/utils/Nui';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
@@ -17,11 +16,9 @@ export const usePhone = (): IUsePhone => {
|
|||||||
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
||||||
|
|
||||||
const { removeAlerts } = useNotifications();
|
const { removeAlerts } = useNotifications();
|
||||||
const { resetCallNotification } = useCallNotifications();
|
|
||||||
|
|
||||||
const closePhone = () => {
|
const closePhone = () => {
|
||||||
removeAlerts();
|
removeAlerts();
|
||||||
resetCallNotification();
|
|
||||||
Nui.send('phone:close');
|
Nui.send('phone:close');
|
||||||
};
|
};
|
||||||
const openPhone = () => {
|
const openPhone = () => {
|
||||||
|
|||||||
@@ -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 { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||||
import { soundContext } from '../providers/SoundProvider';
|
import { soundContext } from '../providers/SoundProvider';
|
||||||
import { getSoundSettings } from '../utils/getSoundSettings';
|
import { getSoundSettings } from '../utils/getSoundSettings';
|
||||||
@@ -24,24 +24,9 @@ export const useRingtoneSound = () => {
|
|||||||
context.volume(options.sound, options.volume);
|
context.volume(options.sound, options.volume);
|
||||||
}, [context, options.sound, options.volume]);
|
}, [context, options.sound, options.volume]);
|
||||||
|
|
||||||
const play = useCallback(() => {
|
return {
|
||||||
context.play(options.sound, options.volume, true);
|
play: () => context.play(options.sound, options.volume, true),
|
||||||
}, [context, options.sound, options.volume]);
|
stop: () => context.stop(options.sound),
|
||||||
|
playing: () => context.playing(options.sound),
|
||||||
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]
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user