From d76da02d0c4f6610f27c11da460ff618b302f716 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Fri, 15 Jul 2016 16:04:05 +0200 Subject: [PATCH] Wait for clearLocal to end by returning the promise --- www/assets/js/sofia.db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/assets/js/sofia.db.js b/www/assets/js/sofia.db.js index ec75ee4..dfda406 100644 --- a/www/assets/js/sofia.db.js +++ b/www/assets/js/sofia.db.js @@ -74,7 +74,7 @@ S.db.users = { return response; }); }else{ - return err; + return response; } } }); @@ -204,7 +204,7 @@ S.db.fiches = { S.db.fiches.sync(); //Same Db base everything is ok }else{ console.log("Diff DB Token detected !",remote, local); - S.db.clearLocal().then(function () { //Clear local DB + return S.db.clearLocal().then(function () { //Clear local DB S.db.localDB = new PouchDB(S.config.db._local_url); //Restart local DB S.db.fiches.sync(); //Same Db base everything is ok }).catch(function (err) {