mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(phone/apps): Apps will no longer call not existent endpoint
This commit is contained in:
1 parent
908e467011
commit
f54dc974a2
3 files changed
+28
-16
No files matched your search
@@ -2,12 +2,12 @@ import React from 'react';
|
|||||||
import { Route } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
import { AppWithStartup } from './AppWithStartup';
|
import { AppWithStartup } from './AppWithStartup';
|
||||||
|
|
||||||
export const AppRoute = ({ id, component: Component, ...rest }) => {
|
export const AppRoute = ({ id, emitOnOpen, component: Component, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<Route
|
<Route
|
||||||
{...rest}
|
{...rest}
|
||||||
render={() => (
|
render={() => (
|
||||||
<AppWithStartup id={id}>
|
<AppWithStartup id={id} emitOnOpen={emitOnOpen}>
|
||||||
<Component />
|
<Component />
|
||||||
</AppWithStartup>
|
</AppWithStartup>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { memo, useEffect } from 'react';
|
import { memo, useEffect } from 'react';
|
||||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||||
|
|
||||||
const Component = ({ children, id }) => {
|
const Component = ({ children, id, emitOnOpen }) => {
|
||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Nui.send(`npwd:app:${id}`);
|
if (emitOnOpen) Nui.send(`npwd:app:${id}`);
|
||||||
}, [Nui, id]);
|
}, [Nui, id, emitOnOpen]);
|
||||||
return children;
|
return children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: DIALER_APP_PRIMARY_COLOR,
|
backgroundColor: DIALER_APP_PRIMARY_COLOR,
|
||||||
color: DIALER_APP_TEXT_COLOR,
|
color: DIALER_APP_TEXT_COLOR,
|
||||||
path: '/phone',
|
path: '/phone',
|
||||||
Route: () => <AppRoute id="DIALER" path="/phone" component={DialerApp} />,
|
Route: () => <AppRoute id="DIALER" path="/phone" component={DialerApp} emitOnOpen={false} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'MESSAGES',
|
id: 'MESSAGES',
|
||||||
@@ -67,7 +67,9 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: MESSAGES_APP_PRIMARY_COLOR,
|
backgroundColor: MESSAGES_APP_PRIMARY_COLOR,
|
||||||
color: MESSAGES_APP_TEXT_COLOR,
|
color: MESSAGES_APP_TEXT_COLOR,
|
||||||
path: '/messages',
|
path: '/messages',
|
||||||
Route: () => <AppRoute id="MESSAGES" path="/messages" component={MessagesApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="MESSAGES" path="/messages" component={MessagesApp} emitOnOpen={true} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'CONTACTS',
|
id: 'CONTACTS',
|
||||||
@@ -75,7 +77,9 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: CONTACTS_APP_PRIMARY_COLOR,
|
backgroundColor: CONTACTS_APP_PRIMARY_COLOR,
|
||||||
color: CONTACTS_APP_TEXT_COLOR,
|
color: CONTACTS_APP_TEXT_COLOR,
|
||||||
path: '/contacts',
|
path: '/contacts',
|
||||||
Route: () => <AppRoute id="CONTACTS" path="/contacts" component={ContactsApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="CONTACTS" path="/contacts" component={ContactsApp} emitOnOpen={false} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'CALCULATOR',
|
id: 'CALCULATOR',
|
||||||
@@ -83,7 +87,9 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: purple[500],
|
backgroundColor: purple[500],
|
||||||
color: grey[50],
|
color: grey[50],
|
||||||
path: '/calculator',
|
path: '/calculator',
|
||||||
Route: () => <AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} emitOnOpen={false} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'SETTINGS',
|
id: 'SETTINGS',
|
||||||
@@ -91,7 +97,9 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: '#383838',
|
backgroundColor: '#383838',
|
||||||
color: grey[50],
|
color: grey[50],
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
Route: () => <AppRoute id="SETTINGS" path="/settings" component={SettingsApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="SETTINGS" path="/settings" component={SettingsApp} emitOnOpen={false} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
/* Hiding the bank app while the bank resource gets done */
|
/* Hiding the bank app while the bank resource gets done */
|
||||||
/*{
|
/*{
|
||||||
@@ -108,7 +116,7 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: MATCH_APP_PRIMARY_COLOR,
|
backgroundColor: MATCH_APP_PRIMARY_COLOR,
|
||||||
color: MATCH_APP_TEXT_COLOR,
|
color: MATCH_APP_TEXT_COLOR,
|
||||||
path: '/match',
|
path: '/match',
|
||||||
Route: () => <AppRoute id="MATCH" path="/match" component={MatchApp} />,
|
Route: () => <AppRoute id="MATCH" path="/match" component={MatchApp} emitOnOpen={true} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'TWITTER',
|
id: 'TWITTER',
|
||||||
@@ -116,7 +124,7 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: TWITTER_APP_PRIMARY_COLOR,
|
backgroundColor: TWITTER_APP_PRIMARY_COLOR,
|
||||||
color: TWITTER_APP_TEXT_COLOR,
|
color: TWITTER_APP_TEXT_COLOR,
|
||||||
path: '/twitter',
|
path: '/twitter',
|
||||||
Route: () => <AppRoute id="TWITTER" path="/twitter" component={TwitterApp} />,
|
Route: () => <AppRoute id="TWITTER" path="/twitter" component={TwitterApp} emitOnOpen={true} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'SELLOUT',
|
id: 'SELLOUT',
|
||||||
@@ -124,7 +132,9 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
|
backgroundColor: SELLOUT_APP_PRIMARY_COLOR,
|
||||||
color: SELLOUT_APP_ICON_COLOR,
|
color: SELLOUT_APP_ICON_COLOR,
|
||||||
path: '/marketplace',
|
path: '/marketplace',
|
||||||
Route: () => <AppRoute id="MARKETPLACE" path="/marketplace" component={MarketplaceApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="MARKETPLACE" path="/marketplace" component={MarketplaceApp} emitOnOpen={true} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'NOTES',
|
id: 'NOTES',
|
||||||
@@ -132,7 +142,7 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: NOTES_APP_PRIMARY_COLOR,
|
backgroundColor: NOTES_APP_PRIMARY_COLOR,
|
||||||
color: NOTES_APP_ICON_COLOR,
|
color: NOTES_APP_ICON_COLOR,
|
||||||
path: '/notes',
|
path: '/notes',
|
||||||
Route: () => <AppRoute id="NOTES" path="/notes" component={NotesApp} />,
|
Route: () => <AppRoute id="NOTES" path="/notes" component={NotesApp} emitOnOpen={true} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'CAMERA',
|
id: 'CAMERA',
|
||||||
@@ -140,7 +150,7 @@ export const APPS: IAppConfig[] = [
|
|||||||
backgroundColor: grey['A400'],
|
backgroundColor: grey['A400'],
|
||||||
color: common.white,
|
color: common.white,
|
||||||
path: '/camera',
|
path: '/camera',
|
||||||
Route: () => <AppRoute id="CAMERA" path="/camera" component={CameraApp} />,
|
Route: () => <AppRoute id="CAMERA" path="/camera" component={CameraApp} emitOnOpen={true} />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -152,6 +162,8 @@ if (process.env.NODE_ENV === 'development') {
|
|||||||
backgroundColor: blue[500],
|
backgroundColor: blue[500],
|
||||||
color: blue[50],
|
color: blue[50],
|
||||||
path: '/example',
|
path: '/example',
|
||||||
Route: () => <AppRoute id="EXAMPLE" path="/example" component={ExampleApp} />,
|
Route: () => (
|
||||||
|
<AppRoute id="EXAMPLE" path="/example" component={ExampleApp} emitOnOpen={false} />
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user