JS: Fix for multiple Account instances (which caused multiple subscriptions.)

This commit is contained in:
Stefan Thomas
2013-03-07 11:38:51 +01:00
parent 8e8a10d90d
commit 93459dfcba
2 changed files with 12 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
// Routines for working with an account. // Routines for working with an account.
// //
// You should not instantiate this class yourself, instead use Remote#account.
//
// Events: // Events:
// wallet_clean : True, iff the wallet has been updated. // wallet_clean : True, iff the wallet has been updated.
// wallet_dirty : True, iff the wallet needs to be updated. // wallet_dirty : True, iff the wallet needs to be updated.

View File

@@ -1111,11 +1111,17 @@ Remote.prototype.request_owner_count = function (account, current) {
}; };
Remote.prototype.account = function (accountId) { Remote.prototype.account = function (accountId) {
accountId = UInt160.json_rewrite(accountId);
if (!this._accounts[accountId]) {
var account = new Account(this, accountId); var account = new Account(this, accountId);
if (!account.is_valid()) return account; if (!account.is_valid()) return account;
return this._accounts[account.to_json()] = account; this._accounts[accountId] = account;
}
return this._accounts[accountId];
}; };
Remote.prototype.book = function (currency_out, issuer_out, Remote.prototype.book = function (currency_out, issuer_out,
@@ -1130,7 +1136,7 @@ Remote.prototype.book = function (currency_out, issuer_out,
// Return the next account sequence if possible. // Return the next account sequence if possible.
// <-- undefined or Sequence // <-- undefined or Sequence
Remote.prototype.account_seq = function (account, advance) { Remote.prototype.account_seq = function (account, advance) {
var account = UInt160.json_rewrite(account); account = UInt160.json_rewrite(account);
var account_info = this.accounts[account]; var account_info = this.accounts[account];
var seq; var seq;