CTFd / core-beta

Apache License 2.0
10 stars 23 forks source link

question on challenge load hooks for plugins #58

Open frankli0324 opened 10 months ago

frankli0324 commented 10 months ago

as implemented in async loadChallenge(challengeId), core-beta invokes displayChallenge in CTFd.js which downloads view.js for a challenge and does this:

https://github.com/CTFd/CTFd.js/blob/65df4e05fa039b6e464d50e62423e4536580f318/pages/challenge.js#L18-L33

before core-beta, postRender is invoked after the html is actually rendered, yet core-beta uses alpinejs, so show() the modal takes effect after the entire displayChallenge, which breaks the logic of a plugin which relied on postRender to get the challenge id with jquery($('#challenge-id')) and load the challenge info.

I think what I really need is CTFd._internal.challenge.data.id, yet I still wonder should postRender keep the previous behavior when virtual dom is actually rendered? otherwise what's the point of the postRender hook?

frankli0324 commented 10 months ago

two things are in between of displayChallenge and postRender: