Namespace events
Naming conflict was firing the error handler twice. // FREEBIE
This commit is contained in:
parent
6e74ac9e28
commit
20586e2dcc
3 changed files with 22 additions and 22 deletions
|
@ -43,12 +43,12 @@
|
|||
function init() {
|
||||
if (!textsecure.registration.isDone()) { return; }
|
||||
|
||||
window.addEventListener('message', onMessageReceived);
|
||||
window.addEventListener('receipt', onDeliveryReceipt);
|
||||
window.addEventListener('contact', onContactReceived);
|
||||
window.addEventListener('group', onGroupReceived);
|
||||
window.addEventListener('sent', onSentMessage);
|
||||
window.addEventListener('error', onError);
|
||||
window.addEventListener('textsecure:message', onMessageReceived);
|
||||
window.addEventListener('textsecure:receipt', onDeliveryReceipt);
|
||||
window.addEventListener('textsecure:contact', onContactReceived);
|
||||
window.addEventListener('textsecure:group', onGroupReceived);
|
||||
window.addEventListener('textsecure:sent', onSentMessage);
|
||||
window.addEventListener('textsecure:error', onError);
|
||||
|
||||
// initialize the socket and start listening for messages
|
||||
messageReceiver = new textsecure.MessageReceiver(window);
|
||||
|
|
|
@ -39500,7 +39500,7 @@ function generateKeys(count, progressCallback) {
|
|||
if (e.code === 1006) {
|
||||
// possible 403. Make an request to confirm
|
||||
TextSecureServer.getDevices(textsecure.storage.user.getNumber()).catch(function(e) {
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = e;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
});
|
||||
|
@ -39532,7 +39532,7 @@ function generateKeys(count, progressCallback) {
|
|||
}.bind(this)).catch(function(e) {
|
||||
request.respond(500, 'Bad encrypted websocket message');
|
||||
console.log("Error handling incoming message:", e);
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = e;
|
||||
this.target.dispatchEvent(ev);
|
||||
}.bind(this));
|
||||
|
@ -39545,7 +39545,7 @@ function generateKeys(count, progressCallback) {
|
|||
}
|
||||
},
|
||||
onDeliveryReceipt: function (envelope) {
|
||||
var ev = new Event('receipt');
|
||||
var ev = new Event('textsecure:receipt');
|
||||
ev.proto = envelope;
|
||||
this.target.dispatchEvent(ev);
|
||||
},
|
||||
|
@ -39556,7 +39556,7 @@ function generateKeys(count, progressCallback) {
|
|||
envelope.type,
|
||||
ciphertext
|
||||
).catch(function(error) {
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = error;
|
||||
ev.proto = envelope;
|
||||
this.target.dispatchEvent(ev);
|
||||
|
@ -39566,7 +39566,7 @@ function generateKeys(count, progressCallback) {
|
|||
handleSentMessage: function(destination, timestamp, message) {
|
||||
var source = textsecure.storage.user.getNumber();
|
||||
return processDecrypted(message, source).then(function(message) {
|
||||
var ev = new Event('sent');
|
||||
var ev = new Event('textsecure:sent');
|
||||
ev.data = {
|
||||
destination : destination,
|
||||
timestamp : timestamp.toNumber(),
|
||||
|
@ -39581,7 +39581,7 @@ function generateKeys(count, progressCallback) {
|
|||
close_session();
|
||||
}
|
||||
return processDecrypted(message, envelope.source).then(function(message) {
|
||||
var ev = new Event('message');
|
||||
var ev = new Event('textsecure:message');
|
||||
ev.data = {
|
||||
source : envelope.source,
|
||||
timestamp : envelope.timestamp.toNumber(),
|
||||
|
@ -39641,7 +39641,7 @@ function generateKeys(count, progressCallback) {
|
|||
var contactBuffer = new ContactBuffer(attachmentPointer.data);
|
||||
var contactDetails = contactBuffer.next();
|
||||
while (contactDetails !== undefined) {
|
||||
var ev = new Event('contact');
|
||||
var ev = new Event('textsecure:contact');
|
||||
ev.contactDetails = contactDetails;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
contactDetails = contactBuffer.next();
|
||||
|
@ -39669,7 +39669,7 @@ function generateKeys(count, progressCallback) {
|
|||
);
|
||||
}
|
||||
}).then(function() {
|
||||
var ev = new Event('group');
|
||||
var ev = new Event('textsecure:group');
|
||||
ev.groupDetails = groupDetails;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
});
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
if (e.code === 1006) {
|
||||
// possible 403. Make an request to confirm
|
||||
TextSecureServer.getDevices(textsecure.storage.user.getNumber()).catch(function(e) {
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = e;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
});
|
||||
|
@ -69,7 +69,7 @@
|
|||
}.bind(this)).catch(function(e) {
|
||||
request.respond(500, 'Bad encrypted websocket message');
|
||||
console.log("Error handling incoming message:", e);
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = e;
|
||||
this.target.dispatchEvent(ev);
|
||||
}.bind(this));
|
||||
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
},
|
||||
onDeliveryReceipt: function (envelope) {
|
||||
var ev = new Event('receipt');
|
||||
var ev = new Event('textsecure:receipt');
|
||||
ev.proto = envelope;
|
||||
this.target.dispatchEvent(ev);
|
||||
},
|
||||
|
@ -93,7 +93,7 @@
|
|||
envelope.type,
|
||||
ciphertext
|
||||
).catch(function(error) {
|
||||
var ev = new Event('error');
|
||||
var ev = new Event('textsecure:error');
|
||||
ev.error = error;
|
||||
ev.proto = envelope;
|
||||
this.target.dispatchEvent(ev);
|
||||
|
@ -103,7 +103,7 @@
|
|||
handleSentMessage: function(destination, timestamp, message) {
|
||||
var source = textsecure.storage.user.getNumber();
|
||||
return processDecrypted(message, source).then(function(message) {
|
||||
var ev = new Event('sent');
|
||||
var ev = new Event('textsecure:sent');
|
||||
ev.data = {
|
||||
destination : destination,
|
||||
timestamp : timestamp.toNumber(),
|
||||
|
@ -118,7 +118,7 @@
|
|||
close_session();
|
||||
}
|
||||
return processDecrypted(message, envelope.source).then(function(message) {
|
||||
var ev = new Event('message');
|
||||
var ev = new Event('textsecure:message');
|
||||
ev.data = {
|
||||
source : envelope.source,
|
||||
timestamp : envelope.timestamp.toNumber(),
|
||||
|
@ -178,7 +178,7 @@
|
|||
var contactBuffer = new ContactBuffer(attachmentPointer.data);
|
||||
var contactDetails = contactBuffer.next();
|
||||
while (contactDetails !== undefined) {
|
||||
var ev = new Event('contact');
|
||||
var ev = new Event('textsecure:contact');
|
||||
ev.contactDetails = contactDetails;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
contactDetails = contactBuffer.next();
|
||||
|
@ -206,7 +206,7 @@
|
|||
);
|
||||
}
|
||||
}).then(function() {
|
||||
var ev = new Event('group');
|
||||
var ev = new Event('textsecure:group');
|
||||
ev.groupDetails = groupDetails;
|
||||
eventTarget.dispatchEvent(ev);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue