fix leaving in wait

This commit is contained in:
Daniel Bulant 2023-01-20 20:00:05 +01:00
parent df026dd466
commit b92ec82d4e
2 changed files with 8 additions and 2 deletions

View file

@ -1,12 +1,12 @@
<script>
import { quadOut } from "svelte/easing";
import { fly } from "svelte/transition";
import { room } from "./websocket";
import { connection, room } from "./websocket";
const duration = 400;
</script>
<a href="/multiplayer" class="arrow-back fixed top-0 left-0 w-4 h-4 m-4 p-2 transform transition-transform hover:-translate-x-1">
<a on:click={() => { $connection?.leave() }} href="/multiplayer" class="arrow-back fixed top-0 left-0 w-4 h-4 m-4 p-2 transform transition-transform hover:-translate-x-1">
<svg width="16" height="16">
<line y1="50%" x1="0" y2="50%" x2="100%" stroke="currentColor" stroke-width="2" />
<line y1="50%" x1="0" y2="100%" x2="50%" stroke="currentColor" stroke-width="2" />

View file

@ -179,6 +179,12 @@ export class WebsocketConnection extends EventTarget {
}
leave() {
connection.set(null);
room.set(null);
messages.set([]);
gameData.set(null);
listLoading.set(false);
list.set(null);
this.ws.close();
}
}