HabitRPG / habitica-chat-extension

A habitica.com Chat Client for Chrome
18 stars 13 forks source link

likes count inaccurate (possibly `false` likes are displayed as if they were `true` likes) #47

Closed Alys closed 4 years ago

Alys commented 4 years ago

Aerilita posted in the Report a Bug guild: "My post appears void of likes on the website, but with a +1 via the chat extension." screenshot

I haven't looked at the extension's code, but my guess would be that it's treating false likes in the same way as true ones. I.e., when someone clicks the like button on a post, their plus-one is recorded in the message like this:

{
    "_id": "abcdefg1-2d2f-4f72-8bf6-abcdefgabcde",
    "text": "post goes here",
    "likes": {
        "12345678-6267-4e87-b989-123412345678": true
    },
    ...
}

But if they change their mind and click like again to remove their plus-one, the data in the message changes to this:

{
    "_id": "abcdefg1-2d2f-4f72-8bf6-abcdefgabcde",
    "text": "post goes here",
    "likes": {
        "12345678-6267-4e87-b989-123412345678": false
    },
    ...
}

If the extension is counting items in the likes object without checking if they're true or false, that would explain what Aerlita noticed. I suspect this is what's happening in the extension because exactly that bug appears in a chat tool that I wrote for myself. :)

benjaminbhollon commented 4 years ago

@Alys I checked, that's what's happening. I'll take a look at fixing that.