mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
feat(phone/debug): Added a global window dispatch method
See JSDocs for usage details.
This commit is contained in:
1 parent
622a931ace
commit
b6352ccf82
2 files changed
+35
No files matched your search
@@ -8,6 +8,7 @@ import { Integrations } from '@sentry/tracing';
|
||||
import './main.css';
|
||||
import PhoneConfig from './config/default.json';
|
||||
import { PhoneContainer } from './PhoneContainer';
|
||||
import attachMockNuiEvent from './os/debug/AttachMockNuiEvent';
|
||||
|
||||
// Enable Sentry when config setting is true
|
||||
if (PhoneConfig.SentryErrorMetrics) {
|
||||
@@ -21,6 +22,8 @@ if (PhoneConfig.SentryErrorMetrics) {
|
||||
});
|
||||
}
|
||||
|
||||
attachMockNuiEvent();
|
||||
|
||||
ReactDOM.render(
|
||||
<HashRouter>
|
||||
<RecoilRoot>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
function dispatchEvent({ method, app, data }: { method: string; app: string; data: unknown }) {
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent('message', {
|
||||
data: {
|
||||
app,
|
||||
method,
|
||||
data,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}, 200);
|
||||
}
|
||||
/**
|
||||
* Allows you to mock NUI data from your console by attaching
|
||||
* to the global window object
|
||||
* @example
|
||||
* mockNuiEvent({
|
||||
* app: 'NOTES',
|
||||
* method: 'setAlert',
|
||||
* data: {
|
||||
* message: 'CONTACT_ADD_SUCCESS',
|
||||
* type: 'success',
|
||||
* }
|
||||
* })
|
||||
**/
|
||||
const attachMockNuiEvent = () => {
|
||||
//@ts-ignore
|
||||
window.mockNuiEvent = dispatchEvent;
|
||||
};
|
||||
|
||||
export default attachMockNuiEvent;
|
||||
Reference in new issue
Block a user