mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
styling: Enforced styling across all files (#55)
This commit is contained in:
165 files changed
+1879
-1725
No files matched your search
@@ -1,6 +1,5 @@
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { eventNameFactory } from "../utils/nuiUtils";
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { eventNameFactory } from '../utils/nuiUtils';
|
||||
|
||||
interface IOptions {
|
||||
capture?: boolean;
|
||||
@@ -8,7 +7,12 @@ interface IOptions {
|
||||
once?: boolean;
|
||||
}
|
||||
|
||||
export const useNuiEvent = (app: any, method: any, handler: any, options: IOptions = {}) => {
|
||||
export const useNuiEvent = (
|
||||
app: any,
|
||||
method: any,
|
||||
handler: any,
|
||||
options: IOptions = {}
|
||||
) => {
|
||||
const savedHandler: any = useRef();
|
||||
const { capture, passive, once } = options;
|
||||
|
||||
@@ -18,7 +22,7 @@ export const useNuiEvent = (app: any, method: any, handler: any, options: IOptio
|
||||
|
||||
useEffect(() => {
|
||||
const eventName = eventNameFactory(app, method);
|
||||
const eventListener = (event: any ) => {
|
||||
const eventListener = (event: any) => {
|
||||
if (savedHandler.current && savedHandler.current.call) {
|
||||
const { data } = event;
|
||||
console.log(eventName, data);
|
||||
@@ -29,4 +33,4 @@ export const useNuiEvent = (app: any, method: any, handler: any, options: IOptio
|
||||
window.addEventListener(eventName, eventListener, opts);
|
||||
return () => window.removeEventListener(eventName, eventListener, opts);
|
||||
}, [app, method, capture, passive, once]);
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect } from "react";
|
||||
import { eventNameFactory } from "../utils/nuiUtils";
|
||||
import { useEffect } from 'react';
|
||||
import { eventNameFactory } from '../utils/nuiUtils';
|
||||
|
||||
interface IOptions {
|
||||
capture?: boolean;
|
||||
@@ -21,7 +21,7 @@ export const useNuiService = (options: IOptions = {}) => {
|
||||
};
|
||||
useEffect(() => {
|
||||
const opts = { capture, passive, once };
|
||||
window.addEventListener("message", eventListener, opts);
|
||||
return () => window.removeEventListener("message", eventListener, opts);
|
||||
window.addEventListener('message', eventListener, opts);
|
||||
return () => window.removeEventListener('message', eventListener, opts);
|
||||
}, [capture, passive, once]);
|
||||
};
|
||||
};
|
||||
@@ -3,9 +3,9 @@ export default {
|
||||
async send(event: any, data = {}) {
|
||||
/* eslint-disable no-unreachable */
|
||||
return fetch(`http://new-phone-who-dis/${event}`, {
|
||||
method: "post",
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=UTF-8",
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export const eventNameFactory = (app: any, method: any) => `${app}:${method}`;
|
||||
export const eventNameMethod = (name: any) => name.split(":")[1] || null;
|
||||
export const eventNameMethod = (name: any) => name.split(':')[1] || null;
|
||||
Reference in new issue
Block a user