From 410d32deceb2ca11d08265592acb1cc5495dd532 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 28 Jun 2020 14:44:47 -0700 Subject: [PATCH] Drop extra PromptOption state for not showing a specific prompt It was fun for me to learn about how to use the useState hook, but this only code path was only necessary for when I was not planning to distribute negative votes through the server to other clients. I ended up distributing that state after all, which has the benefit that hidden prompts stay hidden when reloading (and from one round to the next). [One potential downside is that hidden prompts are permanently hidden---they can't be made to appear again. Oh well!] And now that the server is telling us about the prompts we've already voted against, and we're already not dispalying those, we don't need the additional state here to hide things on the client side before we receive that notification from the server. --- empathy/empathy.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index ab45be9..12bedd2 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -366,10 +366,6 @@ class CategoryRequest extends React.PureComponent { const PromptOption = React.memo(props => { const prompt = props.prompt; - const [show_prompt, set_show_prompt] = React.useState(true); - - if (! show_prompt) - return false; if (prompt.votes_against.find(v => v === props.player.name)) return false; @@ -385,7 +381,6 @@ const PromptOption = React.memo(props => { onClick={(event) => { event.stopPropagation(); fetch_post_json(`vote_against/${prompt.id}`); - set_show_prompt(false); }} > × -- 2.43.0