Reactions sometimes not displayed when like count is missing

@JammyDodger noticed that he wasn’t able to see the reactions on this post on mobile: ToS and Privacy buttons disappear from /about when I remove my custom FAQ URL - #3 by Canapin [example1]

Jammy (mobile) - No reactions:

Jammy (desktop) - Reactions on the left, but not on the right:

Everyone else - You can see he has reacted, everything works as expected:

After searching through my reaction activity, I found an example where the problem occurs for me: Admins may not realize certain sidebar customization are global - #8 by JammyDodger [example2]

What both posts have in common is that there are reactions, but the number of likes does not appear to be available as the count in the actions_summary.

Depending on if you reacted on the post yourself or not, id: 2 is either missing in the actions_summary, or if you haven’t reacted you can see that the count is missing. If I understand correctly, id: 2 is included if either you could react (can_act) or count>0.

Taking a closer look at the json of the post example2 https://meta.discourse.org/posts/1404583.json where two users reacted, this count is missing:

User who hasn’t reacted
can_act true
User who has reacted
no id 2

In this case, the count: 2 is missing for both users. For the user who has already reacted this results in id: 2 missing completely. This seems to explain why reactions are not shown for the user who reacted, even though reactions exist.

For comparison, here is a post with two reactions where the count is shown as expected Buttons to order items in emoji list settings is difficult to find on touch devices - #2 by zogstrip and the post’s json https://meta.discourse.org/posts/1907506.json

User who hasn’t reacted
can_act true
User who has reacted
acted true

On this post the count is available and the reactions appear as expected.

I have no idea how many posts here on Meta are affected by this or whether other forums are also affected. And I can’t provide any steps on why the data is missing. I can only report that for some posts, the reactions are not displayed on mobile phones and are only partially displayed on laptops, and the cause for this seems to be related to the missing data.

5 Likes

Started investigating, here’s a WIP fix

1 Like

Were you able to find out how this happened? I only found examples from 2023 and the beginning of 2024. So I wondered if something with the data before all reactions were counted as likes is different than after that change.
So I tried what happens if I use a reaction that is excluded from counting as a like, but then “can_act” is still true even if “can_undo” for current_user_reaction is false.

That’s because discourse_reactions_like_sync_enabled is set to false. This was done intentionally by the migration from May 2024 to avoid disrupting existing data.

When this setting is disabled, the ReactionLikeSynchronizer doesn’t run. This synchronizer is responsible for:

  • Creating PostAction (like) records for reactions
  • Updating posts.like_count to reflect reactions

Without the sync running:

  1. Reactions exist in discourse_reactions_reaction_users
  2. But there are no corresponding PostAction records
  3. And posts.like_count remains at 0

Your intuition about the timing is spot on - the posts from 2023/early 2024 had reactions added when this sync wasn’t active, so their like_count was never updated. The old serializer logic then omitted the like action entirely when both count = 0 AND can_act = false (undo window expired).

The fix doesn’t correct the underlying data discrepancy - it simply ensures the UI displays reactions correctly even when the PostAction/like_count data isn’t synced. On sites where discourse_reactions_like_sync_enabled = false, reactions existing independently from PostAction records is expected behavior.

1 Like

This topic was automatically closed after 20 hours. New replies are no longer allowed.