X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=empathy%2Fempathy.jsx;h=54d6c2660975aac30c9376ba05cff1c4feef3048;hp=b03d697ef1cfd2561ffc1b223d4939e3b616fa4a;hb=3c2c043c4a6e389a597736c9fd366b716ac7237c;hpb=ae931528b06e796b57147b974b669e980b18c51f diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index b03d697..54d6c26 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -55,9 +55,7 @@ events.addEventListener("player-update", event => { events.addEventListener("game-state", event => { const state = JSON.parse(event.data); - for (let prompt of state.prompts) { - window.game.add_or_update_prompt(prompt); - } + window.game.set_prompts(state.prompts); window.game.set_active_prompt(state.active_prompt); @@ -436,6 +434,12 @@ class Game extends React.PureComponent { }); } + set_prompts(prompts) { + this.setState({ + prompts: prompts + }); + } + add_or_update_prompt(prompt) { const prompts_copy = [...this.state.prompts]; const idx = prompts_copy.findIndex(p => p.id === prompt.id);