From 0acab8e789ebe821fe2cd1efd2b6881878254c0b Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 1 Apr 2019 16:23:19 -0600 Subject: [PATCH] Don't fail loading pages when their JS comes after pageAfterIn fires --- www/routes.js | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/www/routes.js b/www/routes.js index e279a41..ab5f6fc 100644 --- a/www/routes.js +++ b/www/routes.js @@ -19,7 +19,14 @@ var routes = [ }, on: { pageAfterIn: function () { - loadHomePage(function () {}); + function tryToLoadHomePage() { + if (typeof loadHomePage != "function") { + setTimeout(tryToLoadHomePage, 500); + } else { + loadHomePage(function () {}); + } + } + tryToLoadHomePage(); } } }, @@ -39,7 +46,14 @@ var routes = [ name: 'sendmoney', on: { pageAfterIn: function () { - loadSendMoneyPage(); + function tryToLoadSendMoneyPage() { + if (typeof loadSendMoneyPage != "function") { + setTimeout(tryToLoadSendMoneyPage, 500); + } else { + loadSendMoneyPage(); + } + } + tryToLoadSendMoneyPage(); } } }, @@ -54,7 +68,14 @@ var routes = [ name: 'addfunds', on: { pageAfterIn: function () { - initPaymentPage(); + function tryToInitPaymentPage() { + if (typeof initPaymentPage != "function") { + setTimeout(tryToInitPaymentPage, 500); + } else { + initPaymentPage(); + } + } + tryToInitPaymentPage(); } } }, @@ -69,7 +90,14 @@ var routes = [ name: 'updateprofile', on: { pageAfterIn: function () { - loadProfilePage(); + function tryToLoadProfilePage() { + if (typeof loadProfilePage != "function") { + setTimeout(tryToLoadProfilePage, 500); + } else { + loadProfilePage(); + } + } + tryToLoadProfilePage(); } } },