aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-01-31 15:14:58 +0800
committerkumavis <aaron@kumavis.me>2016-01-31 15:14:58 +0800
commit2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27 (patch)
tree82e4f760b58987a7051567934c5c18ed4b3f3ed8 /app/scripts/lib
parenta91d576213f6a22a3f785b9877b2617147500b58 (diff)
downloadtangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar.gz
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar.bz2
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar.lz
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar.xz
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.tar.zst
tangerine-wallet-browser-2aa38ac4b44c21bd3a26de90fa23beb8ffbb6f27.zip
util - stream-provider - fix batch
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/stream-provider.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/scripts/lib/stream-provider.js b/app/scripts/lib/stream-provider.js
index 5a77979ee..8390cab8a 100644
--- a/app/scripts/lib/stream-provider.js
+++ b/app/scripts/lib/stream-provider.js
@@ -22,7 +22,11 @@ StreamProvider.prototype.send = function(payload){
StreamProvider.prototype.sendAsync = function(payload, callback){
// console.log('StreamProvider - sending payload', payload)
- this._payloads[payload.id] = [payload, callback]
+ var id = payload.id
+ if (Array.isArray(payload)) {
+ id = 'batch'+payload[0].id
+ }
+ this._payloads[id] = [payload, callback]
// console.log('payload for plugin:', payload)
this.push(payload)
}
@@ -31,9 +35,13 @@ StreamProvider.prototype.sendAsync = function(payload, callback){
StreamProvider.prototype._onResponse = function(response){
// console.log('StreamProvider - got response', payload)
- var data = this._payloads[response.id]
+ var id = response.id
+ if (Array.isArray(response)) {
+ id = 'batch'+response[0].id
+ }
+ var data = this._payloads[id]
if (!data) throw new Error('StreamProvider - Unknown response id')
- delete this._payloads[response.id]
+ delete this._payloads[id]
var payload = data[0]
var callback = data[1]