delete items on signout

This commit is contained in:
Mo Bitar
2017-01-13 00:50:20 -06:00
parent 0130fae17d
commit 86b6ac0d58
5 changed files with 39 additions and 10 deletions

View File

@@ -88,8 +88,9 @@ angular.module('app.frontend')
this.signOutPressed = function() { this.signOutPressed = function() {
this.showAccountMenu = false; this.showAccountMenu = false;
apiController.signout(); apiController.signout(function(){
window.location.reload(); window.location.reload();
})
} }
this.submitPasswordChange = function() { this.submitPasswordChange = function() {

View File

@@ -571,8 +571,11 @@ angular.module('app.frontend')
localStorage.setItem('mk', mk); localStorage.setItem('mk', mk);
} }
this.signout = function() { this.signout = function(callback) {
localStorage.clear(); dbManager.clearAllItems(function(){
localStorage.clear();
callback();
});
} }
this.encryptSingleItem = function(item, masterKey) { this.encryptSingleItem = function(item, masterKey) {

View File

@@ -115,6 +115,16 @@ class DBManager {
}; };
}, null); }, null);
} }
clearAllItems(callback) {
this.openDatabase((db) => {
var request = db.transaction("items", "readwrite").objectStore("items").clear();
request.onsuccess = function(event) {
console.log("Successfully cleared items");
callback();
};
}, null)
}
} }
angular.module('app.frontend').service('dbManager', DBManager); angular.module('app.frontend').service('dbManager', DBManager);

View File

@@ -793,8 +793,9 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
this.signOutPressed = function () { this.signOutPressed = function () {
this.showAccountMenu = false; this.showAccountMenu = false;
apiController.signout(); apiController.signout(function () {
window.location.reload(); window.location.reload();
});
}; };
this.submitPasswordChange = function () { this.submitPasswordChange = function () {
@@ -957,7 +958,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
// refresh every 30s // refresh every 30s
setInterval(function () { setInterval(function () {
apiController.sync(null); apiController.sync(null);
}, 30000); }, 2000);
}); });
$scope.allTag = new Tag({ all: true }); $scope.allTag = new Tag({ all: true });
@@ -2487,8 +2488,11 @@ var Tag = function (_Item3) {
localStorage.setItem('mk', mk); localStorage.setItem('mk', mk);
}; };
this.signout = function () { this.signout = function (callback) {
localStorage.clear(); dbManager.clearAllItems(function () {
localStorage.clear();
callback();
});
}; };
this.encryptSingleItem = function (item, masterKey) { this.encryptSingleItem = function (item, masterKey) {
@@ -2711,6 +2715,17 @@ var DBManager = function () {
}; };
}, null); }, null);
} }
}, {
key: 'clearAllItems',
value: function clearAllItems(callback) {
this.openDatabase(function (db) {
var request = db.transaction("items", "readwrite").objectStore("items").clear();
request.onsuccess = function (event) {
console.log("Successfully cleared items");
callback();
};
}, null);
}
}]); }]);
return DBManager; return DBManager;

File diff suppressed because one or more lines are too long