diff --git a/phone/package.json b/phone/package.json
index 1362c55..cc566e6 100644
--- a/phone/package.json
+++ b/phone/package.json
@@ -43,6 +43,7 @@
"@types/react": "^16.9.51",
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.7",
+ "@welldone-software/why-did-you-render": "^6.1.1",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
"cp-cli": "^2.0.0",
"cross-env": "^7.0.2",
diff --git a/phone/src/os/apps/components/AppWithStartup.tsx b/phone/src/os/apps/components/AppWithStartup.tsx
index 6a529f1..43de431 100644
--- a/phone/src/os/apps/components/AppWithStartup.tsx
+++ b/phone/src/os/apps/components/AppWithStartup.tsx
@@ -1,10 +1,14 @@
-import { useEffect } from 'react';
+import { memo, useEffect } from 'react';
import { useNuiRequest } from 'fivem-nui-react-lib';
-export const AppWithStartup = ({ children, id }) => {
+const Component = ({ children, id }) => {
const Nui = useNuiRequest();
useEffect(() => {
Nui.send(`npwd:app:${id}`);
}, [Nui, id]);
return children;
};
+
+const AppWithStartup = memo(Component, () => true);
+
+export { AppWithStartup };
diff --git a/phone/src/os/apps/config/apps.tsx b/phone/src/os/apps/config/apps.tsx
index 58e0646..4f15e03 100644
--- a/phone/src/os/apps/config/apps.tsx
+++ b/phone/src/os/apps/config/apps.tsx
@@ -67,7 +67,7 @@ export const APPS: IAppConfig[] = [
backgroundColor: MESSAGES_APP_PRIMARY_COLOR,
color: MESSAGES_APP_TEXT_COLOR,
path: '/messages',
- Route: () => ,
+ Route: () => ,
},
{
id: 'CONTACTS',
diff --git a/phone/src/os/call/components/CallNotification.tsx b/phone/src/os/call/components/CallNotification.tsx
index 579df16..28abb22 100644
--- a/phone/src/os/call/components/CallNotification.tsx
+++ b/phone/src/os/call/components/CallNotification.tsx
@@ -2,11 +2,6 @@ import React from 'react';
import { Box, makeStyles } from '@material-ui/core';
import { CallControls } from './CallControls';
-// interface ICallNotificationProps {
-// onAccept(): void;
-// onReject(): void;
-// }
-
const useStyles = makeStyles((theme) => ({
root: {
paddingBottom: '48px',
diff --git a/phone/src/os/keyboard/hooks/useKeyboardService.ts b/phone/src/os/keyboard/hooks/useKeyboardService.ts
index 7834a15..526cac4 100644
--- a/phone/src/os/keyboard/hooks/useKeyboardService.ts
+++ b/phone/src/os/keyboard/hooks/useKeyboardService.ts
@@ -49,15 +49,14 @@ const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
export const useKeyboardService = () => {
const history = useHistory();
const { closePhone } = usePhone();
- const getters = {
- ArrowRight: useRecoilValue(keyboardState.ArrowRight),
- ArrowLeft: useRecoilValue(keyboardState.ArrowLeft),
- ArrowUp: useRecoilValue(keyboardState.ArrowUp),
- ArrowDown: useRecoilValue(keyboardState.ArrowDown),
- Backspace: useRecoilValue(keyboardState.Backspace),
- Enter: useRecoilValue(keyboardState.Enter),
- Escape: useRecoilValue(keyboardState.Escape),
- };
+
+ const ArrowRight = useRecoilValue(keyboardState.ArrowRight);
+ const ArrowLeft = useRecoilValue(keyboardState.ArrowLeft);
+ const ArrowUp = useRecoilValue(keyboardState.ArrowUp);
+ const ArrowDown = useRecoilValue(keyboardState.ArrowDown);
+ const Backspace = useRecoilValue(keyboardState.Backspace);
+ const Enter = useRecoilValue(keyboardState.Enter);
+ const Escape = useRecoilValue(keyboardState.Escape);
const handlers = useRef(new Map());
const setEscape = useSetRecoilState(keyboardState.Escape);
@@ -65,28 +64,29 @@ export const useKeyboardService = () => {
useEffect(
function registerCustomKeys() {
- Object.keys(getters).forEach((g) => {
- handlers.current.set(g, getters[g]);
- });
+ handlers.current.set('ArrowRight', ArrowRight);
+ handlers.current.set('ArrowLeft', ArrowLeft);
+ handlers.current.set('ArrowUp', ArrowUp);
+ handlers.current.set('ArrowDown', ArrowDown);
+ handlers.current.set('Backspace', Backspace);
+ handlers.current.set('Enter', Enter);
+ handlers.current.set('Escape', Escape);
},
- [getters],
+ [ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Backspace, Enter, Escape],
);
- useEffect(
- function handleNUIKeyboardMessage() {
- function onKeyUp(event) {
- const { key } = event;
- const callback = handlers.current.get(key);
- if (isKeyValid(key) && callback && callback.call) {
- return callback(event);
- }
+ useEffect(function handleNUIKeyboardMessage() {
+ function onKeyUp(event) {
+ const { key } = event;
+ const callback = handlers.current.get(key);
+ if (isKeyValid(key) && callback && callback.call) {
+ return callback(event);
}
+ }
- window.addEventListener('keyup', onKeyUp);
- return () => window.removeEventListener('keyup', onKeyUp);
- },
- [getters],
- );
+ window.addEventListener('keyup', onKeyUp);
+ return () => window.removeEventListener('keyup', onKeyUp);
+ }, []);
const backspaceHandler = useCallback(
(event) => {
diff --git a/phone/src/wdyr.ts b/phone/src/wdyr.ts
new file mode 100644
index 0000000..a9016ad
--- /dev/null
+++ b/phone/src/wdyr.ts
@@ -0,0 +1,9 @@
+///
+import React from 'react';
+
+if (process.env.NODE_ENV === 'development') {
+ const whyDidYouRender = require('@welldone-software/why-did-you-render');
+ whyDidYouRender(React, {
+ trackAllPureComponents: true,
+ });
+}
diff --git a/phone/yarn.lock b/phone/yarn.lock
index f874455..ba3d6c3 100644
--- a/phone/yarn.lock
+++ b/phone/yarn.lock
@@ -2381,6 +2381,13 @@
"@webassemblyjs/wast-parser" "1.9.0"
"@xtuc/long" "4.2.2"
+"@welldone-software/why-did-you-render@^6.1.1":
+ version "6.1.1"
+ resolved "https://registry.yarnpkg.com/@welldone-software/why-did-you-render/-/why-did-you-render-6.1.1.tgz#3dcf66620fcafbf79e5260bd6ace5e51254055ac"
+ integrity sha512-BMFp33T4MC27qvCWsI1SqwZCxIlxoQXsPQFdGLDsPSg7sgoWX4Gzj0+hlKVrWrCBiIxi7gP2JcS9IK6CZzk8mg==
+ dependencies:
+ lodash "^4"
+
"@wojtekmaj/enzyme-adapter-react-17@^0.6.1":
version "0.6.1"
resolved "https://registry.yarnpkg.com/@wojtekmaj/enzyme-adapter-react-17/-/enzyme-adapter-react-17-0.6.1.tgz#28caa37118c183e5f13c4dfb68cc32cde828ecbc"
@@ -7672,7 +7679,7 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
-"lodash@>=3.5 <5", lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.5:
+"lodash@>=3.5 <5", lodash@^4, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.5:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==