From 7d0a6084c58b867d9d7b7d671398670e5252b094 Mon Sep 17 00:00:00 2001
From: Dennis Postma <dennis@directonline.io>
Date: Tue, 10 Sep 2024 14:19:04 +0200
Subject: [PATCH] Race condition maybe?

---
 src/stores/game.ts | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/stores/game.ts b/src/stores/game.ts
index 069890b..3ed1137 100644
--- a/src/stores/game.ts
+++ b/src/stores/game.ts
@@ -62,11 +62,11 @@ export const useGameStore = defineStore('game', {
       })
     },
     disconnectSocket() {
-      if (!this.connection) return
+      if (this.connection) this.connection.disconnect()
 
-      this.connection.disconnect()
+      useCookies().remove('token')
+      
       this.connection = null
-
       this.token = null
       this.user = null
       this.character = null
@@ -74,8 +74,6 @@ export const useGameStore = defineStore('game', {
       this.isMovingCamera = false
       this.isChatOpen = false
       this.isUserPanelOpen = false
-
-      useCookies().remove('token')
     }
   }
 })