mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
fix(calls): fix references to async selector DialerHistory
This commit is contained in:
1 parent
36d1e993bd
commit
10c5e97088
15 files changed
+45
-51
No files matched your search
@@ -9,7 +9,6 @@ import { Navigation } from './os/navigation-bar/components/Navigation';
|
|||||||
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
|
||||||
import { usePhoneService } from './os/phone/hooks/usePhoneService';
|
import { usePhoneService } from './os/phone/hooks/usePhoneService';
|
||||||
import { useApps } from './os/apps/hooks/useApps';
|
import { useApps } from './os/apps/hooks/useApps';
|
||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
|
||||||
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
|
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
|
||||||
import { useMatchService } from './apps/match/hooks/useMatchService';
|
import { useMatchService } from './apps/match/hooks/useMatchService';
|
||||||
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
|
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
|
||||||
@@ -42,8 +41,6 @@ function Phone() {
|
|||||||
|
|
||||||
const { addAlert } = useSnackbar();
|
const { addAlert } = useSnackbar();
|
||||||
|
|
||||||
const Nui = useNuiRequest();
|
|
||||||
|
|
||||||
// Set language from local storage
|
// Set language from local storage
|
||||||
// This will only trigger on first mount & settings changes
|
// This will only trigger on first mount & settings changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo, useState, useCallback, useEffect } from 'react';
|
import React, { useMemo, useState, useCallback } from 'react';
|
||||||
import useStyles from './modal.styles';
|
import useStyles from './modal.styles';
|
||||||
import { Button, Paper } from '@material-ui/core';
|
import { Button, Paper } from '@material-ui/core';
|
||||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
@@ -8,7 +8,6 @@ import { useHistory } from 'react-router-dom';
|
|||||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||||
import { ShareModal } from './ShareModal';
|
import { ShareModal } from './ShareModal';
|
||||||
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
|
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
|
||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
|
||||||
import { usePhotoActions } from '../../hooks/usePhotoActions';
|
import { usePhotoActions } from '../../hooks/usePhotoActions';
|
||||||
import { fetchNui } from '../../../../utils/fetchNui';
|
import { fetchNui } from '../../../../utils/fetchNui';
|
||||||
import { ServerPromiseResp } from '../../../../../../typings/common';
|
import { ServerPromiseResp } from '../../../../../../typings/common';
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { SearchContacts } from './SearchContacts';
|
|||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||||
import { CallEvents } from '../../../../../../typings/call';
|
import { CallEvents } from '../../../../../../typings/call';
|
||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
|
||||||
import { useFilteredContacts } from '../../hooks/state';
|
import { useFilteredContacts } from '../../hooks/state';
|
||||||
import { fetchNui } from '../../../../utils/fetchNui';
|
import { fetchNui } from '../../../../utils/fetchNui';
|
||||||
import { ServerPromiseResp } from '../../../../../../typings/common';
|
import { ServerPromiseResp } from '../../../../../../typings/common';
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ const LoadingSpinner: React.FC = () => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const DialerApp = () => {
|
export const DialerApp = () => {
|
||||||
const history = useDialHistory();
|
|
||||||
|
|
||||||
const dialer = useApp('DIALER');
|
const dialer = useApp('DIALER');
|
||||||
return (
|
return (
|
||||||
<DialerThemeProvider>
|
<DialerThemeProvider>
|
||||||
@@ -35,7 +33,7 @@ export const DialerApp = () => {
|
|||||||
</Route>
|
</Route>
|
||||||
<Route exact path="/phone">
|
<Route exact path="/phone">
|
||||||
<React.Suspense fallback={<LoadingSpinner />}>
|
<React.Suspense fallback={<LoadingSpinner />}>
|
||||||
<DialerHistory calls={history} />
|
<DialerHistory />
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/phone/contacts" component={ContactList} />
|
<Route path="/phone/contacts" component={ContactList} />
|
||||||
@@ -46,22 +44,3 @@ export const DialerApp = () => {
|
|||||||
</DialerThemeProvider>
|
</DialerThemeProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
InjectDebugData([
|
|
||||||
{
|
|
||||||
app: 'DIALER',
|
|
||||||
method: CallEvents.SET_CALL_HISTORY,
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
transmitter: '636-6496',
|
|
||||||
start: 1615946292,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
transmitter: '777-7777',
|
|
||||||
start: 1615946292,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
@@ -16,6 +16,7 @@ import { fetchNui } from '../../../../utils/fetchNui';
|
|||||||
import { ServerPromiseResp } from '../../../../../../typings/common';
|
import { ServerPromiseResp } from '../../../../../../typings/common';
|
||||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||||
import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
|
import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
|
||||||
|
import { useDialHistory } from '../../hooks/useDialHistory';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
callForward: {
|
callForward: {
|
||||||
@@ -26,10 +27,11 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const DialerHistory = ({ calls }) => {
|
export const DialerHistory: React.FC = () => {
|
||||||
const { addAlert } = useSnackbar();
|
const { addAlert } = useSnackbar();
|
||||||
const myNumber = useMyPhoneNumber();
|
const myNumber = useMyPhoneNumber();
|
||||||
const { getDisplayByNumber } = useContactActions();
|
const { getDisplayByNumber } = useContactActions();
|
||||||
|
const calls = useDialHistory();
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,29 @@
|
|||||||
import { atom } from 'recoil';
|
import { atom, selector } from 'recoil';
|
||||||
import { CallHistoryItem } from '../../../../../typings/call';
|
import { CallEvents, CallHistoryItem } from '../../../../../typings/call';
|
||||||
|
import { fetchNui } from '../../../utils/fetchNui';
|
||||||
|
import { ServerPromiseResp } from '../../../../../typings/common';
|
||||||
|
import LogDebugEvent from '../../../os/debug/LogDebugEvents';
|
||||||
|
import { isEnvBrowser } from '../../../utils/misc';
|
||||||
|
import { MockHistoryData } from '../utils/constants';
|
||||||
|
|
||||||
export const dialState = {
|
export const dialState = {
|
||||||
history: atom<CallHistoryItem[]>({
|
history: atom<CallHistoryItem[]>({
|
||||||
key: 'dialHistory',
|
key: 'dialHistory',
|
||||||
default: [],
|
default: selector({
|
||||||
|
key: 'dialHistoryDefault',
|
||||||
|
get: async () => {
|
||||||
|
try {
|
||||||
|
const resp = await fetchNui<ServerPromiseResp<CallHistoryItem[]>>(CallEvents.FETCH_CALLS);
|
||||||
|
LogDebugEvent({ action: 'ContactsFetched', data: resp.data });
|
||||||
|
return resp.data;
|
||||||
|
} catch (e) {
|
||||||
|
if (isEnvBrowser()) {
|
||||||
|
return MockHistoryData;
|
||||||
|
}
|
||||||
|
console.error(e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { dialState } from './state';
|
import { dialState } from './state';
|
||||||
|
|
||||||
export const useDialHistory = () => {
|
export const useDialHistory = () => useRecoilValue(dialState.history);
|
||||||
return useRecoilValue(dialState.history);
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import { useSetRecoilState } from 'recoil';
|
|
||||||
import { useNuiEvent } from 'fivem-nui-react-lib';
|
import { useNuiEvent } from 'fivem-nui-react-lib';
|
||||||
import { dialState } from './state';
|
|
||||||
import { CallEvents } from '../../../../../typings/call';
|
import { CallEvents } from '../../../../../typings/call';
|
||||||
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -16,7 +14,5 @@ export const useDialService = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const setHistory = useSetRecoilState(dialState.history);
|
|
||||||
useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory);
|
|
||||||
useNuiEvent('DIALER', CallEvents.SEND_ALERT, handleAddAlert);
|
useNuiEvent('DIALER', CallEvents.SEND_ALERT, handleAddAlert);
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
export const MockHistoryData = [
|
import { CallHistoryItem } from '../../../../../typings/call';
|
||||||
|
|
||||||
|
export const MockHistoryData: CallHistoryItem[] = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
identifier: 'ca839e8c-ef9d-40bd-b6a3-d531ee58149f',
|
identifier: 'ca839e8c-ef9d-40bd-b6a3-d531ee58149f',
|
||||||
transmitter: '704-1549',
|
transmitter: '704-1549',
|
||||||
receiver: '704-1549',
|
receiver: '704-1549',
|
||||||
is_accepted: 0,
|
is_accepted: true,
|
||||||
start: '1615939174',
|
start: '1615939174',
|
||||||
end: null,
|
end: null,
|
||||||
},
|
},
|
||||||
@@ -13,7 +15,7 @@ export const MockHistoryData = [
|
|||||||
identifier: 'b8080a50-ad30-4ee9-84cb-00688e2bf167',
|
identifier: 'b8080a50-ad30-4ee9-84cb-00688e2bf167',
|
||||||
transmitter: '704-1549',
|
transmitter: '704-1549',
|
||||||
receiver: '704-1549',
|
receiver: '704-1549',
|
||||||
is_accepted: 0,
|
is_accepted: false,
|
||||||
start: '1615939850',
|
start: '1615939850',
|
||||||
end: null,
|
end: null,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const useMarketplaceActions = (): MarketplaceActionValues => {
|
|||||||
if (valueLoading !== 'hasValue') return;
|
if (valueLoading !== 'hasValue') return;
|
||||||
setListings((curListings) => [...curListings, listing]);
|
setListings((curListings) => [...curListings, listing]);
|
||||||
},
|
},
|
||||||
[setListings, valueLoading, contents],
|
[setListings, valueLoading],
|
||||||
);
|
);
|
||||||
|
|
||||||
return { deleteListing, addListing };
|
return { deleteListing, addListing };
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import NewMessageGroupButton from './form/NewMessageGroupButton';
|
|||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||||
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
|
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
|
||||||
import { MessageEvents } from '../../../../../typings/messages';
|
import { MessageEvents } from '../../../../../typings/messages';
|
||||||
|
import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
|
||||||
|
|
||||||
export const MessagesApp = () => {
|
export const MessagesApp = () => {
|
||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
@@ -27,6 +28,7 @@ export const MessagesApp = () => {
|
|||||||
<AppWrapper id="messages-app">
|
<AppWrapper id="messages-app">
|
||||||
<AppTitle app={messages} />
|
<AppTitle app={messages} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
|
<React.Suspense fallback={<LoadingSpinner />}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/messages/conversations/:groupId">
|
<Route path="/messages/conversations/:groupId">
|
||||||
<div>
|
<div>
|
||||||
@@ -42,6 +44,7 @@ export const MessagesApp = () => {
|
|||||||
<MessageGroupModal />
|
<MessageGroupModal />
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
</React.Suspense>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
<Route exact path="/messages">
|
<Route exact path="/messages">
|
||||||
<NewMessageGroupButton onClick={() => history.push('/messages/new')} />
|
<NewMessageGroupButton onClick={() => history.push('/messages/new')} />
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { useHistory, useLocation, useParams } from 'react-router-dom';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Modal from '../../../../ui/components/Modal';
|
import Modal from '../../../../ui/components/Modal';
|
||||||
import { useContactActions } from '../../../contacts/hooks/useContactActions';
|
import { useContactActions } from '../../../contacts/hooks/useContactActions';
|
||||||
import { useSimcard } from '../../../../os/simcard/hooks/useMyPhoneNumber';
|
import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
|
||||||
import { MessageEvents } from '../../../../../../typings/messages';
|
import { MessageEvents } from '../../../../../../typings/messages';
|
||||||
|
|
||||||
const LARGE_HEADER_CHARS = 30;
|
const LARGE_HEADER_CHARS = 30;
|
||||||
@@ -51,7 +51,7 @@ export const MessageModal = () => {
|
|||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { number: myNumber } = useSimcard();
|
const myNumber = useMyPhoneNumber();
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { groupId } = useParams<{ groupId: string }>();
|
const { groupId } = useParams<{ groupId: string }>();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useNotesValue } from '../hooks/state';
|
|||||||
import { useSetSelectedNote } from '../hooks/state';
|
import { useSetSelectedNote } from '../hooks/state';
|
||||||
import { NoteItem } from '../../../../../typings/notes';
|
import { NoteItem } from '../../../../../typings/notes';
|
||||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
import { Notes } from '@material-ui/icons';
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
noNotes: {
|
noNotes: {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { AppContent } from '../../../ui/components/AppContent';
|
|||||||
import { useContextMenu, MapSettingItem, SettingOption } from '../../../ui/hooks/useContextMenu';
|
import { useContextMenu, MapSettingItem, SettingOption } from '../../../ui/hooks/useContextMenu';
|
||||||
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
|
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
|
||||||
import { List } from '../../../ui/components/List';
|
import { List } from '../../../ui/components/List';
|
||||||
import { useSimcard } from '../../../os/simcard/hooks/useMyPhoneNumber';
|
import { useMyPhoneNumber } from '../../../os/simcard/hooks/useMyPhoneNumber';
|
||||||
import { IconSetObject, useApp } from '../../../os/apps/hooks/useApps';
|
import { IconSetObject, useApp } from '../../../os/apps/hooks/useApps';
|
||||||
import {
|
import {
|
||||||
SettingItem,
|
SettingItem,
|
||||||
@@ -59,7 +59,7 @@ const useStyles = makeStyles({
|
|||||||
export const SettingsApp = () => {
|
export const SettingsApp = () => {
|
||||||
const settingsApp = useApp('SETTINGS');
|
const settingsApp = useApp('SETTINGS');
|
||||||
const [config] = usePhoneConfig();
|
const [config] = usePhoneConfig();
|
||||||
const simcard = useSimcard();
|
const myNumber = useMyPhoneNumber();
|
||||||
const [settings, setSettings] = useSettings();
|
const [settings, setSettings] = useSettings();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
||||||
@@ -142,7 +142,7 @@ export const SettingsApp = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCopyPhoneNumber = () => {
|
const handleCopyPhoneNumber = () => {
|
||||||
setClipboard(simcard.number);
|
setClipboard(myNumber);
|
||||||
addAlert({
|
addAlert({
|
||||||
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
|
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
|
||||||
content: 'number',
|
content: 'number',
|
||||||
@@ -162,7 +162,7 @@ export const SettingsApp = () => {
|
|||||||
<List disablePadding subheader={<SubHeaderComp text={t('SETTINGS.CATEGORY.PHONE')} />}>
|
<List disablePadding subheader={<SubHeaderComp text={t('SETTINGS.CATEGORY.PHONE')} />}>
|
||||||
<SettingItemIconAction
|
<SettingItemIconAction
|
||||||
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
||||||
labelSecondary={simcard.number}
|
labelSecondary={myNumber}
|
||||||
actionLabel={t('GENERIC_WRITE_TO_CLIPBOARD_TOOLTIP', {
|
actionLabel={t('GENERIC_WRITE_TO_CLIPBOARD_TOOLTIP', {
|
||||||
content: 'number',
|
content: 'number',
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { createLazyAppIcon } from '../utils/createLazyAppIcon';
|
|||||||
import { APPS, IApp } from '../config/apps';
|
import { APPS, IApp } from '../config/apps';
|
||||||
import { SvgIconComponent } from '@material-ui/icons';
|
import { SvgIconComponent } from '@material-ui/icons';
|
||||||
import { useTheme } from '@material-ui/core';
|
import { useTheme } from '@material-ui/core';
|
||||||
import { useSettings, useSettingsValue } from '../../../apps/settings/hooks/useSettings';
|
import { useSettingsValue } from '../../../apps/settings/hooks/useSettings';
|
||||||
|
|
||||||
export interface IconSetObject {
|
export interface IconSetObject {
|
||||||
custom: boolean;
|
custom: boolean;
|
||||||
|
|||||||
Reference in new issue
Block a user