FIX: Do not reload card if already loaded (PR #14129)

This changes include some used for making it easier to extend user card functionality.

GitHub

I know this is used for future customisation but I think it’ll be better to introduce when the use case for customization is clearer.

Sorry but from the PR’s title I’m not quite sure what this is fixing so it is making it slightly harder to review. Do you have the steps to repro this problem ?

I’m curious, what do you need the lastEvent for? “future customizations” isn’t very specific :sweat_smile:

I needed it in https://github.com/discourse/discourse-user-card-on-hover.

Cards that are shown because the user hovered must disappear when the user no longer hovers over the user avatar. Cards that were shown because the user clicked must disappear when the user clicks again outside the user card. Using lastEvent I can determine the type of the event.

@ZogStriP @nbianca Will it be possible to publish this via appEvents instead and avoid extending core for plugins in this way? Core has no need for the lastEvent property so code for plugin is in some way polluting core now.