mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
my mistake lol
This commit is contained in:
1 parent
f7b8517155
commit
79c29c3f7e
4 files changed
+10
-13
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { eventNameFactory } from "../utils/nuiUtils";
|
import { eventNameFactory } from "../utils/nuiUtils";
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@ interface IOptions {
|
|||||||
once?: boolean;
|
once?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useNuiEvent = (app, method, handler, options: IOptions = {}) => {
|
export const useNuiEvent = (app: any, method: any, handler: any, options: IOptions = {}) => {
|
||||||
const savedHandler: any = useRef();
|
const savedHandler: any = useRef();
|
||||||
const { capture, passive, once } = options;
|
const { capture, passive, once } = options;
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ export const useNuiEvent = (app, method, handler, options: IOptions = {}) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const eventName = eventNameFactory(app, method);
|
const eventName = eventNameFactory(app, method);
|
||||||
const eventListener = (event) => {
|
const eventListener = (event: any ) => {
|
||||||
if (savedHandler.current && savedHandler.current.call) {
|
if (savedHandler.current && savedHandler.current.call) {
|
||||||
const { data } = event;
|
const { data } = event;
|
||||||
console.log(eventName, data);
|
console.log(eventName, data);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ interface IOptions {
|
|||||||
|
|
||||||
export const useNuiService = (options: IOptions = {}) => {
|
export const useNuiService = (options: IOptions = {}) => {
|
||||||
const { capture, passive, once } = options;
|
const { capture, passive, once } = options;
|
||||||
const eventListener = (event) => {
|
const eventListener = (event: any) => {
|
||||||
const { app, method, data } = event.data;
|
const { app, method, data } = event.data;
|
||||||
if (app && method && data !== undefined) {
|
if (app && method && data !== undefined) {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
|
// eslint-disable-next-line
|
||||||
export default {
|
export default {
|
||||||
async send(event, data = {}) {
|
async send(event: any, data = {}) {
|
||||||
// /// #if DEBUG
|
|
||||||
//return new Promise(resolve => setTimeout(resolve, 100));
|
|
||||||
// /// #endif
|
|
||||||
|
|
||||||
/* eslint-disable no-unreachable */
|
/* eslint-disable no-unreachable */
|
||||||
return fetch(`http://new-phone-who-dis/${event}`, {
|
return fetch(`http://or-ambumdt/${event}`, {
|
||||||
method: "post",
|
method: "post",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-type": "application/json; charset=UTF-8",
|
"Content-Type": "application/json; charset=UTF-8",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
/* eslint-enable no-unreachable */
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
export const eventNameFactory = (app, method) => `${app}:${method}`;
|
export const eventNameFactory = (app: any, method: any) => `${app}:${method}`;
|
||||||
export const eventNameMethod = (name) => name.split(":")[1] || null;
|
export const eventNameMethod = (name: any) => name.split(":")[1] || null;
|
||||||
Reference in new issue
Block a user