mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
refactor(calls): refactor of call architecture
This commit is contained in:
1 parent
92b687b130
commit
36d1e993bd
21 files changed
+361
-185
No files matched your search
@@ -2,18 +2,17 @@ import { Box, Tooltip, Button } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import React from 'react';
|
||||
import { MarketplaceEvents, MarketplaceListing } from '../../../../../../typings/marketplace';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import ReportIcon from '@material-ui/icons/Report';
|
||||
import ChatIcon from '@material-ui/icons/Chat';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router';
|
||||
import { CallEvents } from '../../../../../../typings/call';
|
||||
import { fetchNui } from '../../../../utils/fetchNui';
|
||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||
import { ServerPromiseResp } from '../../../../../../typings/common';
|
||||
import { useMyPhoneNumber } from '../../../../os/simcard/hooks/useMyPhoneNumber';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
icon: {
|
||||
@@ -22,9 +21,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
}));
|
||||
|
||||
export const ListingActions: React.FC<MarketplaceListing> = ({ children, ...listing }) => {
|
||||
const Nui = useNuiRequest();
|
||||
const classes = useStyles();
|
||||
const { number: myNumber } = useSimcard();
|
||||
const myNumber = useMyPhoneNumber();
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
const { addAlert } = useSnackbar();
|
||||
@@ -66,8 +64,13 @@ export const ListingActions: React.FC<MarketplaceListing> = ({ children, ...list
|
||||
};
|
||||
|
||||
const handleCall = () => {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number: listing.number,
|
||||
fetchNui<ServerPromiseResp>(CallEvents.INITIALIZE_CALL, {
|
||||
receiverNumber: listing.number,
|
||||
}).then((resp) => {
|
||||
if (resp.status === 'error') {
|
||||
addAlert({ message: t('CALLS.FEEDBACK.ERROR'), type: 'error' });
|
||||
console.error(resp.errorMsg);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user