diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2016-08-01 19:46:06 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2016-08-01 19:46:06 -0400 |
| commit | c89196934f5c83b117afdc6c2061f1efe4a2c60a (patch) | |
| tree | eece008671bdc04ddff9ee4217e780a6cff49d54 /www/js | |
| parent | 0dcbfc493c5c08b463d3cb02c29f932ff3e3f2ea (diff) | |
#292 - firstuse fixes - dealing with problems of checking firstuse before all data is loaded
Former-commit-id: 7b071f959eb86ae0109094f1828a1ca4f7b3cfde
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/DataModel.js | 6 | ||||
| -rw-r--r-- | www/js/FirstUseCtrl.js | 2 | ||||
| -rw-r--r-- | www/js/app.js | 39 |
3 files changed, 42 insertions, 5 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 681e8fbd..4a02f5bc 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -427,6 +427,10 @@ angular.module('zmApp.controllers') $ionicLoading.show({ template: "retrieving profile data..." }); + + + + localforage.getItem("serverGroupList").then(function (val) { $ionicLoading.hide(); serverGroupList = val; @@ -746,6 +750,8 @@ angular.module('zmApp.controllers') //localforage.setItem("isFirstUse", val, // function(err) {if (err) zmLog ("localforage error, //storing isFirstUse: " + JSON.stringify(err));}); isFirstUse = val; + localforage.setItem ("isFirstUse",val); + console.log (">>>>>>setting isFirstUse to " + val); }, diff --git a/www/js/FirstUseCtrl.js b/www/js/FirstUseCtrl.js index b9031309..66b7712c 100644 --- a/www/js/FirstUseCtrl.js +++ b/www/js/FirstUseCtrl.js @@ -13,7 +13,7 @@ $scope.openMenu = function () { // Controller Main //------------------------------------------------------------------------ $scope.$on('$ionicView.enter', function () { - //console.log("**VIEW ** FirstUse Ctrl Entered"); + console.log("**VIEW ** FirstUse Ctrl Entered"); $ionicSideMenuDelegate.canDragContent(true); diff --git a/www/js/app.js b/www/js/app.js index 40fb76cb..849365d3 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1043,7 +1043,7 @@ angular.module('zmApp', [ $rootScope.$on('$stateChangeStart', function (event, toState, toParams) { var requireLogin = toState.data.requireLogin; - if (ZMDataModel.isLoggedIn() || toState.name =="login" ) { + if (ZMDataModel.isLoggedIn() || toState.data.requireLogin ==false ) { //console.log("State transition is authorized"); return; @@ -1115,7 +1115,20 @@ angular.module('zmApp', [ localforage.getItem("defaultServerName") .then (function (val) { - if (!val && defaultServerName) + console.log (">>>> localforage reported defaultServerName as " + val); + // if neither, we are in first use, mates! + if (!val && !defaultServerName) + { + continueInitialInit(); + /* ZMDataModel.zmDebug ("Neither localstorage or forage - First use, showing warm and fuzzy..."); + $ionicHistory.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + $state.go('first-use');*/ + } + + else if (!val && defaultServerName) { ZMDataModel.zmLog (">>>>Importing data from localstorage...."); @@ -1252,8 +1265,26 @@ angular.module('zmApp', [ .then(function (success) { ZMDataModel.zmLog(">>>>Language to be used:" + $translate.proposedLanguage()); moment.locale($translate.proposedLanguage()); - continueRestOfInit(); - + + // Remember this is before data Init + // so I need to do a direct forage fetch + localforage.getItem("isFirstUse") + .then (function(val) + { + console.log ("isFirstUse is " + val); + if (val == null || val == true) + { + ZMDataModel.zmLog ("First time detected"); + $state.go("first-use"); + } + else + { + continueRestOfInit(); + } + + }); + + }); } |
