I have a situation where I need an initial value from the user object (the user’s next penalty) even though the value isn’t loaded when the component is rendered. The user might need to load after the modal shows (discourse/admin-tools.js at 0542e9cb19bc4c2bc2a39d56011e03c1742f3f95 · featheredtoast/discourse · GitHub).
I cannot make silenceUntil/suspendUntil itself a computed property here because I need to allow the future-date-picker the ability to call mut on the value, uninhibited.
I need to update silenceUntil/suspendUntil’s initial value when the user loads in to the modal, but I am unable to within the same runloop as the init (Ember complains that we’re recomputing the value too many times). Putting it in a later() allows me to update the initial value quickly enough.
I could load the user first, and then display the modal with the initial values, but if the user needs to load and takes a long time, no loading indicator would be shown so I decided to go down this route.
I need the following events to fire:
- Modal window shows, value is potentially blank as user loads
- User loads in. Fires an event to the controller that sets the initial value of silenceUntil/suspendUntil from user object. This should also update the future-date-picker’s selection to custom, with the specified date/time along with the underlying input value for said date. Without the later() call it does update the UI, but not the underlying js value as a
mut call was never triggered from the future-date-picker.