From 1d4c771246951306d2db9c83f912ca486dfe0bd3 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Tue, 30 Jul 2024 13:23:18 -0500 Subject: [PATCH] fix reconnection bugs --- .dist/localuser.js | 2 ++ .dist/snowflake.js | 3 +++ .dist/user.js | 3 +++ webpage/localuser.ts | 2 ++ webpage/snowflake.ts | 5 ++++- webpage/user.ts | 3 +++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.dist/localuser.js b/.dist/localuser.js index 7e95b6d..3b8c59d 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -100,6 +100,8 @@ class Localuser { this.guilds = []; this.guildids = new Map(); this.ws.close(4001); + SnowFlake.clear(); + User.clear(); } async initwebsocket() { let returny = null; diff --git a/.dist/snowflake.js b/.dist/snowflake.js index 1e97301..6b7dd35 100644 --- a/.dist/snowflake.js +++ b/.dist/snowflake.js @@ -28,6 +28,9 @@ class SnowFlake { SnowFlake.FinalizationRegistry.register(this, [id, obj.constructor]); this.obj = obj; } + static clear() { + this.SnowFlakes = new Map(); + } /** * Just to clarify bc TS, it returns a SnowFlake\ which is what you entered with the type parameter * diff --git a/.dist/user.js b/.dist/user.js index 1403982..b676c35 100644 --- a/.dist/user.js +++ b/.dist/user.js @@ -54,6 +54,9 @@ class User { }); }); } + static clear() { + this.userids = {}; + } static checkuser(user, owner) { if (User.userids[user.id]) { return User.userids[user.id]; diff --git a/webpage/localuser.ts b/webpage/localuser.ts index f2e0ea1..7606107 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -106,6 +106,8 @@ class Localuser{ this.guilds=[]; this.guildids=new Map(); this.ws.close(4001) + SnowFlake.clear(); + User.clear(); } async initwebsocket():Promise{ let returny=null diff --git a/webpage/snowflake.ts b/webpage/snowflake.ts index 76c755f..f3042a0 100644 --- a/webpage/snowflake.ts +++ b/webpage/snowflake.ts @@ -1,6 +1,6 @@ class SnowFlake{ public readonly id:string; - private static readonly SnowFlakes:Map>>>=new Map(); + private static SnowFlakes:Map>>>=new Map(); private static readonly FinalizationRegistry=new FinalizationRegistry((a:[string,WeakKey])=>{ SnowFlake.SnowFlakes.get(a[1]).delete(a[0]); }); @@ -27,6 +27,9 @@ class SnowFlake{ SnowFlake.FinalizationRegistry.register(this,[id,obj.constructor]); this.obj=obj; } + static clear(){//this is kinda a temp solution, it should be fixed, though its not that easy to do so + this.SnowFlakes=new Map(); + } /** * Just to clarify bc TS, it returns a SnowFlake\ which is what you entered with the type parameter * diff --git a/webpage/user.ts b/webpage/user.ts index 4591e43..6460cb8 100644 --- a/webpage/user.ts +++ b/webpage/user.ts @@ -59,6 +59,9 @@ class User{ }); }) } + static clear(){ + this.userids={}; + } static checkuser(user:User|userjson,owner:Localuser):User{ if(User.userids[user.id]){ return User.userids[user.id];