From 52df7bb4afcfb6dc930e59bb8d91d994f62f6d5d Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Mon, 7 Feb 2022 19:59:26 +0200 Subject: [PATCH] fix gateway server listener memory leak and add token importing to the frontend --- GatewayServer.js | 8 +- config.js | 2 +- frontend/public/global.css | 2 +- frontend/src/components/App.svelte | 157 +++++++++++++++-------- frontend/src/components/FuzzyView.svelte | 7 +- 5 files changed, 112 insertions(+), 64 deletions(-) diff --git a/GatewayServer.js b/GatewayServer.js index ee1e9ae..4b4b77f 100644 --- a/GatewayServer.js +++ b/GatewayServer.js @@ -26,7 +26,7 @@ class GatewayServer { this.onMessage(ws, data, isBinary); }); ws.on("close", (code, reason) => { - this.onDisconnect(code, reason.toString()); + this.onDisconnect(ws, code, reason.toString()); }); ws.on("pong", () => { this.onPong(ws); @@ -151,7 +151,7 @@ class GatewayServer { type: "ADD_HANDLER", handler: handle, guildId - }) + }); }); ws.send(JSON.stringify({ @@ -182,8 +182,8 @@ class GatewayServer { } } - onDisconnect(ws) { - if (ws.state && ws.state.handlers && ws.state.handlers.length > 0) { + onDisconnect(ws, code, reason) { + if (ws.state && ws.state.handlers) { for (const [guildId, handler] of ws.state.handlers.entries()) { const guild = guildMap.get(guildId); if (guild) { diff --git a/config.js b/config.js index 542f5e6..91a5f98 100644 --- a/config.js +++ b/config.js @@ -2,4 +2,4 @@ export const mainHttpListenPort = 4050; export const watchedGuildIds = ["822089558886842418"]; export const jwtSecret = process.env.JWT_SECRET; export const discordToken = process.env.DISCORD_TOKEN; -export const dangerousAdminMode = false; +export const dangerousAdminMode = true; diff --git a/frontend/public/global.css b/frontend/public/global.css index 15ad848..9b870d1 100644 --- a/frontend/public/global.css +++ b/frontend/public/global.css @@ -134,7 +134,7 @@ button:focus { } .main-panel-header { - font-size: 1.1em; + font-size: 1.2em; } .error-text { diff --git a/frontend/src/components/App.svelte b/frontend/src/components/App.svelte index 798d07f..67fbba2 100644 --- a/frontend/src/components/App.svelte +++ b/frontend/src/components/App.svelte @@ -1,7 +1,7 @@
- { title } + { title } {#each displayedElements as element, index} {#if index === 0}