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

Loading…
Cancel
Save