ElkArte Community

Title: [1.0.3] problems with likes
Post by: Jorin on March 31, 2015, 12:32:57 am
The last few days I wondered about messages that someone liked my post and disliked it then. But when I look at the post the like is still there. This happend twice till now.

As you can see at the attachments, the user "YarisFahrer" liked my post and disliked it at the same time. The post is still liked anyhow.

It seems sometimes a like is not removed from a post. Maybe there's a time limit between likes and dislikes?
Title: Re: [1.0.3] problems with likes
Post by: Spuds on March 31, 2015, 09:09:30 am
Interesting.

Its possible that since the requests are arriving at the same time (kind of), that there is a bit of contention as to which happens first.  If the unlike does not see the like in the db it may skip some actions (in updateLike). 

Not sure what to do about that, maybe we can add a delay in the button, or leave the like button disabled until it gets it ajax response back.
Title: Re: [1.0.3] problems with likes
Post by: emanuele on March 31, 2015, 09:14:37 am
Arg... race conditions! :P

I think I proposed a while ago a "are you sure you want to remove the like" kind of thing to avoid mistakenly removes of likes (my mouse has an odd click and it may fire two or three times with a single click depending on where and how I push the button LOL).
Title: Re: [1.0.3] problems with likes
Post by: Spuds on March 31, 2015, 09:24:11 am
Yup could add that as well, either would spread the two events farther apart and exponentially lower the race.  I think I may try it at first as a disabled button, which only re-enables when it gets the response.  We already have the indicator code in place so that should be easy and prevent a resend until the first response is back (or someone does a page load)
Title: Re: [1.0.3] problems with likes
Post by: emanuele on March 31, 2015, 10:06:06 am
Good then! ;D
Title: Re: [1.0.3] problems with likes
Post by: Jorin on March 31, 2015, 11:05:14 am
Like - like not - like - like not - LIKE! Sorry, my mouse button...  :D

No, just to be serious, it would be great to avoid this happening again. It happened twice in the last few weeks, and I did not know if this happens to other users of my board too. So it seems to happen often enough to take care about it. Thanks!
Title: Re: [1.0.3] problems with likes
Post by: Jorin on April 02, 2015, 04:43:22 am
Another one happened now. User liked my post a few hours ago, and now I got the message he disliked it. In the post he still is shown as "liked your post". So now it seems I have the problem with a few hours between the actions.  :o

Is there a way I can see when exactly the user liked and/or disliked my post?
Title: Re: [1.0.3] problems with likes
Post by: emanuele on April 02, 2015, 07:57:53 am
I don't think there is an interface for that, but you can go to phpmyadmin, the elkarte_log_likes, knowing the message id, you can search by "id_target" (that is the message id) and... id_member that is the member that liked your message. There you can see the action and the log time, feel free to post them here to "understand" what is going on. ;)
Title: Re: [1.0.3] problems with likes
Post by: Spuds on April 02, 2015, 09:27:42 am
Yeah, that blows my theory out of the water.  I could have seen a double click causing problems, but hours apart seems like a bug. Just to be sure the post liked count is wrong even after you refresh the page?
Title: Re: [1.0.3] problems with likes
Post by: emanuele on April 02, 2015, 09:56:59 am
From a quick test linking/unliking messages even very quickly and multiple times, here on my localhost I can't reproduce the behaviour...

WAIT A MOMENT!
I think I got it.
If you:
like
unlike
* like again
in the mentions the last message is the unlike, but the post is liked, because the last action is actually a like.
Why that? Because the message has already been liked, so the like mention is not repeated.
At least this is the idea behind the behaviour.

I don't find it wrong, but it may be worth during the "like" to search if there is any "unlike" and remove it (or make it invisible) so that it doesn't pop up anymore.
Title: Re: [1.0.3] problems with likes
Post by: Spuds on April 02, 2015, 07:02:33 pm
Great catch ... Yup, perhaps removing the unlike, or changing the like date/order so its newer would be the proper thing to do.
Title: Re: [1.0.3] problems with likes
Post by: emanuele on July 19, 2015, 12:02:14 pm
Tracked: https://github.com/elkarte/Elkarte/issues/2135
Title: Re: [1.0.3] problems with likes
Post by: emanuele on July 25, 2015, 05:31:13 pm
The "fix": https://github.com/emanuele45/Dialogo/commit/c1a273da2d3391b8600fa668049030305d1c6383
And the warning: https://github.com/elkarte/Elkarte/commit/1d26cf3d38a3ff745434e3f477560caaf4fc4888