diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx
index 8469c0e..bd18a6f 100644
--- a/phone/src/Phone.tsx
+++ b/phone/src/Phone.tsx
@@ -9,7 +9,6 @@ import { Navigation } from './os/navigation-bar/components/Navigation';
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
import { usePhoneService } from './os/phone/hooks/usePhoneService';
import { useApps } from './os/apps/hooks/useApps';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
import { useMatchService } from './apps/match/hooks/useMatchService';
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
@@ -42,8 +41,6 @@ function Phone() {
const { addAlert } = useSnackbar();
- const Nui = useNuiRequest();
-
// Set language from local storage
// This will only trigger on first mount & settings changes
useEffect(() => {
diff --git a/phone/src/apps/camera/components/modal/GalleryModal.tsx b/phone/src/apps/camera/components/modal/GalleryModal.tsx
index b4903be..a5a445d 100644
--- a/phone/src/apps/camera/components/modal/GalleryModal.tsx
+++ b/phone/src/apps/camera/components/modal/GalleryModal.tsx
@@ -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 { Button, Paper } from '@material-ui/core';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
@@ -8,7 +8,6 @@ import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { ShareModal } from './ShareModal';
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { usePhotoActions } from '../../hooks/usePhotoActions';
import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx
index f6a1e19..0cd43af 100644
--- a/phone/src/apps/contacts/components/List/ContactList.tsx
+++ b/phone/src/apps/contacts/components/List/ContactList.tsx
@@ -8,7 +8,6 @@ import { SearchContacts } from './SearchContacts';
import { useHistory } from 'react-router-dom';
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
import { CallEvents } from '../../../../../../typings/call';
-import { useNuiRequest } from 'fivem-nui-react-lib';
import { useFilteredContacts } from '../../hooks/state';
import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
diff --git a/phone/src/apps/dialer/components/DialerApp.tsx b/phone/src/apps/dialer/components/DialerApp.tsx
index 86649e2..a479dbe 100644
--- a/phone/src/apps/dialer/components/DialerApp.tsx
+++ b/phone/src/apps/dialer/components/DialerApp.tsx
@@ -21,8 +21,6 @@ const LoadingSpinner: React.FC = () => (
);
export const DialerApp = () => {
- const history = useDialHistory();
-
const dialer = useApp('DIALER');
return (
@@ -35,7 +33,7 @@ export const DialerApp = () => {
}>
-
+
@@ -46,22 +44,3 @@ export const DialerApp = () => {
);
};
-
-InjectDebugData([
- {
- app: 'DIALER',
- method: CallEvents.SET_CALL_HISTORY,
- data: [
- {
- id: 1,
- transmitter: '636-6496',
- start: 1615946292,
- },
- {
- id: 2,
- transmitter: '777-7777',
- start: 1615946292,
- },
- ],
- },
-]);
diff --git a/phone/src/apps/dialer/components/views/DialerHistory.tsx b/phone/src/apps/dialer/components/views/DialerHistory.tsx
index b650e71..9493665 100644
--- a/phone/src/apps/dialer/components/views/DialerHistory.tsx
+++ b/phone/src/apps/dialer/components/views/DialerHistory.tsx
@@ -16,6 +16,7 @@ import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
+import { useDialHistory } from '../../hooks/useDialHistory';
const useStyles = makeStyles((theme: Theme) => ({
callForward: {
@@ -26,10 +27,11 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}));
-export const DialerHistory = ({ calls }) => {
+export const DialerHistory: React.FC = () => {
const { addAlert } = useSnackbar();
const myNumber = useMyPhoneNumber();
const { getDisplayByNumber } = useContactActions();
+ const calls = useDialHistory();
const classes = useStyles();
diff --git a/phone/src/apps/dialer/hooks/state.ts b/phone/src/apps/dialer/hooks/state.ts
index d3f3748..af090ad 100644
--- a/phone/src/apps/dialer/hooks/state.ts
+++ b/phone/src/apps/dialer/hooks/state.ts
@@ -1,9 +1,29 @@
-import { atom } from 'recoil';
-import { CallHistoryItem } from '../../../../../typings/call';
+import { atom, selector } from 'recoil';
+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 = {
history: atom({
key: 'dialHistory',
- default: [],
+ default: selector({
+ key: 'dialHistoryDefault',
+ get: async () => {
+ try {
+ const resp = await fetchNui>(CallEvents.FETCH_CALLS);
+ LogDebugEvent({ action: 'ContactsFetched', data: resp.data });
+ return resp.data;
+ } catch (e) {
+ if (isEnvBrowser()) {
+ return MockHistoryData;
+ }
+ console.error(e);
+ return [];
+ }
+ },
+ }),
}),
};
diff --git a/phone/src/apps/dialer/hooks/useDialHistory.ts b/phone/src/apps/dialer/hooks/useDialHistory.ts
index d7d07f8..1bcf8a2 100644
--- a/phone/src/apps/dialer/hooks/useDialHistory.ts
+++ b/phone/src/apps/dialer/hooks/useDialHistory.ts
@@ -1,6 +1,4 @@
import { useRecoilValue } from 'recoil';
import { dialState } from './state';
-export const useDialHistory = () => {
- return useRecoilValue(dialState.history);
-};
+export const useDialHistory = () => useRecoilValue(dialState.history);
diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts
index 4a3eb03..2e02675 100644
--- a/phone/src/apps/dialer/hooks/useDialService.ts
+++ b/phone/src/apps/dialer/hooks/useDialService.ts
@@ -1,6 +1,4 @@
-import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from 'fivem-nui-react-lib';
-import { dialState } from './state';
import { CallEvents } from '../../../../../typings/call';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
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);
};
diff --git a/phone/src/apps/dialer/utils/constants.ts b/phone/src/apps/dialer/utils/constants.ts
index 79b31af..5d131bb 100644
--- a/phone/src/apps/dialer/utils/constants.ts
+++ b/phone/src/apps/dialer/utils/constants.ts
@@ -1,10 +1,12 @@
-export const MockHistoryData = [
+import { CallHistoryItem } from '../../../../../typings/call';
+
+export const MockHistoryData: CallHistoryItem[] = [
{
id: 1,
identifier: 'ca839e8c-ef9d-40bd-b6a3-d531ee58149f',
transmitter: '704-1549',
receiver: '704-1549',
- is_accepted: 0,
+ is_accepted: true,
start: '1615939174',
end: null,
},
@@ -13,7 +15,7 @@ export const MockHistoryData = [
identifier: 'b8080a50-ad30-4ee9-84cb-00688e2bf167',
transmitter: '704-1549',
receiver: '704-1549',
- is_accepted: 0,
+ is_accepted: false,
start: '1615939850',
end: null,
},
diff --git a/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts b/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
index 6e57394..16e5a2a 100644
--- a/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
+++ b/phone/src/apps/marketplace/hooks/useMarketplaceActions.ts
@@ -31,7 +31,7 @@ export const useMarketplaceActions = (): MarketplaceActionValues => {
if (valueLoading !== 'hasValue') return;
setListings((curListings) => [...curListings, listing]);
},
- [setListings, valueLoading, contents],
+ [setListings, valueLoading],
);
return { deleteListing, addListing };
diff --git a/phone/src/apps/messages/components/MessagesApp.tsx b/phone/src/apps/messages/components/MessagesApp.tsx
index f938b8c..af872f9 100644
--- a/phone/src/apps/messages/components/MessagesApp.tsx
+++ b/phone/src/apps/messages/components/MessagesApp.tsx
@@ -12,12 +12,13 @@ import NewMessageGroupButton from './form/NewMessageGroupButton';
import { useNuiRequest } from 'fivem-nui-react-lib';
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
import { MessageEvents } from '../../../../../typings/messages';
+import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
export const MessagesApp = () => {
const Nui = useNuiRequest();
const messages = useApp('MESSAGES');
const history = useHistory();
-
+
useEffect(() => {
Nui.send(MessageEvents.FETCH_MESSAGE_GROUPS);
}, [Nui]);
@@ -27,21 +28,23 @@ export const MessagesApp = () => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ }>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
history.push('/messages/new')} />
diff --git a/phone/src/apps/messages/components/modal/MessageModal.tsx b/phone/src/apps/messages/components/modal/MessageModal.tsx
index fae4f57..4207c1f 100644
--- a/phone/src/apps/messages/components/modal/MessageModal.tsx
+++ b/phone/src/apps/messages/components/modal/MessageModal.tsx
@@ -22,7 +22,7 @@ import { useHistory, useLocation, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import Modal from '../../../../ui/components/Modal';
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';
const LARGE_HEADER_CHARS = 30;
@@ -51,7 +51,7 @@ export const MessageModal = () => {
const Nui = useNuiRequest();
const classes = useStyles();
const history = useHistory();
- const { number: myNumber } = useSimcard();
+ const myNumber = useMyPhoneNumber();
const { pathname } = useLocation();
const { t } = useTranslation();
const { groupId } = useParams<{ groupId: string }>();
diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx
index 7daab1a..8a08930 100644
--- a/phone/src/apps/notes/list/NoteList.tsx
+++ b/phone/src/apps/notes/list/NoteList.tsx
@@ -4,7 +4,6 @@ import { useNotesValue } from '../hooks/state';
import { useSetSelectedNote } from '../hooks/state';
import { NoteItem } from '../../../../../typings/notes';
import { makeStyles, Theme } from '@material-ui/core/styles';
-import { Notes } from '@material-ui/icons';
const useStyles = makeStyles((theme: Theme) => ({
noNotes: {
diff --git a/phone/src/apps/settings/components/SettingsApp.tsx b/phone/src/apps/settings/components/SettingsApp.tsx
index 771163c..eba4145 100644
--- a/phone/src/apps/settings/components/SettingsApp.tsx
+++ b/phone/src/apps/settings/components/SettingsApp.tsx
@@ -5,7 +5,7 @@ import { AppContent } from '../../../ui/components/AppContent';
import { useContextMenu, MapSettingItem, SettingOption } from '../../../ui/hooks/useContextMenu';
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
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 {
SettingItem,
@@ -59,7 +59,7 @@ const useStyles = makeStyles({
export const SettingsApp = () => {
const settingsApp = useApp('SETTINGS');
const [config] = usePhoneConfig();
- const simcard = useSimcard();
+ const myNumber = useMyPhoneNumber();
const [settings, setSettings] = useSettings();
const { t } = useTranslation();
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
@@ -142,7 +142,7 @@ export const SettingsApp = () => {
};
const handleCopyPhoneNumber = () => {
- setClipboard(simcard.number);
+ setClipboard(myNumber);
addAlert({
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
content: 'number',
@@ -162,7 +162,7 @@ export const SettingsApp = () => {
}>