cached sites for current tab page

This commit is contained in:
Kyle Spearrin 2016-09-15 21:22:47 -04:00
parent 6f142c3682
commit 072a9606e1
2 changed files with 12 additions and 51 deletions

View File

@ -87,6 +87,7 @@ var Folder = function (obj, alreadyEncrypted) {
return null; return null;
}).then(function (val) { }).then(function (val) {
model.uri = val; model.uri = val;
model.domain = tldjs.getDomain(val);
if (self.username) { if (self.username) {
return self.username.decryptWithPromise(); return self.username.decryptWithPromise();
} }

View File

@ -29,61 +29,21 @@ angular
$scope.canAutofill = true; $scope.canAutofill = true;
}); });
var filteredPromises = [], var filteredSites = [],
filteredSites = [], promises = [];
promises = [],
decSites = [];
siteService.getAll(function (sites) { var sitePromise = $q.when(siteService.getAllDecrypted());
sitePromise.then(function (sites) {
for (var i = 0; i < sites.length; i++) { for (var i = 0; i < sites.length; i++) {
var uriPromise = cipherService.decrypt(sites[i].uri, i); if (sites[i].domain && sites[i].domain == domain) {
filteredPromises.push(uriPromise); filteredSites.push(sites[i]);
uriPromise.then(function (obj) {
if (!obj.val) {
return;
} }
var siteDomain = tldjs.getDomain(obj.val);
if (!siteDomain || siteDomain != domain) {
return;
} }
filteredSites.push(obj.index);
}); });
} promises.push(sitePromise);
$q.all(filteredPromises).then(function () {
for (var j = 0; j < filteredSites.length; j++) {
var index = filteredSites[j];
decSites.push({
id: sites[index].id,
folderId: sites[index].folderId,
favorite: sites[index].favorite
});
var namePromise = cipherService.decrypt(sites[index].name, j);
promises.push(namePromise);
namePromise.then(function (obj) {
decSites[obj.index].name = obj.val;
});
var usernamePromise = cipherService.decrypt(sites[index].username, j);
promises.push(usernamePromise);
usernamePromise.then(function (obj) {
decSites[obj.index].username = obj.val;
});
var passwordPromise = cipherService.decrypt(sites[index].password, j);
promises.push(passwordPromise);
passwordPromise.then(function (obj) {
decSites[obj.index].password = obj.val;
});
}
$q.all(promises).then(function () { $q.all(promises).then(function () {
$scope.sites = decSites; $scope.sites = filteredSites;
});
});
}); });
}); });