1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Some tidy up

This commit is contained in:
Daniel Barber 2018-09-09 19:28:31 -04:00
parent ae3ecefcf7
commit c059d4c13d
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 15 additions and 9 deletions

View File

@ -24,7 +24,8 @@ class Channel {
}
join() {
this.channel.join()
this.channel
.join()
.receive("error", resp => {
console.log("Unable to join", resp);
});
@ -57,20 +58,24 @@ class Channel {
}
setOpponentStatus() {
this.store.dispatch(setOpponentStatus(
this.presences.opponentOnline(this.opponentId) ? "viewing" : "offline"
));
this.store.dispatch(
setOpponentStatus(
this.presences.opponentOnline(this.opponentId) ? "viewing" : "offline"
)
);
}
getAvailableMoves(square) {
this.channel.push("game:get_available_moves", { square })
.receive("ok", (data) => {
this.channel
.push("game:get_available_moves", { square })
.receive("ok", data => {
this.store.dispatch(setAvailableMoves(data.moves));
});
}
sendMove(move) {
this.channel.push("game:move", move)
this.channel
.push("game:move", move)
.receive("error", resp => {
alert(resp.message);
});

View File

@ -90,13 +90,14 @@ defmodule ChessWeb.GameChannel do
opponent(game, socket.assigns.user_id).id
|> Integer.to_string
send_update(socket)
"game:#{game.id}"
|> Presence.list
|> case do
%{^opponent_id => _} ->
send_update(socket)
nil
_ ->
send_update(socket)
socket
|> Emails.opponent_moved_email(game)
|> Mailer.deliver_later