From 62e2f0582adcafcf657acc36319cfa6f9bcaa986 Mon Sep 17 00:00:00 2001 From: Daniel Ferri Date: Thu, 6 May 2021 21:49:20 +0200 Subject: [PATCH] Fixed bug with faction invitations not getting deleted --- src/Faction/FactionHelpers.jsx | 9 +++++++++ src/engine.jsx | 6 ------ utils/FactionInvitationBox.js | 2 -- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Faction/FactionHelpers.jsx b/src/Faction/FactionHelpers.jsx index 2ceca238a..7c2abeca3 100644 --- a/src/Faction/FactionHelpers.jsx +++ b/src/Faction/FactionHelpers.jsx @@ -56,6 +56,15 @@ export function joinFaction(faction) { Factions[enemy].isBanned = true; } } + for (var i = 0; i < Player.factionInvitations.length; ++i) { + if (Player.factionInvitations[i] == faction.name || Factions[Player.factionInvitations[i]].isBanned) { + Player.factionInvitations.splice(i, 1); + i--; + } + } + if (routing.isOn(Page.Factions)) { + Engine.loadFactionsContent(); + } } export function startHackingMission(faction) { diff --git a/src/engine.jsx b/src/engine.jsx index c64141f2c..bfd4d761f 100644 --- a/src/engine.jsx +++ b/src/engine.jsx @@ -643,12 +643,6 @@ const Engine = { clickListener: (e) => { if (!e.isTrusted) { return false; } joinFaction(Factions[factionName]); - for (var i = 0; i < Player.factionInvitations.length; ++i) { - if (Player.factionInvitations[i] == factionName || Factions[Player.factionInvitations[i]].isBanned) { - Player.factionInvitations.splice(i, 1); - i--; - } - } Engine.displayFactionsInfo(); return false; }, diff --git a/utils/FactionInvitationBox.js b/utils/FactionInvitationBox.js index 8150def89..2d0a9b975 100644 --- a/utils/FactionInvitationBox.js +++ b/utils/FactionInvitationBox.js @@ -36,8 +36,6 @@ function factionInvitationBoxCreate(faction) { var i = Player.factionInvitations.findIndex((facName)=>{return facName === faction.name}); if (i === -1) { console.error("Could not find faction in Player.factionInvitations"); - } else { - Player.factionInvitations.splice(i, 1); } joinFaction(faction); factionInvitationBoxClose();