I am one day into using trigger.io to develop apps and have run into a little trouble. My app requires that the user log in when first launching, upon successful log-in their user settings are stored using forge.prefs.set
. The log-in form is index.html - thus loaded first when the app is launched.
After the user has logged in, I check to see if they have already logged in by checking for their userID with forge.prefs.get
. If they are logged in, I redirect them to the main page of the app -
forge.prefs.get('user', function(result) {
if (result) {
window.location.href = 'main.html'; // They're logged in, redirect
}
});
$(function () {
... main app logic
});
However, this approach causes the login form to be visible for a split second before the code checking to see if they are already logged in runs.
I noticed this in docs for the trigger.io module launchimage:
By default, the launch image is hidden automatically when the window load event fires or after 5 seconds, whichever is sooner.
It sounds like I want to run this check during the "window load event," but I cannot seem to figure out how to do that - Google and searching the docs did not turn anything up.
How can I prevent this behavior?
Thanks!