mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Some tidy up
This commit is contained in:
parent
ae3ecefcf7
commit
c059d4c13d
@ -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);
|
||||
});
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user