ref(stores): Allow silent organization updates#15165
Conversation
There was a problem hiding this comment.
My only concern might be to have the if statement further inside of the OrganizationActions.fetchOrg function. That way the store's state is reset to a loading state which should be correct, but just have an if statement surrounding the this.trigger(this.get()) call inside of the org store.
So changing the org store reset() function to look like
reset(silent = false) {
this.loading = true;
this.error = null;
this.errorType = null;
this.organization = null;
this.dirty = false;
if (!silent) {
this.trigger(this.get());
}
},this way if the org details are chosen to be refetched and the request is not persisted in flight and immediately the user moves to the projects page or another page, the org details will still be refetched because it will detect that the org store is in a loading state. Let me know if I'm not making sense there.
There was a problem hiding this comment.
Talked with @billyvg, decided to keep the store state consistent with components.
There was a problem hiding this comment.
sounds good to me I was just scared of the case in which
- user does something that requires a refetch of organization
- trigger fetchOrganizationDetails()
- orgstore is not reset
- user clicks somewhere else unmounting and clearing the inflight request to
/organizations - in the new page that the user clicked to, the org context sees that it does not need to refetch organization because the old org has not been reset
- old information is displayed on the frontend
but maybe i have some misconceptions about how this works. I'd say if we run into problems we can just fix em on the fly and just go with what you have for now
99efa0f to
367bcb5
Compare
There was a problem hiding this comment.
do we need the !! here? is this for scenarios where silent is undefined?
There was a problem hiding this comment.
oh I see nvm that seems good to me
367bcb5 to
361f67c
Compare
|
What would be the point of this if we're not emitting the update event to listeners? |
This stops the |
|
Wouldn't it be better if we had silent just not change loading state? |
|
@davidenwang can you explain your comment here again: #15165 (comment) This is why I moved it to just avoid triggering, but now re-reading I'm not sure I understand either. |
361f67c to
35eaea3
Compare
|
Okay, reverted back to just not resetting. |
|
Ooh damn. Just re read the pr and didn’t realize the first time the trigger was in the reset method. I think what David described makes total sense. My b |
I think you're still right abut the state of the store being out of sync with the state of the components not being great. |
I had originally fixed the same problem in [0] and then looks like it was refactored in [1], without the `silent` flag that I had introduced [2] for trialing [0]: #12842 [1]: 7ff0f57#diff-b53a62e33ed69961e43e0cc24634616eR101 [2]: #15165
Going to use this for starting trials