]> git.cworth.org Git - lmno.games/commitdiff
Drop extra PromptOption state for not showing a specific prompt
authorCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 21:44:47 +0000 (14:44 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 21:44:47 +0000 (14:44 -0700)
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

index ab45be913f109e782349529af805f8edd82105e1..12bedd2f3ace02801b9652ba5295445e0596ed1c 100644 (file)
@@ -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);
         }}
       >
         &times;