Skip to content

ref(stores): Allow silent organization updates#15165

Merged
evanpurkhiser merged 1 commit intomasterfrom
evanpurkhiser/refstores-allow-silent-organization-updates
Oct 18, 2019
Merged

ref(stores): Allow silent organization updates#15165
evanpurkhiser merged 1 commit intomasterfrom
evanpurkhiser/refstores-allow-silent-organization-updates

Conversation

@evanpurkhiser
Copy link
Member

Going to use this for starting trials

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked with @billyvg, decided to keep the store state consistent with components.

Copy link
Contributor

@davidenwang davidenwang Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me I was just scared of the case in which

  1. user does something that requires a refetch of organization
  2. trigger fetchOrganizationDetails()
  3. orgstore is not reset
  4. user clicks somewhere else unmounting and clearing the inflight request to /organizations
  5. 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
  6. 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

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/refstores-allow-silent-organization-updates branch from 99efa0f to 367bcb5 Compare October 17, 2019 23:05
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the !! here? is this for scenarios where silent is undefined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see nvm that seems good to me

@davidenwang davidenwang requested a review from billyvg October 17, 2019 23:43
@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/refstores-allow-silent-organization-updates branch from 367bcb5 to 361f67c Compare October 17, 2019 23:50
@billyvg
Copy link
Member

billyvg commented Oct 17, 2019

What would be the point of this if we're not emitting the update event to listeners?

@evanpurkhiser
Copy link
Member Author

What would be the point of this if we're not emitting the update event to listeners?

This stops the OrganzationContext from rendering a loading indicator and un-rendering the world.

@billyvg
Copy link
Member

billyvg commented Oct 18, 2019

Wouldn't it be better if we had silent just not change loading state?

@evanpurkhiser
Copy link
Member Author

@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.

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/refstores-allow-silent-organization-updates branch from 361f67c to 35eaea3 Compare October 18, 2019 00:22
@evanpurkhiser
Copy link
Member Author

Okay, reverted back to just not resetting.

@evanpurkhiser evanpurkhiser merged commit 071003c into master Oct 18, 2019
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/refstores-allow-silent-organization-updates branch October 18, 2019 01:20
@billyvg
Copy link
Member

billyvg commented Oct 18, 2019

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

@evanpurkhiser
Copy link
Member Author

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.

evanpurkhiser added a commit that referenced this pull request Jul 10, 2020
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
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants