From b8681c3b52793010c6477c7a4d33738b6a177336 Mon Sep 17 00:00:00 2001 From: AlexeyAdoniev Date: Mon, 28 Aug 2023 11:09:47 +0300 Subject: [PATCH] remove dest socket --- src/App.tsx | 13 ++------ src/constants.ts | 8 ++--- src/context/Events.tsx | 14 +++----- src/pages/errorHandler.js | 69 +++++++++++++++++++-------------------- 4 files changed, 46 insertions(+), 58 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c3f197bd..4c0d698f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,23 +9,18 @@ import io from "socket.io-client"; import { useEffect, useState } from "react"; import "./components/ChainModal/Chain.css"; -import { - socketUrl, - url, - scraperSocketUrl, - destScraperSocketUrl, -} from "./constants"; +import { socketUrl, url } from "./constants"; import { handleGoogleAnalyticsPageView } from "./GA4"; const socket = io(socketUrl, { path: "/socket.io", }); -const scraperSocket = io(scraperSocketUrl, { +/*const scraperSocket = io(scraperSocketUrl, { path: "/socket.io", }); const destScraperSocket = io(destScraperSocketUrl, { path: "/socket.io", -}); +});*/ interface AppData { totalTx: number; totalWallets: number; @@ -77,8 +72,6 @@ export const App = () => { socket, appData, fetching, - scraperSocket, - destScraperSocket, }} > diff --git a/src/constants.ts b/src/constants.ts index aae83a9e..f0679941 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -246,15 +246,15 @@ export const chains = [ export const url = "https://dev-explorer-api.herokuapp.com/"; export const socketUrl = "wss://dev-explorer-api.herokuapp.com/"; -export const scraperSocketUrl = "wss://explorer-scraper.herokuapp.com/"; -export const destScraperSocketUrl = "wss://dest-scraper.herokuapp.com/"; +//export const scraperSocketUrl = "wss://explorer-scraper.herokuapp.com/"; +//export const destScraperSocketUrl = "wss://dest-scraper.herokuapp.com/"; // export const url = "http://localhost:3100/"; //export const socketUrl = "ws://localhost:3100"; -export const setTelegram = async (destination: string, error: any) => { +/*export const setTelegram = async (destination: string, error: any) => { // console.log("got here") await axios.get( `https://api.telegram.org/bot5434178910:AAF7EpfcDyvsLG_pAIv-SXVRU6bYBqjlqKo/sendMessage?chat_id=-721145192&text=Error on ${destination} , Message : ${error}&parse_mode=HTML` ); -}; +};*/ diff --git a/src/context/Events.tsx b/src/context/Events.tsx index d481ca1e..96f6020b 100644 --- a/src/context/Events.tsx +++ b/src/context/Events.tsx @@ -34,7 +34,7 @@ interface IEventsContext { export const EventsContext = createContext(null); export const EventsProvider: FC = withContainer( - ({ children, container: { socket, scraperSocket, destScraperSocket } }) => { + ({ children, container: { socket } }) => { const [events, setEvents] = useState([]); // console.log("🚀 ~ file: Events.tsx:39 ~ events:", events); //const [chainName, setChainName] = useState(""); @@ -66,11 +66,11 @@ export const EventsProvider: FC = withContainer( socket.off("incomingEvent"); socket.off("updateEvent"); - scraperSocket.off("incomingEvent"); + /*scraperSocket.off("incomingEvent"); scraperSocket.off("updateEvent"); destScraperSocket.off("incomingEvent"); - destScraperSocket.off("updateEvent"); + destScraperSocket.off("updateEvent");*/ socket.on("incomingEvent", async (event: IEvent) => { if (!event) return; @@ -116,7 +116,7 @@ export const EventsProvider: FC = withContainer( console.log("disconnect!!!!!"); }); - scraperSocket.on("incomingEvent", async (event: IEvent) => { + /*scraperSocket.on("incomingEvent", async (event: IEvent) => { console.log("scraperSocket-Incoming Event!!", event); if (eventsQueryString) return; try { @@ -175,15 +175,11 @@ export const EventsProvider: FC = withContainer( ...events.slice(idx + 1), ]); //updateEvent } - }); + });*/ return () => { socket.off("incomingEvent"); socket.off("updateEvent"); - scraperSocket.off("incomingEvent"); - scraperSocket.off("updateEvent"); - destScraperSocket.off("updateEvent"); - destScraperSocket.off("updateEvent"); }; }, [events]); diff --git a/src/pages/errorHandler.js b/src/pages/errorHandler.js index d60672f5..55bb6d31 100644 --- a/src/pages/errorHandler.js +++ b/src/pages/errorHandler.js @@ -1,44 +1,43 @@ import React from "react"; -import { setTelegram } from "../constants"; + import systemError from "../assets/img/systemError.png"; import { Tools } from "../components/Tools"; export class ErrorBoundary extends React.Component { - constructor(props) { - super(props); - this.state = { error: null, errorInfo: null }; - } + constructor(props) { + super(props); + this.state = { error: null, errorInfo: null }; + } - componentDidCatch(error, errorInfo) { - // Catch errors in any components below and re-render with error message - this.setState({ - error: error, - errorInfo: errorInfo, - }); - // You can also log error messages to an error reporting service here - } + componentDidCatch(error, errorInfo) { + // Catch errors in any components below and re-render with error message + this.setState({ + error: error, + errorInfo: errorInfo, + }); + // You can also log error messages to an error reporting service here + } - render() { - if (this.state.errorInfo) { - setTelegram("errorHandler.js", this.state.errorInfo.componentStack); - // Error path - return ( -
-
-
- -
-
-

OUCH!

-

System Error.

-
-
-
- -
-
- ); + render() { + if (this.state.errorInfo) { + // Error path + return ( +
+
+
+ +
+
+

OUCH!

+

System Error.

+
+
+
+ +
+
+ ); + } + return this.props.children; } - return this.props.children; - } }