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

feat: wait for onsyschange #9

Merged
merged 15 commits into from
Oct 6, 2021

Conversation

TylerBarnes
Copy link

@TylerBarnes TylerBarnes commented Oct 5, 2021

This PR solves (with bandaids) the contentful onSysChange vs data save timing issue.

  1. When pressing open preview the button becomes disabled and a loading indicator appears below it.
  2. We wait 3 seconds before doing anything to let Contentful catch up to us
  3. We open the Content Sync page with the manifest ID we have
  4. We set an interval to recheck the manifest ID every second for 10 seconds.
  5. If the ID changes in those 10 seconds, we refresh the Content Sync window with the updated manifest ID.
  6. After the ID changes or after 10 seconds the button becomes clickable again.

The initial 3 second wait is required to make sure the incremental build doesn't happen before Contentful saves the entry data (this happens suprisingly often). The rest is a pile of bandaids because Contentful doesn't expose an API to let us know when the data is saved.

Manually saving the data on our own causes other problems:

  1. It locks the UI so the user can't do anything until they refresh the page
  2. onSysChanged stops firing probably due to the UI being locked so we can't refresh the content sync window if the manifest ID changes.
  3. Manually saving doesn't seem to create the right manifest ID.

TODO:

  • Use ExtensionUI component instead of this custom Button component in this PR. This will require another PR to mansion.
    • Add disabled state to button with new styles
    • Add new prop to prevent extension UI from opening the previewUrl
  • Remove console logs
  • Cleanup code

@netlify
Copy link

netlify bot commented Oct 6, 2021

❌ Deploy Preview for content-sync failed.

🔨 Explore the source changes: 230c464

🔍 Inspect the deploy log: https://app.netlify.com/sites/content-sync/deploys/615de5e4671c270008474455

@TylerBarnes TylerBarnes marked this pull request as ready for review October 6, 2021 17:58
Copy link

@pvorozhe pvorozhe left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link

@veryspry veryspry left a comment

Choose a reason for hiding this comment

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

Just a few really tiny things

@TylerBarnes TylerBarnes merged commit 286ffa0 into content-sync-support Oct 6, 2021
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.

5 participants