0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed preview background flash when switching from none -> all/invite

no issue

- flash was occurring because as soon as the setting was changed we switched to showing the portal preview but at that time the preview URL is still set to an old url value. The url doesn't get changed until the settings save completes which gives enough time for a non-portal page to load before being replaced
- added a `switchFromNoneTask` that is triggered when switching away from a saved none value and updated the template to stay on the "disabled" view until the save has completed so we don't trigger multiple page loads
This commit is contained in:
Kevin Ansfield 2021-05-25 09:40:17 +01:00
parent 2bd118eef9
commit 2f39953917
2 changed files with 7 additions and 2 deletions

View file

@ -111,7 +111,7 @@ export default class MembersAccessController extends Controller {
// when saved value is 'none' the server won't inject the portal script // when saved value is 'none' the server won't inject the portal script
// to work around that and show the expected portal preview we save and // to work around that and show the expected portal preview we save and
// force a refresh // force a refresh
await this.saveSettingsTask.perform({forceRefresh: true}); await this.switchFromNoneTask.perform();
} else { } else {
this.updatePortalPreview(); this.updatePortalPreview();
} }
@ -257,6 +257,11 @@ export default class MembersAccessController extends Controller {
this.resizePortalPreviewTask.cancelAll(); this.resizePortalPreviewTask.cancelAll();
} }
@task
*switchFromNoneTask() {
return yield this.saveSettingsTask.perform({forceRefresh: true});
}
@task({restartable: true}) @task({restartable: true})
*resizePortalPreviewTask() { *resizePortalPreviewTask() {
if (this.portalPreviewIframe && this.portalPreviewIframe.contentWindow) { if (this.portalPreviewIframe && this.portalPreviewIframe.contentWindow) {

View file

@ -48,7 +48,7 @@
</div> </div>
<div class="gh-setting-members-portalpreview"> <div class="gh-setting-members-portalpreview">
<div class="gh-setting-members-portal-mock"> <div class="gh-setting-members-portal-mock">
{{#if (eq this.settings.membersSignupAccess 'none')}} {{#if (or (eq this.settings.membersSignupAccess 'none') this.switchFromNoneTask.isRunning)}}
<div class="gh-setting-members-portal-disabled"> <div class="gh-setting-members-portal-disabled">
<span class="lightgrey">{{svg-jar "portal-logo-stroke"}}</span> <span class="lightgrey">{{svg-jar "portal-logo-stroke"}}</span>
<h4>Portal disabled</h4> <h4>Portal disabled</h4>