mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Remove client phoneConfig event (#73)
* Remove client phoneConfig event * Remove unused debug * Remove unused import * Remove unused import * Remove duplicated functions | fix useEffect dependency | etc * Fix warnings * Update phone/src/apps/twitter/components/TwitterApp.tsx Co-authored-by: Taso <[email protected]> Co-authored-by: Taso <[email protected]>
This commit is contained in:
1 parent
fdfd4133e2
commit
81f5e27064
12 files changed
+61
-81
No files matched your search
+3
-2
@@ -75,10 +75,11 @@
|
|||||||
"webpack-cli": "^3.3.12"
|
"webpack-cli": "^3.3.12"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"copy:config": "cp ../config.json ./src/config.autogen.json",
|
||||||
|
"start": "yarn copy:config && react-scripts start",
|
||||||
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
|
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
|
||||||
"format": "prettier --write src/**/*.{js,jsx,ts,tsx,json,css,scss,md}",
|
"format": "prettier --write src/**/*.{js,jsx,ts,tsx,json,css,scss,md}",
|
||||||
"build": "cross-env NODE_ENV=production webpack --config webpack/webpack.resources.js --color -p --progress --hide-modules --display-optimization-bailout",
|
"build": "yarn copy:config && cross-env NODE_ENV=production webpack --config webpack/webpack.resources.js --color -p --progress --hide-modules --display-optimization-bailout",
|
||||||
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||||
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
|
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
|
|||||||
+9
-46
@@ -1,7 +1,7 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import './Phone.css';
|
import './Phone.css';
|
||||||
import './i18n';
|
import './i18n';
|
||||||
import { Route, useHistory } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
import { CallModal } from './modal/components/CallModal';
|
import { CallModal } from './modal/components/CallModal';
|
||||||
import { HomeApp } from './apps/home/components/Home';
|
import { HomeApp } from './apps/home/components/Home';
|
||||||
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
|
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
|
||||||
@@ -33,51 +33,6 @@ import { useDialService } from './apps/dialer/hooks/useDialService';
|
|||||||
import InjectDebugData from './os/debug/InjectDebugData';
|
import InjectDebugData from './os/debug/InjectDebugData';
|
||||||
import { useQuickAccess } from './os/notifications/hooks/useQuickAccess';
|
import { useQuickAccess } from './os/notifications/hooks/useQuickAccess';
|
||||||
|
|
||||||
InjectDebugData([
|
|
||||||
{
|
|
||||||
app: 'PHONE',
|
|
||||||
method: 'phoneConfig',
|
|
||||||
data: {
|
|
||||||
Locale: 'en',
|
|
||||||
KeyTogglePhone: 288,
|
|
||||||
KeyTakeCall: 38,
|
|
||||||
PhoneAsItem: false,
|
|
||||||
SwimDestroy: false,
|
|
||||||
RunRate: 10,
|
|
||||||
DestoryChance: 100,
|
|
||||||
DestroyPhoneReCheck: 3,
|
|
||||||
notificationPosition: {
|
|
||||||
horizontal: 'right',
|
|
||||||
vertical: 'top',
|
|
||||||
},
|
|
||||||
general: {
|
|
||||||
useDashNumber: true,
|
|
||||||
},
|
|
||||||
twitter: {
|
|
||||||
showNotifications: true,
|
|
||||||
generateProfileNameFromUsers: true,
|
|
||||||
allowEdtiableProfileName: true,
|
|
||||||
allowDeleteTweets: true,
|
|
||||||
allowReportTweets: true,
|
|
||||||
characterLimit: 160,
|
|
||||||
newLineLimit: 10,
|
|
||||||
enableAvatars: true,
|
|
||||||
enableEmojis: true,
|
|
||||||
enableImages: true,
|
|
||||||
maxImages: 3,
|
|
||||||
},
|
|
||||||
bank: {
|
|
||||||
showNotifications: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
app: 'PHONE',
|
|
||||||
method: 'setVisibility',
|
|
||||||
data: true,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const quickAccess = useQuickAccess();
|
const quickAccess = useQuickAccess();
|
||||||
useNuiService();
|
useNuiService();
|
||||||
@@ -173,3 +128,11 @@ function Phone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default Phone;
|
export default Phone;
|
||||||
|
|
||||||
|
InjectDebugData([
|
||||||
|
{
|
||||||
|
app: 'PHONE',
|
||||||
|
method: 'setVisibility',
|
||||||
|
data: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, {useEffect} from 'react';
|
import React from 'react';
|
||||||
import { Box, Button } from '@material-ui/core';
|
import { Box, Button } from '@material-ui/core';
|
||||||
import useStyles from './grid.styles';
|
import useStyles from './grid.styles';
|
||||||
import { usePhotos } from '../../hooks/usePhotos';
|
import { usePhotos } from '../../hooks/usePhotos';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button, TextField, Slide } from '@material-ui/core';
|
import { Button, TextField, Slide } from '@material-ui/core';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||||
|
|
||||||
import { useNoteModal } from '../hooks/useNoteModal';
|
import { useNoteModal } from '../hooks/useNoteModal';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import { TextField } from '@material-ui/core';
|
import { TextField } from '@material-ui/core';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles({
|
||||||
textField: {
|
textField: {
|
||||||
flex: '1 1 100%',
|
flex: '1 1 100%',
|
||||||
padding: '10px 15px',
|
padding: '10px 15px',
|
||||||
@@ -12,7 +12,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
textFieldInput: {
|
textFieldInput: {
|
||||||
fontSize: '22px',
|
fontSize: '22px',
|
||||||
},
|
},
|
||||||
}));
|
});
|
||||||
|
|
||||||
export const ImagePrompt = ({ visible, value, handleChange }) => {
|
export const ImagePrompt = ({ visible, value, handleChange }) => {
|
||||||
const textFieldRef = useRef(null);
|
const textFieldRef = useRef(null);
|
||||||
@@ -23,7 +23,10 @@ export const ImagePrompt = ({ visible, value, handleChange }) => {
|
|||||||
textFieldRef.current && textFieldRef.current.focus();
|
textFieldRef.current && textFieldRef.current.focus();
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
|
||||||
const handleImageChange = useCallback(e => handleChange(e.target.value), []);
|
const handleImageChange = useCallback(
|
||||||
|
(e) => handleChange(e.target.value),
|
||||||
|
[handleChange]
|
||||||
|
);
|
||||||
|
|
||||||
if (!visible) return null;
|
if (!visible) return null;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ export const useTwitterService = () => {
|
|||||||
);
|
);
|
||||||
const setNotification = useSetRecoilState(twitterState.notification);
|
const setNotification = useSetRecoilState(twitterState.notification);
|
||||||
|
|
||||||
const _setProfile = (profile) => {
|
|
||||||
setProfile(profile);
|
|
||||||
};
|
|
||||||
const _setUpdateProfileSuccess = (isSuccessful) => {
|
const _setUpdateProfileSuccess = (isSuccessful) => {
|
||||||
setUpdateProfileSuccess(isSuccessful);
|
setUpdateProfileSuccess(isSuccessful);
|
||||||
setUpdateProfileLoading(false); // on any result we should set loading to false
|
setUpdateProfileLoading(false); // on any result we should set loading to false
|
||||||
@@ -56,10 +53,6 @@ export const useTwitterService = () => {
|
|||||||
setCreateLoading(false);
|
setCreateLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const _setNotification = (tweet) => {
|
|
||||||
setNotification(tweet);
|
|
||||||
};
|
|
||||||
|
|
||||||
const _setTweets = (tweets) => {
|
const _setTweets = (tweets) => {
|
||||||
setTweets(tweets.map(processTweet));
|
setTweets(tweets.map(processTweet));
|
||||||
};
|
};
|
||||||
@@ -67,12 +60,12 @@ export const useTwitterService = () => {
|
|||||||
setFilteredTweets(tweets.map(processTweet));
|
setFilteredTweets(tweets.map(processTweet));
|
||||||
};
|
};
|
||||||
|
|
||||||
useNuiEvent(APP_TWITTER, 'getOrCreateTwitterProfile', _setProfile);
|
useNuiEvent(APP_TWITTER, 'getOrCreateTwitterProfile', setProfile);
|
||||||
useNuiEvent(APP_TWITTER, 'updateProfileLoading', setUpdateProfileLoading);
|
useNuiEvent(APP_TWITTER, 'updateProfileLoading', setUpdateProfileLoading);
|
||||||
useNuiEvent(APP_TWITTER, 'updateProfileResult', _setUpdateProfileSuccess);
|
useNuiEvent(APP_TWITTER, 'updateProfileResult', _setUpdateProfileSuccess);
|
||||||
useNuiEvent(APP_TWITTER, 'fetchTweets', _setTweets);
|
useNuiEvent(APP_TWITTER, 'fetchTweets', _setTweets);
|
||||||
useNuiEvent(APP_TWITTER, 'fetchTweetsFiltered', _setFilteredTweets);
|
useNuiEvent(APP_TWITTER, 'fetchTweetsFiltered', _setFilteredTweets);
|
||||||
useNuiEvent(APP_TWITTER, 'createTweetLoading', setCreateLoading);
|
useNuiEvent(APP_TWITTER, 'createTweetLoading', setCreateLoading);
|
||||||
useNuiEvent(APP_TWITTER, 'createTweetResult', _setCreateSuccess);
|
useNuiEvent(APP_TWITTER, 'createTweetResult', _setCreateSuccess);
|
||||||
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', _setNotification);
|
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', setNotification);
|
||||||
};
|
};
|
||||||
@@ -25,7 +25,7 @@ interface BankConfig {
|
|||||||
showNotifications: boolean;
|
showNotifications: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerConfig {
|
export interface IServerConfig {
|
||||||
Locale: string;
|
Locale: string;
|
||||||
KeyTogglePhone: number;
|
KeyTogglePhone: number;
|
||||||
KeyTakeCall: number;
|
KeyTakeCall: number;
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"Locale": "en",
|
||||||
|
"KeyTogglePhone": 288,
|
||||||
|
"KeyTakeCall": 38,
|
||||||
|
"PhoneAsItem": false,
|
||||||
|
"SwimDestroy": false,
|
||||||
|
"RunRate": 10,
|
||||||
|
"DestoryChance": 100,
|
||||||
|
"DestroyPhoneReCheck": 3,
|
||||||
|
"notificationPosition": {
|
||||||
|
"horizontal": "right",
|
||||||
|
"vertical": "top"
|
||||||
|
},
|
||||||
|
"general": {
|
||||||
|
"useDashNumber": true
|
||||||
|
},
|
||||||
|
"twitter": {
|
||||||
|
"showNotifications": true,
|
||||||
|
"generateProfileNameFromUsers": true,
|
||||||
|
"allowEdtiableProfileName": true,
|
||||||
|
"allowDeleteTweets": true,
|
||||||
|
"allowReportTweets": true,
|
||||||
|
"characterLimit": 160,
|
||||||
|
"newLineLimit": 10,
|
||||||
|
"enableAvatars": true,
|
||||||
|
"enableEmojis": true,
|
||||||
|
"enableImages": true,
|
||||||
|
"maxImages": 3
|
||||||
|
},
|
||||||
|
"bank": {
|
||||||
|
"showNotifications": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ type AppsRepository = { preinstalled: IAppConfig[] };
|
|||||||
const AppWithStartup = ({ children, id }) => {
|
const AppWithStartup = ({ children, id }) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Nui.send(`phone:app:${id}`);
|
Nui.send(`phone:app:${id}`);
|
||||||
}, []);
|
}, [id]);
|
||||||
return children;
|
return children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
import { ServerConfig } from '../../../common/typings/config';
|
import { IServerConfig } from '../../../common/typings/config';
|
||||||
|
import ServerConfig from '../../../config.autogen.json';
|
||||||
|
|
||||||
interface IUsePhone {
|
interface IUsePhone {
|
||||||
visibility: boolean;
|
visibility: boolean;
|
||||||
config?: ServerConfig;
|
config?: IServerConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePhone = (): IUsePhone => {
|
export const usePhone = (): IUsePhone => {
|
||||||
const visibility = useRecoilValue(phoneState.visibility);
|
const visibility = useRecoilValue(phoneState.visibility);
|
||||||
const config = useRecoilValue(phoneState.phoneConfig);
|
return { visibility, config: ServerConfig as any };
|
||||||
return { visibility, config };
|
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,6 @@ import { makeStyles } from '@material-ui/core/styles';
|
|||||||
import Avatar from '@material-ui/core/Avatar';
|
import Avatar from '@material-ui/core/Avatar';
|
||||||
import { green } from '@material-ui/core/colors';
|
import { green } from '@material-ui/core/colors';
|
||||||
import { Button } from '@material-ui/core';
|
import { Button } from '@material-ui/core';
|
||||||
import Nui from '../../os/nui-events/utils/Nui';
|
|
||||||
|
|
||||||
interface IStyles {
|
interface IStyles {
|
||||||
root: any;
|
root: any;
|
||||||
|
|||||||
@@ -210,16 +210,6 @@ function noPhone() {
|
|||||||
ESX.ShowNotification('Oi Mate, No El Telephono', false, false, 1);
|
ESX.ShowNotification('Oi Mate, No El Telephono', false, false, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendPhoneConfig() {
|
|
||||||
SendNuiMessage(
|
|
||||||
JSON.stringify({
|
|
||||||
app: 'PHONE',
|
|
||||||
method: 'phoneConfig',
|
|
||||||
data: config,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTick(() => {
|
setTick(() => {
|
||||||
if (IsControlJustPressed(1, config.KeyTogglePhone)) {
|
if (IsControlJustPressed(1, config.KeyTogglePhone)) {
|
||||||
Phone();
|
Phone();
|
||||||
@@ -263,7 +253,6 @@ async function Phone() {
|
|||||||
data: true,
|
data: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
sendPhoneConfig();
|
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
//SetNuiFocusKeepInput(true)
|
//SetNuiFocusKeepInput(true)
|
||||||
} else {
|
} else {
|
||||||
@@ -301,7 +290,6 @@ async function Phone() {
|
|||||||
data: true,
|
data: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
sendPhoneConfig();
|
|
||||||
SetNuiFocus(true, true);
|
SetNuiFocus(true, true);
|
||||||
//SetNuiFocusKeepInput(true)
|
//SetNuiFocusKeepInput(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user