Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change external portal cache strategy #2341

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Oct 25, 2023

What does this PR do?

Addresses a small visual issue flagged here on OSL Slack where External Portals do not update as expected

Before

Screen.Recording.2023-10-25.at.21.24.11.mov

After

Screen.Recording.2023-10-25.at.22.12.38.mov

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

Removed vultr server and associated DNS entries

gql`
query GetFlow($id: uuid!) {
flows_by_pk(id: $id) {
const ExternalPortal: React.FC<any> = (props) => {
Copy link
Contributor Author

@DafyddLlyr DafyddLlyr Oct 25, 2023

Choose a reason for hiding this comment

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

React.memo() was caching this component and causing it to update in an unexpected manner.

There's nothing particularly "expensive" going on here apart from the query. By adding an id field to the query response though Apollo will just cache this for us in the InMemoryCache and stop the query being repeated anyway.

The big diff here is a bit weird but it's pretty much just the indentation of React.memo() being removed.

// If the flow referenced by an external portal has been deleted (eg !data),
// still show a "Corrupted" node so that editors have a visual cue to "delete".
// Until deleted, the flow schema will still contain a node reference to this portal causing dataMerged to fail
if (!loading && !data?.flows_by_pk) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking this loading state stops the component flashing to "Corrupted" between updates.

@DafyddLlyr DafyddLlyr force-pushed the dp/change-external-portal-cache-strategy branch from 236b930 to df257fc Compare October 25, 2023 21:00
@DafyddLlyr DafyddLlyr marked this pull request as ready for review October 25, 2023 21:15
@DafyddLlyr DafyddLlyr requested a review from a team October 25, 2023 21:15
@DafyddLlyr DafyddLlyr merged commit c6806d7 into main Oct 26, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants