1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

load vault on $viewContentLoaded. apply scope on current tab when no sites to load. switch to $timeout to go through angular lifecycle.

This commit is contained in:
Kyle Spearrin
2016-12-27 00:01:01 -05:00
parent 6af283b947
commit 304183aad8
2 changed files with 18 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
angular angular
.module('bit.current') .module('bit.current')
.controller('currentController', function ($scope, siteService, tldjs, toastr, $q, $window, $state, autofillService, .controller('currentController', function ($scope, $rootScope, siteService, tldjs, toastr, $q, $window, $state, $timeout,
$analytics, i18nService) { autofillService, $analytics, i18nService) {
$scope.i18n = i18nService; $scope.i18n = i18nService;
var pageDetails = [], var pageDetails = [],
@@ -11,9 +11,13 @@ angular
domain = null, domain = null,
canAutofill = false; canAutofill = false;
$scope.sites = [];
$scope.loaded = false; $scope.loaded = false;
loadVault(); $scope.$on('$viewContentLoaded', function () {
$timeout(loadVault, 0);
});
function loadVault() { function loadVault() {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs.length > 0) { if (tabs.length > 0) {
@@ -22,13 +26,14 @@ angular
} }
else { else {
$scope.loaded = true; $scope.loaded = true;
$scope.$apply();
return; return;
} }
domain = tldjs.getDomain(url); domain = tldjs.getDomain(url);
$scope.sites = [];
if (!domain) { if (!domain) {
$scope.loaded = true; $scope.loaded = true;
$scope.$apply();
return; return;
} }

View File

@@ -2,7 +2,7 @@
.module('bit.vault') .module('bit.vault')
.controller('vaultController', function ($scope, $rootScope, siteService, folderService, $q, $state, $stateParams, toastr, .controller('vaultController', function ($scope, $rootScope, siteService, folderService, $q, $state, $stateParams, toastr,
syncService, utilsService, $analytics, i18nService, stateService) { syncService, utilsService, $analytics, i18nService, stateService, $timeout) {
var stateKey = 'vault', var stateKey = 'vault',
state = stateService.getState(stateKey) || {}; state = stateService.getState(stateKey) || {};
@@ -11,9 +11,11 @@
var syncOnLoad = $stateParams.syncOnLoad; var syncOnLoad = $stateParams.syncOnLoad;
if (syncOnLoad) { if (syncOnLoad) {
setTimeout(function () { $scope.$on('$viewContentLoaded', function () {
syncService.fullSync(function () { }); $timeout(function () {
}, utilsService.isFirefox() ? 500 : 0); syncService.fullSync(function () { })
}, 0);
});
} }
var delayLoad = true; var delayLoad = true;
@@ -29,8 +31,8 @@
} }
if (delayLoad) { if (delayLoad) {
setTimeout(setScrollY, 100); $timeout(setScrollY, 100);
setTimeout(loadVault, 1000); $timeout(loadVault, 1000);
} }
else if (!syncOnLoad) { else if (!syncOnLoad) {
loadVault(); loadVault();
@@ -136,7 +138,7 @@
}; };
$scope.$on('syncCompleted', function (event, successfully) { $scope.$on('syncCompleted', function (event, successfully) {
setTimeout(loadVault, 500); $timeout(loadVault, 500);
}); });
function storeState() { function storeState() {