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

DesignPreview: Refresh iframe the second time the preview is accessed #5551

Merged
merged 1 commit into from
May 25, 2016

Conversation

ehg
Copy link
Member

@ehg ehg commented May 24, 2016

Since we can't access the iframe to do a .reload(), or change the src, changing the URL seems to be the only way of refreshing the iframe.

  • Add a 'view' counter to DesignPreview, which is incremented if a refresh is needed, and reset on site change

Ideally we'd be able to tell WebPreview to refresh the URL somehow, and get rid of the qarg.

TODO:

  • Rebase to a branch with getPreviewUrl code
  • Add counter to getPreviewUrl as a qarg

To test:

  • Open calypso, open the preview (click the site card in the sites list)
  • Close the preview
  • Add a post/change theme
  • Open the preview

@ehg ehg added this to the GuidedTours M2: Preview & Polish milestone May 24, 2016
@ehg ehg self-assigned this May 24, 2016
@ehg ehg force-pushed the update/design-preview-refresh branch 2 times, most recently from 6d7e243 to 7bf7e40 Compare May 25, 2016 10:02
@ehg ehg added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels May 25, 2016
@lsinger
Copy link
Contributor

lsinger commented May 25, 2016

Works nicely for me. Code LGTM. Can you prettify the commit message subject a bit and, in the body, add the rationale for a) changing the URL to force a reload and b) using a counter instead of a random string?

@lsinger lsinger added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 25, 2016
We need a way to refresh the DesignPreview iframe contents after a
preview is displayed the second time. We don't have access to the
iframe, due to cross-origin concerns, so a way to combat this is to
append a counter onto the `previewUrl`. This is done in a way that the
first _preloaded_ view does not refresh, however every subsequent view
_is_ refreshed — which wouldn't be possible with a random number or
timestamp.
@ehg ehg force-pushed the update/design-preview-refresh branch from 7bf7e40 to 6e87223 Compare May 25, 2016 10:58
@ehg
Copy link
Member Author

ehg commented May 25, 2016

Done: 6e87223

@ehg ehg merged commit 5d327a0 into master May 25, 2016
@ehg ehg deleted the update/design-preview-refresh branch May 25, 2016 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants