mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
cleanup: Recoil State Type Safety + Misc Cleanup (#189)
* chore(phone/settings): Removed unused state * cleanup(phone/photos): Added type safety to photo state * tweak(phone/marketplace): Added type safety to marketplace state * chore(phone/match): Removed unnecessary console.log * tweak(phone/messages): Added type safety to messages state Also fixed ESLint warning for exported anonymous hook in useMessages.ts * tweak(phone/match): Added type safety to match state * tweak(phone/dialer): Cleanup & type safety for state Renamed some types to better represent their data * cleanup(phone/gen): Added NUI event enums for phone events * tweak(phone/contacts): Type safety for contacts state & variable rename Renamed and type variable in setFilteredContacts to better represent its use * tweak(phone/gen-state): Added type-safety to gen phone global state * tweak(phone/settings): Type safety for settings state * tweak(phone/photos): Tweaked type for photo referral * fix(phone/notification-comp): Fix reference to old theme config * chore(phone/hooks): Remove keyboard service Removed as this was unused and ESLint was not happy with it * chore(phone): Cleaned up eslint warnings No more warnings hooray! * tweak(phone): Set time in dev mode * fix(phone): Remove useNuiService that appeared somehow * fix(phone/gallery): Fixed missing import for gallery * Revert removing the keyboard service as this is built upon in another PR This reverts commit 82d12255a84e918da087d988b599af98ce1fe54d. * fix(phone/keyboard): Add useKeyboardService hook back to Phone.tsx * fix(phone/gallery): Fix and standardized GalleryPhoto type
This commit is contained in:
35 files changed
+137
-148
No files matched your search
@@ -2,10 +2,10 @@ import React from 'react';
|
||||
import { Box, makeStyles } from '@material-ui/core';
|
||||
import { CallControls } from './CallControls';
|
||||
|
||||
interface ICallNotificationProps {
|
||||
onAccept(): void;
|
||||
onReject(): void;
|
||||
}
|
||||
// interface ICallNotificationProps {
|
||||
// onAccept(): void;
|
||||
// onReject(): void;
|
||||
// }
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { atom } from 'recoil';
|
||||
import { ActiveCall } from '../../../../../typings/call';
|
||||
|
||||
export const callerState = {
|
||||
currentCall: atom({
|
||||
currentCall: atom<ActiveCall>({
|
||||
key: 'currentCall',
|
||||
default: null,
|
||||
}),
|
||||
callModal: atom({
|
||||
callModal: atom<boolean>({
|
||||
key: 'callingModal',
|
||||
default: false,
|
||||
}),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { CallProps } from '../../../../../typings/call';
|
||||
import { ActiveCall } from '../../../../../typings/call';
|
||||
import { callerState } from './state';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
|
||||
interface CallHook {
|
||||
call: CallProps;
|
||||
call: ActiveCall;
|
||||
setCall: (details: any) => void;
|
||||
acceptCall(): void;
|
||||
rejectCall(): void;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CallProps } from '../../../../../typings/call';
|
||||
import { ActiveCall } from '../../../../../typings/call';
|
||||
import { useApp } from '../../apps/hooks/useApps';
|
||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
|
||||
@@ -27,7 +27,7 @@ export const useCallNotifications = () => {
|
||||
notificationIcon,
|
||||
};
|
||||
|
||||
const setNotification = (call: CallProps) => {
|
||||
const setNotification = (call: ActiveCall) => {
|
||||
stop();
|
||||
if (!call || !call.active) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { useCall } from './useCall';
|
||||
import { CallEvents, CallProps } from '../../../../../typings/call';
|
||||
|
||||
import { CallEvents, ActiveCall } from '../../../../../typings/call';
|
||||
// import InjectDebugData from '../../debug/InjectDebugData';
|
||||
import { useCallModal } from './useCallModal';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
@@ -54,7 +55,7 @@ export const useCallService = () => {
|
||||
}
|
||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||
|
||||
const _setCall = (_call: CallProps) => {
|
||||
const _setCall = (_call: ActiveCall) => {
|
||||
setCall({ ...call, ..._call });
|
||||
setNotification(_call);
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const phoneSettings = {
|
||||
theme: atom({
|
||||
key: 'settingTheme',
|
||||
default: 'default-dark',
|
||||
}),
|
||||
zoom: atom({
|
||||
key: 'settingZoom',
|
||||
default: '100%',
|
||||
}),
|
||||
};
|
||||
@@ -1,19 +1,20 @@
|
||||
import { atom } from 'recoil';
|
||||
import { IServerConfig } from '../../../../../typings/config';
|
||||
|
||||
export const phoneState = {
|
||||
visibility: atom({
|
||||
visibility: atom<boolean>({
|
||||
key: 'phoneVisibility',
|
||||
default: false,
|
||||
}),
|
||||
phoneConfig: atom({
|
||||
phoneConfig: atom<IServerConfig>({
|
||||
key: 'phoneConfig',
|
||||
default: undefined,
|
||||
default: null,
|
||||
}),
|
||||
phoneReady: atom({
|
||||
phoneReady: atom<boolean>({
|
||||
key: 'phoneReady',
|
||||
default: false,
|
||||
}),
|
||||
phoneTime: atom({
|
||||
phoneTime: atom<string>({
|
||||
key: 'phoneTime',
|
||||
default: null,
|
||||
}),
|
||||
|
||||
@@ -16,8 +16,8 @@ export const usePhoneService = () => {
|
||||
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
|
||||
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||
useNuiEvent('PHONE', 'setVisibility', setVisibility);
|
||||
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
|
||||
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
|
||||
useNuiEvent('PHONE', 'setTime', setPhoneTime);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setPhoneConfig);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import { simcardState } from './state';
|
||||
import { useSimcard } from './useSimcard';
|
||||
import InjectDebugData from '../../debug/InjectDebugData';
|
||||
import { useNuiEvent } from 'fivem-nui-react-lib';
|
||||
import { PhoneEvents } from '../../../../../typings/phone';
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
@@ -14,6 +15,6 @@ InjectDebugData([
|
||||
|
||||
export const useSimcardService = () => {
|
||||
const setNumber = useSetRecoilState(simcardState.number);
|
||||
useNuiEvent('SIMCARD', 'setNumber', setNumber);
|
||||
useNuiEvent('SIMCARD', PhoneEvents.SET_NUMBER, setNumber);
|
||||
return useSimcard();
|
||||
};
|
||||
Reference in new issue
Block a user