mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
move sync upon login to vault controller initiated via state params.
This commit is contained in:
parent
a59f7a4afc
commit
d49f0fcac3
@ -39,7 +39,7 @@
|
||||
$state.go('twoFactor', { animation: 'in-slide-left' });
|
||||
}
|
||||
else {
|
||||
$state.go('tabs.vault', { animation: 'in-slide-left' });
|
||||
$state.go('tabs.vault', { animation: 'in-slide-left', syncOnLoad: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
$scope.loginPromise = loginService.logInTwoFactor(model.code);
|
||||
$scope.loginPromise.then(function () {
|
||||
$state.go('tabs.vault', { animation: 'in-slide-left' });
|
||||
$state.go('tabs.vault', { animation: 'in-slide-left', syncOnLoad: true });
|
||||
});
|
||||
};
|
||||
});
|
||||
|
@ -75,7 +75,7 @@
|
||||
url: '/vault',
|
||||
templateUrl: 'app/vault/views/vault.html',
|
||||
controller: 'vaultController',
|
||||
params: { scrollY: 0, searchText: null }
|
||||
params: { scrollY: 0, searchText: null, syncOnLoad: false }
|
||||
})
|
||||
.state('tabs.settings', {
|
||||
url: '/settings',
|
||||
|
@ -1,8 +1,8 @@
|
||||
angular
|
||||
.module('bit.services')
|
||||
|
||||
.factory('loginService', function (cryptoService, apiService, userService, tokenService, $q, syncService,
|
||||
$rootScope, siteService, folderService) {
|
||||
.factory('loginService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, siteService,
|
||||
folderService) {
|
||||
var _service = {};
|
||||
|
||||
_service.logIn = function (email, masterPassword) {
|
||||
@ -22,7 +22,6 @@
|
||||
if (response.profile) {
|
||||
userService.setUserId(response.profile.id, function () {
|
||||
userService.setEmail(response.profile.email, function () {
|
||||
syncService.fullSync(function () { });
|
||||
deferred.resolve(response);
|
||||
});
|
||||
});
|
||||
@ -52,7 +51,6 @@
|
||||
tokenService.setToken(response.token, function () {
|
||||
userService.setUserId(response.profile.id, function () {
|
||||
userService.setEmail(response.profile.email, function () {
|
||||
syncService.fullSync(function () { });
|
||||
deferred.resolve(response);
|
||||
});
|
||||
});
|
||||
|
@ -2,9 +2,16 @@
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultController', function ($scope, $rootScope, siteService, folderService, $q, $state, $stateParams, toastr,
|
||||
syncService) {
|
||||
syncService, utilsService) {
|
||||
$('#search').focus();
|
||||
|
||||
var syncOnLoad = $stateParams.syncOnLoad;
|
||||
if (syncOnLoad) {
|
||||
setTimeout(function () {
|
||||
syncService.fullSync(function () { });
|
||||
}, utilsService.isFirefox() ? 500 : 0);
|
||||
}
|
||||
|
||||
var delayLoad = true;
|
||||
$scope.loaded = true;
|
||||
if (!$rootScope.vaultSites) {
|
||||
@ -21,7 +28,7 @@
|
||||
setTimeout(setScrollY, 100);
|
||||
setTimeout(loadVault, 1000);
|
||||
}
|
||||
else {
|
||||
else if (!syncOnLoad) {
|
||||
loadVault();
|
||||
}
|
||||
|
||||
@ -43,11 +50,10 @@
|
||||
promises.push(sitePromise);
|
||||
|
||||
$q.all(promises).then(function () {
|
||||
if (decSites.length || !syncService.syncInProgress) {
|
||||
$scope.loaded = true;
|
||||
$rootScope.vaultFolders = decFolders;
|
||||
$rootScope.vaultSites = decSites;
|
||||
}
|
||||
|
||||
if (!delayLoad) {
|
||||
setScrollY();
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ function initApiService() {
|
||||
|
||||
function handleError(errorCallback, jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.status === 401 || jqXHR.status === 403) {
|
||||
chrome.runtime.sendMessage(null, { command: 'logout' });
|
||||
chrome.runtime.sendMessage({ command: 'logout' });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@ function initSyncService() {
|
||||
throw 'callback function required';
|
||||
}
|
||||
|
||||
syncStarted();
|
||||
|
||||
var self = this;
|
||||
|
||||
self.syncStarted();
|
||||
self.userService.isAuthenticated(function (isAuthenticated) {
|
||||
if (!isAuthenticated) {
|
||||
syncCompleted(false);
|
||||
self.syncCompleted(false);
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
@ -43,7 +43,7 @@ function initSyncService() {
|
||||
self.folderService.replace(folders, function () {
|
||||
self.siteService.replace(sites, function () {
|
||||
self.setLastSync(now, function () {
|
||||
syncCompleted(true);
|
||||
self.syncCompleted(true);
|
||||
callback(true);
|
||||
});
|
||||
});
|
||||
@ -169,15 +169,15 @@ function initSyncService() {
|
||||
});
|
||||
};
|
||||
|
||||
function syncStarted() {
|
||||
SyncService.prototype.syncStarted = function () {
|
||||
this.syncInProgress = true;
|
||||
chrome.runtime.sendMessage(null, { command: 'syncStarted' });
|
||||
}
|
||||
chrome.runtime.sendMessage({ command: 'syncStarted' });
|
||||
};
|
||||
|
||||
function syncCompleted(successfully) {
|
||||
SyncService.prototype.syncCompleted = function (successfully) {
|
||||
this.syncInProgress = false;
|
||||
chrome.runtime.sendMessage(null, { command: 'syncCompleted', successfully: successfully });
|
||||
}
|
||||
chrome.runtime.sendMessage({ command: 'syncCompleted', successfully: successfully });
|
||||
};
|
||||
|
||||
function handleError() {
|
||||
syncCompleted(false);
|
||||
|
Loading…
Reference in New Issue
Block a user