mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +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>
|
||||
,
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
<SettingItem
|
||||
|
||||
@@ -6,16 +6,19 @@ import { useApp } from '../../apps/hooks/useApps';
|
||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
||||
import { CallNotification } from '../components/CallNotification';
|
||||
import { useCall } from './useCall';
|
||||
|
||||
const NOTIFICATION_ID = 'call:current';
|
||||
|
||||
export const useCallNotifications = () => {
|
||||
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: (
|
||||
<CallNotification>
|
||||
{t('APPS_DIALER_CURRENT_CALL_WITH', {
|
||||
transmitter: call.transmitter,
|
||||
})}
|
||||
</CallNotification>
|
||||
),
|
||||
title: t('APPS_DIALER_CURRENT_CALL_TITLE'),
|
||||
},
|
||||
true
|
||||
);
|
||||
addNotification({
|
||||
...callNotificationBase,
|
||||
content: (
|
||||
<CallNotification>
|
||||
{t('APPS_DIALER_CURRENT_CALL_WITH', {
|
||||
transmitter: call.transmitter,
|
||||
})}
|
||||
</CallNotification>
|
||||
),
|
||||
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 };
|
||||
};
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user