Merge pull request #915 from neuroscr/dupfix

Try to address duplicate open group message issues after sleep
pull/933/head
Ryan Tharp 6 years ago committed by GitHub
commit 20c7a42356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,6 +24,8 @@
/* eslint-disable more/no-then */ /* eslint-disable more/no-then */
/* eslint-disable no-unreachable */ /* eslint-disable no-unreachable */
let openGroupBound = false;
function MessageReceiver(username, password, signalingKey, options = {}) { function MessageReceiver(username, password, signalingKey, options = {}) {
this.count = 0; this.count = 0;
@ -51,11 +53,15 @@ function MessageReceiver(username, password, signalingKey, options = {}) {
// only do this once to prevent duplicates // only do this once to prevent duplicates
if (lokiPublicChatAPI) { if (lokiPublicChatAPI) {
// bind events window.log.info('Binding open group events handler', openGroupBound);
lokiPublicChatAPI.on( if (!openGroupBound) {
'publicMessage', // clear any previous binding
this.handleUnencryptedMessage.bind(this) lokiPublicChatAPI.removeAllListeners('publicMessage');
); // we only need one MR in the system handling these
// bind events
lokiPublicChatAPI.on('publicMessage', this.handleUnencryptedMessage.bind(this));
openGroupBound = true;
}
} else { } else {
window.log.error('Can not handle open group data, API is not available'); window.log.error('Can not handle open group data, API is not available');
} }

Loading…
Cancel
Save