Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
[FIX] Send: save contact after send fix
Browse files Browse the repository at this point in the history
When saving new contact after send, actually
show that contact was saved.
  • Loading branch information
darkdarkdragon committed Aug 19, 2015
1 parent f771f46 commit 57eb12b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/js/services/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
}
});
};

Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions src/js/tabs/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ SendTab.prototype.angular = function (module)
}
};

$scope.saveAddress = function () {
$scope.saveAddress = function() {
$scope.addressSaving = true;

var contact = {
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 57eb12b

Please # to comment.