From 22ab5d334ef3950e3c0fa764cfba06dc90988224 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 18 Mar 2017 22:55:54 -0400 Subject: [PATCH] load folders from it's api --- src/app/services/cipherService.js | 2 +- src/app/vault/vaultController.js | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/app/services/cipherService.js b/src/app/services/cipherService.js index 3e4bc53a29..2e89486e4b 100644 --- a/src/app/services/cipherService.js +++ b/src/app/services/cipherService.js @@ -90,7 +90,7 @@ angular return { id: encryptedFolder.Id, - name: _service.decryptProperty(encryptedFolder.Data.Name, null, false) + name: _service.decryptProperty(encryptedFolder.Name, null, false) }; }; diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 58fbc06a40..a225aaf47e 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -2,34 +2,41 @@ .module('bit.vault') .controller('vaultController', function ($scope, $uibModal, apiService, $filter, cryptoService, authService, toastr, - cipherService) { + cipherService, $q) { $scope.logins = []; $scope.folders = []; - $scope.loading = true; - $scope.$on('$viewContentLoaded', function () { - apiService.ciphers.list({}, function (ciphers) { - $scope.loading = false; - var decLogins = []; + $scope.$on('$viewContentLoaded', function () { + var folderPromise = apiService.folders.list({}, function (folders) { var decFolders = [{ id: null, name: '(none)' }]; + for (var i = 0; i < folders.Data.length; i++) { + var decFolder = cipherService.decryptFolderPreview(folders.Data[i]); + decFolders.push(decFolder); + } + + $scope.folders = decFolders; + }).$promise; + + var cipherPromise = apiService.ciphers.list({}, function (ciphers) { + var decLogins = []; + for (var i = 0; i < ciphers.Data.length; i++) { - if (ciphers.Data[i].Type === 0) { - var decFolder = cipherService.decryptFolderPreview(ciphers.Data[i]); - decFolders.push(decFolder); - } - else { + if (ciphers.Data[i].Type === 1) { var decLogin = cipherService.decryptLoginPreview(ciphers.Data[i]); decLogins.push(decLogin); } } - $scope.folders = decFolders; $scope.logins = decLogins; + }).$promise; + + $q.all([folderPromise, cipherPromise]).then(function () { + $scope.loading = false; }); });