Serialize calls to sendSyncMessage

Fixes #679

// FREEBIE
This commit is contained in:
lilia 2016-02-16 17:46:20 -08:00
parent 6154dbb8db
commit b602533084

View file

@ -167,16 +167,18 @@
}, },
sendSyncMessage: function() { sendSyncMessage: function() {
this.syncPromise = this.syncPromise || Promise.resolve();
this.syncPromise = this.syncPromise.then(function() {
var dataMessage = this.get('dataMessage'); var dataMessage = this.get('dataMessage');
if (this.get('synced') || !dataMessage) { if (this.get('synced') || !dataMessage) {
return; return;
} }
return textsecure.messaging.sendSyncMessage(
textsecure.messaging.sendSyncMessage(
dataMessage, this.get('sent_at'), this.get('destination') dataMessage, this.get('sent_at'), this.get('destination')
).then(function() { ).then(function() {
this.save({synced: true, dataMessage: null}); this.save({synced: true, dataMessage: null});
}.bind(this)); }.bind(this));
}.bind(this));
}, },
saveErrors: function(errors) { saveErrors: function(errors) {