Fixed portal preview resize and cached page bugs

no issue

- moved `@onLoad` trigger from `load` event to the `makeVisible()` task so that consumer code isn't called before load has fully finished
  - fixes issue with portal sometimes not being ready when we perform the resize on the membership screen
- added guid as a cache-busting `?v={guid}` query param
  - fixes issue where preview iframe can load stale data after a settings change resulting in a blank preview after going from "nobody" to "invite/anybody" because the loaded homepage is stale and doesn't have the portal script injected
This commit is contained in:
Kevin Ansfield 2021-05-24 17:27:52 +01:00
parent 757f061362
commit baafe011a2
2 changed files with 14 additions and 4 deletions

View File

@ -18,7 +18,13 @@ export default class GhSiteIframeComponent extends Component {
}
get srcUrl() {
return this.args.src || `${this.config.get('blogUrl')}/`;
const srcUrl = new URL(this.args.src || `${this.config.get('blogUrl')}/`);
if (this.args.guid) {
srcUrl.searchParams.set('v', this.args.guid);
}
return srcUrl.href;
}
@action
@ -43,10 +49,13 @@ export default class GhSiteIframeComponent extends Component {
@action
onLoad(event) {
this.iframe = event.target;
if (this.args.invisibleUntilLoaded && typeof this.args.invisibleUntilLoaded === 'boolean') {
this.makeVisible.perform();
} else {
this.args.onLoad?.(this.iframe);
}
this.args.onLoad?.(event);
}
@action
@ -73,5 +82,6 @@ export default class GhSiteIframeComponent extends Component {
// allows portal to render it's overlay and prevent site background flashes
yield timeout(100);
this.isInvisible = false;
this.args.onLoad?.(this.iframe);
}
}

View File

@ -239,8 +239,8 @@ export default class MembersAccessController extends Controller {
}
@action
portalPreviewLoaded(event) {
this.portalPreviewIframe = event.target;
portalPreviewLoaded(iframe) {
this.portalPreviewIframe = iframe;
this.resizePortalPreviewTask.perform();
}