From 835d4fbb139185a0026a24bb2f25ae55d7ee2baf Mon Sep 17 00:00:00 2001 From: Bruno Barbieri Date: Tue, 6 Aug 2019 15:33:41 -0400 Subject: Update mobile sync (#6967) * update mobile sync * update lockfile --- ui/app/pages/mobile-sync/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ui/app/pages/mobile-sync/index.js') diff --git a/ui/app/pages/mobile-sync/index.js b/ui/app/pages/mobile-sync/index.js index 7fc3b540b..bd2385808 100644 --- a/ui/app/pages/mobile-sync/index.js +++ b/ui/app/pages/mobile-sync/index.js @@ -84,6 +84,9 @@ class MobileSyncPage extends Component { } initWebsockets () { + // Make sure there are no existing listeners + this.disconnectWebsockets() + this.pubnub = new PubNub({ subscribeKey: process.env.PUBNUB_SUB_KEY, publishKey: process.env.PUBNUB_PUB_KEY, @@ -91,7 +94,7 @@ class MobileSyncPage extends Component { ssl: true, }) - this.pubnubListener = this.pubnub.addListener({ + this.pubnubListener = { message: (data) => { const {channel, message} = data // handle message @@ -111,7 +114,9 @@ class MobileSyncPage extends Component { this.setState({syncing: false, completed: true}) } }, - }) + } + + this.pubnub.addListener(this.pubnubListener) this.pubnub.subscribe({ channels: [this.channelName], @@ -122,7 +127,7 @@ class MobileSyncPage extends Component { disconnectWebsockets () { if (this.pubnub && this.pubnubListener) { - this.pubnub.disconnect(this.pubnubListener) + this.pubnub.removeListener(this.pubnubListener) } } -- cgit