Bug 920337 - Use promise to ensure we don't miss project load. r=paul
This commit is contained in:
@@ -88,12 +88,19 @@ const IDB = {
|
|||||||
|
|
||||||
const store = new ObservableObject({ projects:[] });
|
const store = new ObservableObject({ projects:[] });
|
||||||
|
|
||||||
|
let loadDeferred = promise.defer();
|
||||||
|
|
||||||
IDB.open().then(function (projects) {
|
IDB.open().then(function (projects) {
|
||||||
store.object.projects = projects;
|
store.object.projects = projects;
|
||||||
AppProjects.emit("ready", store.object.projects);
|
AppProjects.emit("ready", store.object.projects);
|
||||||
|
loadDeferred.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
const AppProjects = {
|
const AppProjects = {
|
||||||
|
load: function() {
|
||||||
|
return loadDeferred.promise;
|
||||||
|
},
|
||||||
|
|
||||||
addPackaged: function(folder) {
|
addPackaged: function(folder) {
|
||||||
let project = {
|
let project = {
|
||||||
type: "packaged",
|
type: "packaged",
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ let UI = {
|
|||||||
this.template = new Template(document.body, AppProjects.store, Utils.l10n);
|
this.template = new Template(document.body, AppProjects.store, Utils.l10n);
|
||||||
this.template.start();
|
this.template.start();
|
||||||
|
|
||||||
AppProjects.store.on("set", (event,path,value) => {
|
AppProjects.load().then(() => {
|
||||||
if (path == "projects") {
|
|
||||||
AppProjects.store.object.projects.forEach(UI.validate);
|
AppProjects.store.object.projects.forEach(UI.validate);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user