Skip to content

Commit

Permalink
main: renaming turtl.loaded -> turtl.intiailized. adding NEW turtl.lo…
Browse files Browse the repository at this point in the history
…aded bool that is true when the profile is loaded and the notes are all indexed (basically, the entire app is loaded) and is false initially/on logout. also, there is an event that fires on change of turtl.loaded: `app:loaded`/`app:unloaded`.
  • Loading branch information
orthecreedence committed Oct 23, 2018
1 parent a0e6464 commit 0887fba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions main.js
Expand Up @@ -19,6 +19,7 @@ var turtl = {
// a modal helper
overlay: null,

initialized: false,
loaded: false,

// holds the title breadcrumbs
Expand Down Expand Up @@ -63,7 +64,7 @@ var turtl = {

init: function()
{
if(this.loaded) return false;
if(this.initialized) return false;

turtl.user = new User();
turtl.search = new Search();
Expand Down Expand Up @@ -156,7 +157,7 @@ var turtl = {
// load the sidebar after we set up the user/profile object
turtl.controllers.sidebar = new SidebarController();

this.loaded = true;
this.initialized = true;
turtl.events.trigger('loaded');

// let RememberMe manage the login from here
Expand Down Expand Up @@ -301,6 +302,9 @@ var turtl = {
if(initial_route.match(/background.html/)) initial_route = space_route;
turtl.route(initial_route);
options.initial_route = '/';

turtl.loaded = true;
turtl.events.trigger('app:loaded');
turtl.events.trigger('app:load:profile-loaded');

turtl.keyboard.bind('shift+/', function() {
Expand Down Expand Up @@ -400,6 +404,8 @@ var turtl = {
}

turtl.events.trigger('user:logout');
turtl.events.trigger('app:unloaded');
turtl.loaded = false;
}.bind(turtl));
},

Expand Down Expand Up @@ -431,7 +437,7 @@ var turtl = {

unload: function()
{
this.loaded = false;
this.initialized = false;
Object.each(this.controllers, function(controller) {
controller.release();
});
Expand All @@ -456,7 +462,7 @@ var turtl = {
enabled = false;
}
if(turtl.user.logging_in) enabled = false;
if(!turtl.loaded) enabled = false;
if(!turtl.initialized) enabled = false;
return enabled;
}
}, options);
Expand Down

0 comments on commit 0887fba

Please sign in to comment.