How do you check if a user has already voted in a specific field in mit app inventor?

I am trying to create a news app with mit app inventor on which only the owner can post the news and it stores the news in firebase database for all users to see it and below that I am adding a like, dislike section but every user is able to like or dislike multiple times. But I want a single user to vote a single time either on like or dislike. I am also using an extension for the user to sign in with his/her google account so I thought I can solve it with the google account like by fetching the user email and checking if this user has already voted or not but i am not able to implement this. please help

(Here are some pics related to my doubt)
Screenshot (32)

Screenshot (34)

Here's what you could do: you could disable the buttons once you like or dislike; however, you won't be able to unlike the post. Instead, you could do this:
Add 2 invisible buttons: Unlike, and un-dislike (not really a word, but I guess it should do :sweat_smile: )
So, whenever you click on the like button, it will be hidden, the dislike button can be disabled, and, the unlike button will appear.
If the dislike button is pressed, you can hide it, the like button can be disabled, and the un-dislike button can be shown instead.
Here's how the code will look:


Edit: Sorry about the small size, I can't do anything about it :expressionless:

1 Like

thank you very much I am implementing it in my app hope it will work. Thanks again

1 Like

I would simply do it in the database with integers:

  1. Default value 0 - User hasn't voted
  2. value 1 - User has voted like
  3. value 2 - User has voted dislike

On upload of vote, value is only changed if it is currently the default value of zero.

1 Like

thanks that is a great idea too

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.