Skip to content

Commit

Permalink
remove dest socket
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAdoniev committed Aug 28, 2023
1 parent 953e2df commit b8681c3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 58 deletions.
13 changes: 3 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,8 +72,6 @@ export const App = () => {
socket,
appData,
fetching,
scraperSocket,
destScraperSocket,
}}
>
<Routes>
Expand Down
8 changes: 4 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
};
};*/
14 changes: 5 additions & 9 deletions src/context/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface IEventsContext {

export const EventsContext = createContext<IEventsContext | null>(null);
export const EventsProvider: FC = withContainer(
({ children, container: { socket, scraperSocket, destScraperSocket } }) => {
({ children, container: { socket } }) => {
const [events, setEvents] = useState<IEvent[]>([]);
// console.log("🚀 ~ file: Events.tsx:39 ~ events:", events);
//const [chainName, setChainName] = useState("");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]);

Expand Down
69 changes: 34 additions & 35 deletions src/pages/errorHandler.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="cont">
<div className="ErrorContainer">
<div className="ErrorImage">
<img src={systemError} />
</div>
<div className="ErrorText">
<h1>OUCH!</h1>
<p>System Error.</p>
</div>
</div>
<div className="ErrorToolsContainer">
<Tools />
</div>
</div>
);
render() {
if (this.state.errorInfo) {
// Error path
return (
<div className="cont">
<div className="ErrorContainer">
<div className="ErrorImage">
<img src={systemError} />
</div>
<div className="ErrorText">
<h1>OUCH!</h1>
<p>System Error.</p>
</div>
</div>
<div className="ErrorToolsContainer">
<Tools />
</div>
</div>
);
}
return this.props.children;
}
return this.props.children;
}
}

0 comments on commit b8681c3

Please sign in to comment.