Skip to content

Commit

Permalink
fix #182 clear up dead battles
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazcash committed Apr 3, 2023
1 parent 1faee87 commit a518146
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/renderer/views/multiplayer/custom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,21 @@ async function updateBattleList() {
await api.comms.request("c.user.list_users_from_ids", { id_list: userIds, include_clients: true });
for (const lobby of lobbies) {
let battle = api.session.battles.get(lobby.lobby.id);
const battle = api.session.battles.get(lobby.lobby.id);
if (!battle) {
api.session.battles.set(lobby.lobby.id, new SpadsBattle(lobby));
} else {
battle.handleServerResponse(lobby);
}
}
// clear up dead battles
const lobbyIds = lobbies.map((lobby) => lobby.lobby.id);
api.session.battles.forEach((battle) => {
if (!lobbyIds.includes(battle.battleOptions.id)) {
api.session.battles.delete(battle.battleOptions.id);
}
});
}
async function attemptJoinBattle(battle: SpadsBattle) {
Expand Down

0 comments on commit a518146

Please sign in to comment.