From 51abcd7524bbd9659ff6737f4b4a6eeab94b36e8 Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Wed, 8 Dec 2021 13:23:39 -1000 Subject: [PATCH] DEV: add app event for user-card:after-show (#15227) Adds user-card:after-show event for when a usercard is fully loaded and shown. --- .../discourse/app/components/user-card-contents.js | 3 ++- .../javascripts/discourse/app/mixins/card-contents-base.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/user-card-contents.js b/app/assets/javascripts/discourse/app/components/user-card-contents.js index 3c64c2fc839..db6621cc71d 100644 --- a/app/assets/javascripts/discourse/app/components/user-card-contents.js +++ b/app/assets/javascripts/discourse/app/components/user-card-contents.js @@ -174,7 +174,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { include_post_count_for: this.get("topic.id"), }; - User.findByUsername(username, args) + return User.findByUsername(username, args) .then((user) => { if (user.topic_post_count) { this.set( @@ -183,6 +183,7 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { ); } this.setProperties({ user }); + return user; }) .catch(() => this._close()) .finally(() => this.set("loading", null)); diff --git a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js index d5843e9afb2..b56179c7340 100644 --- a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js +++ b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js @@ -86,7 +86,9 @@ export default Mixin.create({ }); this.appEvents.trigger("user-card:show", { username }); - this._showCallback(username, $(target)); + this._showCallback(username, $(target)).then((user) => { + this.appEvents.trigger("user-card:after-show", { user }); + }); // We bind scrolling on mobile after cards are shown to hide them if user scrolls if (this.site.mobileView) {