Fix issue with user dropdown not being populated sometimes #1089
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this PR?
I was able to, on rare occassions, reproduce this issue on dev, but it's really difficult due to latency differences compared to staging and production.
The gist of it is, there was an issue with the
organizationMemberscomputed defined on theorganizationmodel.The
project.tasks.indexcontroller was returning the following in the model hook:At the time of the hook being executed, more often than not, the items within
organizationMembersare not fully loaded. The array itself is not a promise, the individual items are promises, so the hook does not wait for them to load. Instead, we end up with most of these being set tonulland this is stored as a controller property calledmembers.As I previously mentioned, computed will not reevaluate themselves, unless they are bound to a template. There was no direct bounding here. We get a computed from the model and evaluate it in the model hook, then store and bind to that value as a controller property.
Even if computeds did reevaluate themselves when not bound to a template, I don't think that would happen here, since we literally used
getto retrieve and later store the value at a certain moment.The solution was to alias the computed in the controller instead of evaluating it in the model hook.
Further more, I would prefer if we used computeds to facilitate template binding, not as a sort of viewModel/decorator for a model. It complicates things and in this case, also makes it quite difficult to test.
For example, I have no idea how to write a failing test for this. It would have to be acceptance level and even so, I would have to use timing and manual pushing into the store to achieve it. I tried several different things, with no luck.
References
Fixes #1082