diff --git a/src/js/services/blob.js b/src/js/services/blob.js index 751659178..4946dc5e1 100644 --- a/src/js/services/blob.js +++ b/src/js/services/blob.js @@ -178,7 +178,7 @@ module.factory('rpBlob', ['$rootScope', function ($scope) }); }; - BlobObj.prototype.applyUpdate = function (op, path, params) { + BlobObj.prototype.applyUpdate = function(op, path, params, callback) { // Exchange from numeric op code to string if ("number" === typeof op) { op = BlobObj.opsReverseMap[op]; @@ -197,8 +197,11 @@ module.factory('rpBlob', ['$rootScope', function ($scope) this._traverse(this.data, pointer, path, op, params); - this.persist(function(){ + this.persist(function(err, data) { console.log('Blob saved'); + if (typeof callback === 'function') { + callback(err, data); + } }); }; @@ -298,7 +301,7 @@ module.factory('rpBlob', ['$rootScope', function ($scope) * This method adds an entry to the beginning of an array. */ BlobObj.prototype.unshift = function (pointer, value, callback) { - this.applyUpdate('unshift', pointer, [value]); + this.applyUpdate('unshift', pointer, [value], callback); }; function normalizeSubcommands(subcommands, compress) { diff --git a/src/js/tabs/send.js b/src/js/tabs/send.js index a2a2196f1..136f02a01 100644 --- a/src/js/tabs/send.js +++ b/src/js/tabs/send.js @@ -809,7 +809,7 @@ SendTab.prototype.angular = function (module) } }; - $scope.saveAddress = function () { + $scope.saveAddress = function() { $scope.addressSaving = true; var contact = { @@ -818,7 +818,8 @@ SendTab.prototype.angular = function (module) address: $scope.send.recipient_address }; - $scope.userBlob.unshift('/contacts', contact, function(err, data){ + $scope.userBlob.unshift('/contacts', contact, function(err, data) { + $scope.addressSaving = false; if (err) { console.log("Can't save the contact. ", err); return; @@ -829,7 +830,7 @@ SendTab.prototype.angular = function (module) }); }; - $scope.$on("$destroy", function () { + $scope.$on("$destroy", function() { // Stop pathfinding if the user leaves the tab if ($scope.send.pathfind) { $scope.send.pathfind.close();