mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
more formatting
This commit is contained in:
1 parent
046447b0fb
commit
f552c1212c
157 files changed
+635
-1579
No files matched your search
@@ -65,115 +65,103 @@ export const APPS: IAppConfig[] = [
|
||||
id: 'DIALER',
|
||||
nameLocale: 'APPS_DIALER',
|
||||
icon: <FontAwesomeIcon icon={faPhoneAlt} />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faPhoneAlt} size='xs' />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faPhoneAlt} size="xs" />,
|
||||
backgroundColor: DIALER_APP_PRIMARY_COLOR,
|
||||
color: DIALER_APP_TEXT_COLOR,
|
||||
path: '/phone',
|
||||
Route: () => <AppRoute id='DIALER' path='/phone' component={DialerApp} />,
|
||||
Route: () => <AppRoute id="DIALER" path="/phone" component={DialerApp} />,
|
||||
},
|
||||
{
|
||||
id: 'MESSAGES',
|
||||
nameLocale: 'APPS_MESSAGES',
|
||||
icon: <MessageIcon fontSize='large' />,
|
||||
notificationIcon: <MessageIcon fontSize='small' />,
|
||||
icon: <MessageIcon fontSize="large" />,
|
||||
notificationIcon: <MessageIcon fontSize="small" />,
|
||||
backgroundColor: MESSAGES_APP_PRIMARY_COLOR,
|
||||
color: MESSAGES_APP_TEXT_COLOR,
|
||||
path: '/messages',
|
||||
Route: () => (
|
||||
<AppRoute id='MESSAGE' path='/messages' component={MessagesApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="MESSAGE" path="/messages" component={MessagesApp} />,
|
||||
},
|
||||
{
|
||||
id: 'CONTACTS',
|
||||
nameLocale: 'APPS_CONTACTS',
|
||||
icon: <ContactsIcon fontSize='large' />,
|
||||
notificationIcon: <ContactsIcon fontSize='small' />,
|
||||
icon: <ContactsIcon fontSize="large" />,
|
||||
notificationIcon: <ContactsIcon fontSize="small" />,
|
||||
backgroundColor: CONTACTS_APP_PRIMARY_COLOR,
|
||||
color: CONTACTS_APP_TEXT_COLOR,
|
||||
path: '/contacts',
|
||||
Route: () => (
|
||||
<AppRoute id='CONTACTS' path='/contacts' component={ContactsApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="CONTACTS" path="/contacts" component={ContactsApp} />,
|
||||
},
|
||||
{
|
||||
id: 'CALCULATOR',
|
||||
nameLocale: 'APPS_CALCULATOR',
|
||||
icon: <CalculatorIcon fontSize='large' />,
|
||||
notificationIcon: <CalculatorIcon fontSize='small' />,
|
||||
icon: <CalculatorIcon fontSize="large" />,
|
||||
notificationIcon: <CalculatorIcon fontSize="small" />,
|
||||
backgroundColor: purple[500],
|
||||
color: grey[50],
|
||||
path: '/calculator',
|
||||
Route: () => (
|
||||
<AppRoute id='CALCULATOR' path='/calculator' component={CalculatorApp} />
|
||||
<AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'SETTINGS',
|
||||
nameLocale: 'APPS_SETTINGS',
|
||||
icon: <SettingsIcon fontSize='large' />,
|
||||
notificationIcon: <SettingsIcon fontSize='small' />,
|
||||
icon: <SettingsIcon fontSize="large" />,
|
||||
notificationIcon: <SettingsIcon fontSize="small" />,
|
||||
backgroundColor: '#383838',
|
||||
color: grey[50],
|
||||
path: '/settings',
|
||||
Route: () => (
|
||||
<AppRoute id='SETTINGS' path='/settings' component={SettingsApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="SETTINGS" path="/settings" component={SettingsApp} />,
|
||||
},
|
||||
{
|
||||
id: 'BANK',
|
||||
nameLocale: 'APPS_BANK',
|
||||
icon: <FontAwesomeIcon icon={faWonSign} />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faWonSign} size='xs' />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faWonSign} size="xs" />,
|
||||
backgroundColor: blue[900],
|
||||
color: common.white,
|
||||
path: '/bank',
|
||||
Route: () => <AppRoute id='BANK' path='/bank' component={BankApp} />,
|
||||
Route: () => <AppRoute id="BANK" path="/bank" component={BankApp} />,
|
||||
},
|
||||
{
|
||||
id: 'TWITTER',
|
||||
nameLocale: 'APPS_TWITTER',
|
||||
icon: <FontAwesomeIcon icon={faTwitter} fixedWidth />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faTwitter} fixedWidth size='xs' />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faTwitter} fixedWidth size="xs" />,
|
||||
backgroundColor: blue[600],
|
||||
color: common.white,
|
||||
path: '/twitter',
|
||||
Route: () => (
|
||||
<AppRoute id='TWITTER' path='/twitter' component={TwitterApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="TWITTER" path="/twitter" component={TwitterApp} />,
|
||||
},
|
||||
{
|
||||
id: 'SELLOUT',
|
||||
nameLocale: 'APPS_SELLOUT',
|
||||
icon: <FontAwesomeIcon icon={faAd} fixedWidth />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faAd} fixedWidth size='xs' />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faAd} fixedWidth size="xs" />,
|
||||
backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
|
||||
color: SELLOUT_APP_ICON_COLOR,
|
||||
path: '/sellout',
|
||||
Route: () => (
|
||||
<AppRoute id='SELLOUT' path='/sellout' component={SelloutApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="SELLOUT" path="/sellout" component={SelloutApp} />,
|
||||
},
|
||||
{
|
||||
id: 'NOTES',
|
||||
nameLocale: 'APPS_NOTES',
|
||||
icon: <FontAwesomeIcon icon={faStickyNote} fixedWidth />,
|
||||
notificationIcon: (
|
||||
<FontAwesomeIcon icon={faStickyNote} fixedWidth size='xs' />
|
||||
),
|
||||
notificationIcon: <FontAwesomeIcon icon={faStickyNote} fixedWidth size="xs" />,
|
||||
backgroundColor: NOTES_APP_PRIMARY_COLOR,
|
||||
color: NOTES_APP_ICON_COLOR,
|
||||
path: '/notes',
|
||||
Route: () => <AppRoute id='NOTES' path='/notes' component={NotesApp} />,
|
||||
Route: () => <AppRoute id="NOTES" path="/notes" component={NotesApp} />,
|
||||
},
|
||||
{
|
||||
id: 'CAMERA',
|
||||
nameLocale: 'APPS_CAMERA',
|
||||
icon: <CameraAltIcon fontSize='large' />,
|
||||
notificationIcon: <CameraAltIcon fontSize='small' />,
|
||||
icon: <CameraAltIcon fontSize="large" />,
|
||||
notificationIcon: <CameraAltIcon fontSize="small" />,
|
||||
backgroundColor: grey['A400'],
|
||||
color: common.white,
|
||||
path: '/camera',
|
||||
Route: () => <AppRoute id='CAMERA' path='/camera' component={CameraApp} />,
|
||||
Route: () => <AppRoute id="CAMERA" path="/camera" component={CameraApp} />,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -182,13 +170,11 @@ if (process.env.NODE_ENV === 'development') {
|
||||
APPS.push({
|
||||
id: 'EXAMPLE',
|
||||
nameLocale: 'APPS_EXAMPLE',
|
||||
icon: <FontAwesomeIcon icon={faPlaneArrival} size='sm' />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faPlaneArrival} size='xs' />,
|
||||
icon: <FontAwesomeIcon icon={faPlaneArrival} size="sm" />,
|
||||
notificationIcon: <FontAwesomeIcon icon={faPlaneArrival} size="xs" />,
|
||||
backgroundColor: blue[500],
|
||||
color: blue[50],
|
||||
path: '/example',
|
||||
Route: () => (
|
||||
<AppRoute id='EXAMPLE' path='/example' component={ExampleApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="EXAMPLE" path="/example" component={ExampleApp} />,
|
||||
});
|
||||
}
|
||||
@@ -10,11 +10,11 @@ export const useApps = () => {
|
||||
...a,
|
||||
notification: icons.find((i) => i.key === a.id),
|
||||
})),
|
||||
[icons]
|
||||
[icons],
|
||||
);
|
||||
const getApp = useCallback(
|
||||
(id: string): IAppConfig => apps.find((a) => a.id === id) || null,
|
||||
[apps]
|
||||
[apps],
|
||||
);
|
||||
return { apps, getApp };
|
||||
};
|
||||
|
||||
@@ -50,24 +50,20 @@ export const CallControls = ({ size }: { size?: 'small' | 'medium' }) => {
|
||||
|
||||
if (accepted || isTransmitter) {
|
||||
return (
|
||||
<StatusIconButton color='error' size={size} onClick={handleEndCall}>
|
||||
<StatusIconButton color="error" size={size} onClick={handleEndCall}>
|
||||
<CallEndIcon />
|
||||
</StatusIconButton>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Box m={SIZES_SPACING[size] || 1} display='inline'>
|
||||
<StatusIconButton color='error' size={size} onClick={handleRejectCall}>
|
||||
<Box m={SIZES_SPACING[size] || 1} display="inline">
|
||||
<StatusIconButton color="error" size={size} onClick={handleRejectCall}>
|
||||
<CallEndIcon className={classes.icon} />
|
||||
</StatusIconButton>
|
||||
</Box>
|
||||
<Box m={SIZES_SPACING[size] || 1} display='inline'>
|
||||
<StatusIconButton
|
||||
color='success'
|
||||
size={size}
|
||||
onClick={handleAcceptCall}
|
||||
>
|
||||
<Box m={SIZES_SPACING[size] || 1} display="inline">
|
||||
<StatusIconButton color="success" size={size} onClick={handleAcceptCall}>
|
||||
<CallIcon className={classes.icon} />
|
||||
</StatusIconButton>
|
||||
</Box>
|
||||
|
||||
@@ -19,7 +19,7 @@ export const CallModal = () => {
|
||||
<CallTimer isAccepted={call?.accepted} />
|
||||
</Box>
|
||||
<div className={classes.actions}>
|
||||
<CallControls size='medium' />
|
||||
<CallControls size="medium" />
|
||||
</div>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
|
||||
@@ -18,17 +18,13 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export const CallNotification = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
export const CallNotification = ({ children }: { children: React.ReactNode }) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Box>{children}</Box>
|
||||
<Box className={classes.controls}>
|
||||
<CallControls size='small' />
|
||||
<CallControls size="small" />
|
||||
</Box>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -12,11 +12,7 @@ const NOTIFICATION_ID = 'call:current';
|
||||
export const useCallNotifications = () => {
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
const {
|
||||
addNotificationAlert,
|
||||
removeId,
|
||||
addNotification,
|
||||
} = useNotifications();
|
||||
const { addNotificationAlert, removeId, addNotification } = useNotifications();
|
||||
|
||||
const { play, stop } = useRingtoneSound();
|
||||
|
||||
@@ -69,7 +65,7 @@ export const useCallNotifications = () => {
|
||||
</CallNotification>
|
||||
),
|
||||
},
|
||||
true
|
||||
true,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,10 +5,9 @@ import { callerState } from './state';
|
||||
export const useDuration = () => {
|
||||
const [duration, setDuration] = useRecoilState(callerState.callDuration);
|
||||
|
||||
const resetDuration = useCallback(
|
||||
() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }),
|
||||
[setDuration]
|
||||
);
|
||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [
|
||||
setDuration,
|
||||
]);
|
||||
|
||||
return { duration, setDuration, resetDuration };
|
||||
};
|
||||
@@ -38,7 +38,7 @@ const InjectDebugData = <P>(events: DebugEvent<P>[], timer = 1000) => {
|
||||
method: event.method,
|
||||
data: event.data,
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
}, timer);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export const useKeyboardService = () => {
|
||||
handlers.current.set(g, getters[g]);
|
||||
});
|
||||
},
|
||||
[getters]
|
||||
[getters],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
@@ -85,7 +85,7 @@ export const useKeyboardService = () => {
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
return () => window.removeEventListener('keyup', onKeyUp);
|
||||
},
|
||||
[getters]
|
||||
[getters],
|
||||
);
|
||||
|
||||
const backspaceHandler = useCallback(
|
||||
@@ -96,7 +96,7 @@ export const useKeyboardService = () => {
|
||||
}
|
||||
history.goBack();
|
||||
},
|
||||
[history]
|
||||
[history],
|
||||
);
|
||||
|
||||
useEffect(
|
||||
@@ -104,6 +104,6 @@ export const useKeyboardService = () => {
|
||||
handlers.current.set('Escape', () => closePhone());
|
||||
handlers.current.set('Backspace', backspaceHandler);
|
||||
},
|
||||
[setEscape, setBackspace, history, backspaceHandler, closePhone]
|
||||
[setEscape, setBackspace, history, backspaceHandler, closePhone],
|
||||
);
|
||||
};
|
||||
@@ -1,9 +1,5 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
BottomNavigation,
|
||||
BottomNavigationAction,
|
||||
} from '@material-ui/core';
|
||||
import { makeStyles, BottomNavigation, BottomNavigationAction } from '@material-ui/core';
|
||||
import KeyboardArrowLeftIcon from '@material-ui/icons/KeyboardArrowLeft';
|
||||
import AppsIcon from '@material-ui/icons/Apps';
|
||||
import RadioButtonUncheckedIcon from '@material-ui/icons/RadioButtonUnchecked';
|
||||
@@ -33,17 +29,17 @@ export const Navigation = () => {
|
||||
}}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
label='Home'
|
||||
label="Home"
|
||||
value={() => history.push('/')}
|
||||
icon={<AppsIcon />}
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
label='Close'
|
||||
label="Close"
|
||||
value={closePhone}
|
||||
icon={<RadioButtonUncheckedIcon />}
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
label='Back'
|
||||
label="Back"
|
||||
value={() => !isExact && history.goBack()}
|
||||
icon={<KeyboardArrowLeftIcon />}
|
||||
/>
|
||||
|
||||
@@ -51,14 +51,14 @@ export const NotificationAlert = () => {
|
||||
<Alert
|
||||
action={
|
||||
<IconButton
|
||||
color='primary'
|
||||
size='small'
|
||||
color="primary"
|
||||
size="small"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
currentAlert?.onCloseAlert(e);
|
||||
}}
|
||||
>
|
||||
<CloseIcon fontSize='small' />
|
||||
<CloseIcon fontSize="small" />
|
||||
</IconButton>
|
||||
}
|
||||
onClick={(e) => currentAlert?.onClickAlert(e)}
|
||||
@@ -67,13 +67,13 @@ export const NotificationAlert = () => {
|
||||
elevation={6}
|
||||
>
|
||||
<AlertTitle>
|
||||
<Box width='282px' whiteSpace='nowrap'>
|
||||
<Box overflow='hidden' component='div' textOverflow='ellipsis'>
|
||||
<Box width="282px" whiteSpace="nowrap">
|
||||
<Box overflow="hidden" component="div" textOverflow="ellipsis">
|
||||
{currentAlert?.title}
|
||||
</Box>
|
||||
</Box>
|
||||
</AlertTitle>
|
||||
<Box component='div' className={classes.alertContent}>
|
||||
<Box component="div" className={classes.alertContent}>
|
||||
{currentAlert?.content}
|
||||
</Box>
|
||||
</Alert>
|
||||
|
||||
@@ -79,13 +79,13 @@ export const NotificationBar = () => {
|
||||
<Grid
|
||||
className={classes.root}
|
||||
container
|
||||
justify='space-between'
|
||||
wrap='nowrap'
|
||||
justify="space-between"
|
||||
wrap="nowrap"
|
||||
onClick={() => {
|
||||
setBarUncollapsed((curr) => !curr);
|
||||
}}
|
||||
>
|
||||
<Grid container item wrap='nowrap'>
|
||||
<Grid container item wrap="nowrap">
|
||||
{icons.map((notifIcon) => (
|
||||
<Grid
|
||||
item
|
||||
@@ -97,29 +97,21 @@ export const NotificationBar = () => {
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
<Grid
|
||||
container
|
||||
item
|
||||
wrap='nowrap'
|
||||
justify='flex-end'
|
||||
alignItems='center'
|
||||
>
|
||||
<Grid container item wrap="nowrap" justify="flex-end" alignItems="center">
|
||||
<Grid item>
|
||||
<SignalIcon fontSize='small' />
|
||||
<SignalIcon fontSize="small" />
|
||||
</Grid>
|
||||
<Grid item className={classes.item}>
|
||||
<Typography className={classes.text} variant='button'>
|
||||
<Typography className={classes.text} variant="button">
|
||||
{Default.cellProvider}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Battery90Icon
|
||||
style={{ transform: 'rotate(90deg)', display: 'block' }}
|
||||
/>
|
||||
<Battery90Icon style={{ transform: 'rotate(90deg)', display: 'block' }} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Slide direction='down' in={barUncollapsed}>
|
||||
<Slide direction="down" in={barUncollapsed}>
|
||||
<Paper square className={classes.drawer}>
|
||||
<Box py={2}>
|
||||
<List>
|
||||
@@ -146,10 +138,10 @@ export const NotificationBar = () => {
|
||||
))}
|
||||
</List>
|
||||
</Box>
|
||||
<Box display='flex'>
|
||||
<Box display="flex">
|
||||
<IconButton
|
||||
className={classes.collapseBtn}
|
||||
size='small'
|
||||
size="small"
|
||||
onClick={() => setBarUncollapsed(false)}
|
||||
>
|
||||
<ArrowDropUpIcon />
|
||||
|
||||
@@ -9,7 +9,7 @@ interface INotificationIcon {
|
||||
|
||||
export const NotificationIcon = ({ icon, to }: INotificationIcon) => {
|
||||
return (
|
||||
<IconButton component={NavLink} to={to} size='small'>
|
||||
<IconButton component={NavLink} to={to} size="small">
|
||||
{icon}
|
||||
</IconButton>
|
||||
);
|
||||
|
||||
@@ -47,12 +47,8 @@ export const NotificationItem = ({
|
||||
{icon && <ListItemAvatar>{icon}</ListItemAvatar>}
|
||||
<ListItemText secondary={content}>{title}</ListItemText>
|
||||
{!cantClose && (
|
||||
<IconButton
|
||||
className={classes.closeNotifBtn}
|
||||
size='small'
|
||||
onClick={onClose}
|
||||
>
|
||||
<CloseIcon color='primary' />
|
||||
<IconButton className={classes.closeNotifBtn} size="small" onClick={onClose}>
|
||||
<CloseIcon color="primary" />
|
||||
</IconButton>
|
||||
)}
|
||||
</ListItem>
|
||||
|
||||
@@ -4,9 +4,7 @@ import { NotificationsContext } from '../providers/NotificationsProvider';
|
||||
export const useNotifications = () => {
|
||||
const context = useContext(NotificationsContext);
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
'useNotifications must be wrapped by NotificationsProvider'
|
||||
);
|
||||
throw new Error('useNotifications must be wrapped by NotificationsProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -26,7 +26,7 @@ export const useQuickAccess = () => {
|
||||
const history = useHistory();
|
||||
const { apps, getApp } = useApps();
|
||||
const [recentlyUsed, setRecentlyUsed] = useRecoilState<IAppConfig[]>(
|
||||
state.recentlyUsed
|
||||
state.recentlyUsed,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -43,7 +43,7 @@ export const useQuickAccess = () => {
|
||||
});
|
||||
setRecentlyUsed(newState.slice(0, MAX_QUICK_ACCESS_ITEMS));
|
||||
},
|
||||
[apps, recentlyUsed, setRecentlyUsed]
|
||||
[apps, recentlyUsed, setRecentlyUsed],
|
||||
);
|
||||
|
||||
history.listen(listener);
|
||||
|
||||
@@ -56,7 +56,7 @@ export const NotificationsContext = createContext<{
|
||||
addNotificationAlert(
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update?: Partial<INotification>
|
||||
update?: Partial<INotification>,
|
||||
);
|
||||
}>(null);
|
||||
|
||||
@@ -83,16 +83,13 @@ export function NotificationsProvider({ children }) {
|
||||
}
|
||||
}, [isPhoneOpen, currentAlert]);
|
||||
|
||||
const updateNotification = useCallback(
|
||||
(idx: number, value: INotification) => {
|
||||
setNotifications((all) => {
|
||||
const updated = [...all];
|
||||
updated.splice(idx, 1, value);
|
||||
return updated;
|
||||
});
|
||||
},
|
||||
[]
|
||||
);
|
||||
const updateNotification = useCallback((idx: number, value: INotification) => {
|
||||
setNotifications((all) => {
|
||||
const updated = [...all];
|
||||
updated.splice(idx, 1, value);
|
||||
return updated;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const removeNotification = (idx) => {
|
||||
setNotifications((all) => {
|
||||
@@ -114,7 +111,7 @@ export function NotificationsProvider({ children }) {
|
||||
(appId: string): number => {
|
||||
return notifications.findIndex((n) => n.app === appId);
|
||||
},
|
||||
[notifications]
|
||||
[notifications],
|
||||
);
|
||||
|
||||
const addOrUpdateNotification = useCallback(
|
||||
@@ -126,7 +123,7 @@ export function NotificationsProvider({ children }) {
|
||||
}
|
||||
addNotification(add);
|
||||
},
|
||||
[addNotification, hasNotification, updateNotification]
|
||||
[addNotification, hasNotification, updateNotification],
|
||||
);
|
||||
|
||||
const _showAlert = useCallback(
|
||||
@@ -134,7 +131,7 @@ export function NotificationsProvider({ children }) {
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update: Partial<INotification>,
|
||||
soundUrl: string
|
||||
soundUrl: string,
|
||||
) => {
|
||||
return new Promise<void>((res) => {
|
||||
const resolve = () => {
|
||||
@@ -172,22 +169,18 @@ export function NotificationsProvider({ children }) {
|
||||
}, DEFAULT_ALERT_HIDE_TIME + 300);
|
||||
});
|
||||
},
|
||||
[addOrUpdateNotification, play]
|
||||
[addOrUpdateNotification, play],
|
||||
);
|
||||
|
||||
const addNotificationAlert = (
|
||||
n: INotification,
|
||||
persist?: boolean,
|
||||
update?: Partial<INotification>
|
||||
update?: Partial<INotification>,
|
||||
) => {
|
||||
if (n.sound) {
|
||||
const { sound, volume } = getSoundSettings(
|
||||
'notification',
|
||||
settings,
|
||||
n.app
|
||||
);
|
||||
const { sound, volume } = getSoundSettings('notification', settings, n.app);
|
||||
mount(sound, volume, false).then(({ url }) =>
|
||||
setAlerts((curr) => [...curr, [n, persist, update, url]])
|
||||
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -233,7 +226,7 @@ export function NotificationsProvider({ children }) {
|
||||
icons.unshift({ key: curr.app, icon: curr.notificationIcon, badge: 1 });
|
||||
return icons;
|
||||
}, []),
|
||||
[notifications]
|
||||
[notifications],
|
||||
);
|
||||
|
||||
const removeAlerts = () => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useNuiEvent = <S = Record<string, unknown>>(
|
||||
method: string,
|
||||
handler: Function,
|
||||
currentState?: S,
|
||||
options: IOptions = defaultOptions
|
||||
options: IOptions = defaultOptions,
|
||||
) => {
|
||||
const savedHandler: MutableRefObject<any> = useRef();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export const useNuiService = (options: IOptions = {}) => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent(eventNameFactory(app, method), {
|
||||
data,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,7 +6,5 @@ import * as config from '../../../config/default.json';
|
||||
export const usePhoneTheme = () => {
|
||||
const [settings] = useSettings();
|
||||
|
||||
return useMemo(() => createMuiTheme(config.themes[settings.theme]), [
|
||||
settings.theme,
|
||||
]);
|
||||
return useMemo(() => createMuiTheme(config.themes[settings.theme]), [settings.theme]);
|
||||
};
|
||||
@@ -12,9 +12,7 @@ export const useRingtoneSound = () => {
|
||||
throw new Error('useRingtoneSound must be wrapped in SoundProvider');
|
||||
}
|
||||
|
||||
const options = useMemo(() => getSoundSettings('ringtone', settings), [
|
||||
settings,
|
||||
]);
|
||||
const options = useMemo(() => getSoundSettings('ringtone', settings), [settings]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!sound.isMounted(options.sound)) {
|
||||
|
||||
@@ -11,7 +11,7 @@ interface ISoundContext {
|
||||
url: string,
|
||||
volume?: number,
|
||||
loop?: boolean,
|
||||
autoplay?: boolean
|
||||
autoplay?: boolean,
|
||||
): Promise<IMountResponse>;
|
||||
play(url?: string, volume?: number, loop?: boolean): void;
|
||||
stop(url: string): void;
|
||||
@@ -36,7 +36,7 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
url: string,
|
||||
volume: number = 1,
|
||||
loop: boolean = false,
|
||||
autoplay: boolean = false
|
||||
autoplay: boolean = false,
|
||||
) => {
|
||||
return new Promise<IMountResponse>((res) => {
|
||||
if (!soundRefs.current) {
|
||||
@@ -78,7 +78,7 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
instance.once('playerror', onError);
|
||||
});
|
||||
},
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
const play = useCallback(
|
||||
@@ -115,25 +115,19 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
}
|
||||
mount(url, volume, loop, true);
|
||||
},
|
||||
[mount]
|
||||
[mount],
|
||||
);
|
||||
|
||||
const volume = useCallback(
|
||||
(url: string, volume: number = undefined): number => {
|
||||
const sound = soundRefs.current.get(url);
|
||||
return sound?.howl.volume(volume) as number;
|
||||
},
|
||||
[]
|
||||
);
|
||||
const volume = useCallback((url: string, volume: number = undefined): number => {
|
||||
const sound = soundRefs.current.get(url);
|
||||
return sound?.howl.volume(volume) as number;
|
||||
}, []);
|
||||
|
||||
const loop = useCallback(
|
||||
(url: string, loop: boolean = undefined): boolean => {
|
||||
const sound = soundRefs.current.get(url);
|
||||
sound.howl.loop(loop);
|
||||
return sound.howl.loop();
|
||||
},
|
||||
[]
|
||||
);
|
||||
const loop = useCallback((url: string, loop: boolean = undefined): boolean => {
|
||||
const sound = soundRefs.current.get(url);
|
||||
sound.howl.loop(loop);
|
||||
return sound.howl.loop();
|
||||
}, []);
|
||||
|
||||
const stop = useCallback((url: string) => {
|
||||
if (!soundRefs.current) {
|
||||
|
||||
@@ -15,14 +15,13 @@ const getPath = {
|
||||
export const getSoundSettings = (
|
||||
type: 'ringtone' | 'notification',
|
||||
settings: IPhoneSettings,
|
||||
app?: string
|
||||
app?: string,
|
||||
) => {
|
||||
try {
|
||||
return app
|
||||
? {
|
||||
sound: getPath[type](settings[`${app}_${type}`] || settings[type]),
|
||||
volume:
|
||||
(settings[`${app}_${type}Vol`] || settings[`${type}Vol`]) / 100,
|
||||
volume: (settings[`${app}_${type}Vol`] || settings[`${type}Vol`]) / 100,
|
||||
}
|
||||
: {
|
||||
sound: getPath[type](settings[type]),
|
||||
|
||||
Reference in new issue
Block a user