mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Add calling and notification sounds (#119)
* Add calling and notification sounds * Fix notification visibility on any resolution * Add comments * Log howler error src * Revert removed files im stupid * Make sliders on settings use changeCommitted instead of onChange * Fix ringtone paths * Break alert words overflow * Fix tweet overflow pepega * Remove unused hook * Update volume sliders in real time * Fix resolution notifications * Fix initial value for vol sliders * Fix call duration timer bugs * Add alert when phone active and phone closes * keep notification * Stop ringing when accept
This commit is contained in:
1 parent
8ecb91e71f
commit
4eda44b9c2
28 files changed
+589
-142
No files matched your search
@@ -1,18 +1,14 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { callerState } from './state';
|
||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { CallNotification } from '../components/CallNotification';
|
||||
import { useCall } from './useCall';
|
||||
import { CallProps } from '../../../common/typings/call';
|
||||
import { useApp } from '../../apps/hooks/useApps';
|
||||
import InjectDebugData from '../../debug/InjectDebugData';
|
||||
import { useCallModal } from './useCallModal';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
const NOTIFICATION_ID = 'call:current';
|
||||
import { callerState } from './state';
|
||||
import { useCallNotifications } from './useCallNotifications';
|
||||
import { useDuration } from './useDuration';
|
||||
|
||||
InjectDebugData<CallProps | boolean>([
|
||||
/* {
|
||||
@@ -22,7 +18,7 @@ InjectDebugData<CallProps | boolean>([
|
||||
accepted: false,
|
||||
isTransmitter: false,
|
||||
transmitter: 'Chip',
|
||||
receiver: 'Taso',
|
||||
receiver: 'Taso',
|
||||
active: true,
|
||||
},
|
||||
},
|
||||
@@ -34,33 +30,19 @@ InjectDebugData<CallProps | boolean>([
|
||||
]);
|
||||
|
||||
export const useCallService = () => {
|
||||
const { t } = useTranslation();
|
||||
const { modal } = useCallModal();
|
||||
const history = useHistory();
|
||||
const { pathname } = useLocation();
|
||||
const {
|
||||
addNotificationAlert,
|
||||
removeId,
|
||||
addNotification,
|
||||
} = useNotifications();
|
||||
|
||||
const { call, setCall } = useCall();
|
||||
const { resetDuration } = useDuration();
|
||||
|
||||
const { icon, notificationIcon } = useApp('DIALER');
|
||||
const { setNotification } = useCallNotifications();
|
||||
|
||||
const setModal = useSetRecoilState(callerState.callModal);
|
||||
|
||||
const [modalHasBeenOpenedThisCall, setModalOpened] = useState<boolean>(false);
|
||||
|
||||
const callNotificationBase = {
|
||||
app: 'CALL',
|
||||
id: NOTIFICATION_ID,
|
||||
cantClose: true,
|
||||
icon,
|
||||
onClick: () => history.push('/call'),
|
||||
notificationIcon,
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setModalOpened(!!modal);
|
||||
}, [modal]);
|
||||
@@ -75,47 +57,10 @@ export const useCallService = () => {
|
||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||
|
||||
const _setCall = (_call: CallProps) => {
|
||||
resetDuration();
|
||||
setCall(_call);
|
||||
if (!_call || !_call.active) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
return;
|
||||
}
|
||||
if (_call.accepted) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
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) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
addNotificationAlert(
|
||||
{
|
||||
...callNotificationBase,
|
||||
title: t('APPS_DIALER_INCOMING_CALL_TITLE', {
|
||||
transmitter: _call.transmitter,
|
||||
}),
|
||||
keepWhenPhoneClosed: true,
|
||||
content: (
|
||||
<CallNotification>
|
||||
{t('APPS_DIALER_TRANSMITTER_IS_CALLING', {
|
||||
transmitter: _call.transmitter,
|
||||
})}
|
||||
</CallNotification>
|
||||
),
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
setNotification(_call);
|
||||
};
|
||||
|
||||
useNuiEvent<CallProps>('CALL', 'setCaller', _setCall, call);
|
||||
useNuiEvent<boolean>('CALL', 'callModal', setModal);
|
||||
};
|
||||
Reference in new issue
Block a user