If you're on an issue/PR and there are reactions to comments the avatars will disappear if someone else reacts. There should be a Mutation Observer or something to track those elements and re-add the avatars on an update.
It's actually hiding the avatars, so _something_ is happening.
Rather than a mutation observer, I think we can just leverage the fact that GitHub's JS emits events on socket messages.
$(document).on('socket:message', (e, data) => {
// data will be an object of the format:
// {timestamp: 1464274232, reason: "reaction #1209345 updated"}
});
We'd know to go run our updates on reactions anytime the reason prop mentions a reaction has been updated
We'd know to go run our updates on reactions anytime the reason prop mentions a reaction has been updated
We can just run them all or we can run just the one comment that was updated, but that latter option is not currently supported.
I'll work on it this week :)
Would $(document).on('socket:message') actually work? I got no events when testing it for #132, even though I saw GH's own code triggering the event.
.
@bfred-it I also tried $(document).on('socket:message') but it didn't work :(
I _thiiiink_ this happens because jQuery doesn't trigger real DOM events but it just short-circuits within its own event Map. So unless we use GH's own jQuery (we can't) we probably won't be able to listen to them.
Pinging jQuery experts around the world. It'd be nice to plug into GH's own events rather than rely on MutationObservers.
Edit: jQuery events are stored in "symbol" properties on document (try Object.keys(document) to see them). Unfortunately we can't easily access private properties from our context.
I'm reopening this issue hoping for a proper resolution. My fix doesn't work all the time and it especially doesn't work on ajax-loaded comments + their new reactions.
I think the solution should just be observeEl on the comments list, which adds new observeEl on new comments and their reactions. I don't think this would be too heavy, since it just observes their direct children.