Hey @Johani , so another version of this “how to trigger or be triggered” issue is that I’m using a version of Custom Header Links in a plugin. It links to some items (“servers”) created in a separate model that my plugin adds. When a server
is created, I want to rebuild the header links to link to the two most recently created servers. I’m doing this now in an initializer and it works fine except to get it to update after a server is added you have to reload the page.
You told me how to add and watch triggers, so I thought I might be able to figure it out, but the page that’s doing the work is in discourse-subscriptions
. Maybe what I want to do is submit a PR to discourse-subscriptions
that adds a
this.appEvents.trigger("purchase-complete")
after a purchase is complete (and the purchase triggers adding to a group, which triggers creating a server and removing the user from the group). Or, if I could just trigger a reload after the purchase was complete, or when the clicked the “OK” in the “purchase complete” modal, that would be fine too, but I don’t know how to do that either (what I tried just reloaded the page forever…)
SO maybe here:
I want to add a
this.appEvents.trigger("successful-transaction")
after loading is set false, and then I could have my initializer add an
this.appEvents.on("successful-transaction")
to do the header manipulation?
I think that once I do that, I’ll need to do something different because I’m afraid that
api.decorateWidget("header-buttons:before", (helper) => {
return helper.h("ul.pfaffmanager-header-links", headerLinks);
});
adds to header-buttons:before
rather than replacing them so I’ll get more links every time it fires?