Hey guys! I need help to avoid the blinking in my page
I am creating a page with a subscription model, and I need to know if it is possible to make the page open only on the subscription page if the subscription has expired. I am currently doing this with an “on page load” workflow that checks whether the subscription has expired or not, and if it has expired, it redirects you. So what steps does it take?
1- Load the page
2- While loading, it checks the subscription
3- It redirects you if it has expired
The problem only occurs when the user manually enters a URL, for example /dashboard. It loads for a second and then redirects you. When you log in, it is already working without the blinking.
My question is, can step 1 be avoided? Because currently, for a brief moment, I can see the page before being redirected to the subscription page.
I believe the better route would be by setting the page to have Private Access, and configuring your subscription settings to function with user roles.
For example, only Subscribers can view a page, and as soon as a subscription lapses, the user has their Subscriber role revoked and they can no longer access the page.
The Private Access checks happen before the page is loaded, so nothing is displayed. From my understanding, you won’t be able to efficiently get around the flickering screen if you use the On Page Load workflow, because it happens asynchronously with the page load by the looks of it. So that means the page will always be partially loaded by the time the checks are finished and the user booted from the page.
You’re best off using the logic above, as that’s what it’s built for and I suspect more secure. That being said… if you really wanted/needed to go the route of using the page load workflow to trigger your logic–or if you only wanted some elements visible on a page depending on if the subscription is valid or not–What you could probably do is set the Conditional Rendering for a single element or root item on the page to have a formula that checks a “IsSubscribed” variable. Set that variable to default to false, so whenever you open the page it starts as false and nothing is displayed, but the on page load workflow runs your subscriber check and flicks IsSubscribed to True when relevent - and then the unrendered content will load.
This conditional rendering keeps the content from being preloaded at all, so it won’t show up when you inspect the page either, unlike triggering the same style of logic in Display.