sync tokens

This commit is contained in:
Mo Bitar
2016-12-30 09:53:02 -06:00
parent d5d1b2b7f7
commit b2f1077fef
7 changed files with 63 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
angular.module('app.frontend')
.directive("header", function(){
.directive("header", function(apiController){
return {
restrict: 'E',
scope: {
@@ -13,7 +13,9 @@ angular.module('app.frontend')
bindToController: true,
link:function(scope, elem, attrs, ctrl) {
scope.$on("sync:updated_token", function(){
ctrl.syncUpdated();
})
}
}
})
@@ -69,12 +71,18 @@ angular.module('app.frontend')
}
}
this.getLastRefreshDate = function() {
return apiController.lastRefreshDate;
this.refreshData = function() {
apiController.sync(function(response){
if(!response) {
alert("There was an error syncing. Please try again. If all else fails, log out and log back in.");
} else {
this.syncUpdated();
}
}.bind(this));
}
this.refreshData = function() {
apiController.sync(null);
this.syncUpdated = function() {
this.lastSyncDate = new Date();
}
this.loginSubmitPressed = function() {

View File

@@ -9,16 +9,17 @@ angular.module('app.frontend')
$scope.tags = modelManager.tags;
$scope.allTag.notes = modelManager.notes;
apiController.sync(null);
// refresh every 30s
setInterval(function () {
apiController.sync(null);
}, 1000);
}, 30000);
// apiController.verifyEncryptionStatusOfAllItems($scope.defaultUser, function(success){});
}
apiController.getCurrentUser(function(user){
if(user) {
// console.log("Get user response", user);
$scope.defaultUser = user;
$rootScope.title = "Notes — Standard Notes";
onUserSet();