When liking a post, expanded likes vanishes

AI-generated summary

The issue involves the expanded likes panel disappearing when a user likes a post or when anyone else likes it while the panel is open, causing confusion. sam outlines the problem and proposes three potential fixes: expanding triggerChangedPost (messy), introducing triggerActedPost (cleaner), or embedding user data in the message bus payload (tricky due to security). codinghorror questions the effort for a rare edge case, but sam argues it’s worth addressing alongside planned technical debt cleanup by @eviltrout. blake notes that appending the user to the post already works as expected — suggesting the core functionality isn’t broken, but the UI state management during real-time updates is flawed. The focus remains on improving the reconciliation logic to preserve the expanded likes panel during post actions.

Repro:

  • Expand likes on a post
  • Like the post
  • Panel with likers disappears

Expected:

User is appended to post.


More severe side effect, if anyone likes a post while you have likes expanded, the expansion will vanish making you think UI is broke.


What needs fixing?

We already subscribe to the “acted” message so we know when post actions happen. postStream only has the very coarse “triggerChangedPost” which does a huge amount of reconciliation.

So we either need:

  • To expand triggerChangedPost to reconcile expanded likes. This is messy cause 1 message from message bus, 1 XHR to get post, 1 extra XHR to get users.

or

  • Introduce a triggerActedPost to reconcile post actions, 1 XHR to get actions, 1 XHR to get users

or

  • Introduce a payload to the message sent and split out acted / removed_act messages, that way you can render the user right away when you get the message and don’t need an extra XHR (very tricky due to security, probably not doable)

Since @eviltrout is planning on working on this (probably next week, leaving it to him)

This seems like a lot of work for a rather rare, niche situation.

A simple fix is probably not too much work, @eviltrout is planning on paying off some technical debt around post actions so I want to make sure this is paid off while at it.

4 likes

This works as expected and probably has for some time now.

5 likes