diff --git a/web-svelte/src/components/modals/ShipDesigner.svelte b/web-svelte/src/components/modals/ShipDesigner.svelte index 83be1ba..795a3cd 100644 --- a/web-svelte/src/components/modals/ShipDesigner.svelte +++ b/web-svelte/src/components/modals/ShipDesigner.svelte @@ -21,24 +21,9 @@ var selectedColour = player.colour.hex; var selectedShip = player.ship.id; var error = null; -function designUpdate(data: any) {}; - -onMount(() => { - socket.on(`req:lobby.players.update`, designUpdate); - return () => { - socket.off(`req:lobby.players.update`); - }; -}); - -function saveShipDesign() { - /* TODO: Send event to server, wait for confirmation */ - let response: any = { - status: Status.UnknownError, - message: `Testing the error design`, - }; - - if (response.status != Status.Success) { - error = response.message; +function designUpdate(data: any) { + if (data.status != Status.Success) { + error = data.message; /* TODO (Maybe): If the list of colours doesn't auto-update the available @@ -57,6 +42,23 @@ function saveShipDesign() { emit(`close`); }; + +onMount(() => { + socket.on(`req:lobby.players.update`, designUpdate); + return () => { + socket.off(`req:lobby.players.update`); + }; +}); + +function saveShipDesign() { + /* TODO: Send event to server, wait for confirmation */ + let response: any = { + status: Status.UnknownError, + message: `Testing the error design`, + }; + + socket.emit(`req:lobby.players.update`, {}); +};