From 5ad1504494d5ded9c79b154346780b1b136f3017 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Tue, 22 Dec 2015 18:05:13 -0500 Subject: [PATCH] handle socketio reconnect situation --- app/assets/javascripts/src/Metamaps.js.erb | 10 ++++++++-- app/assets/stylesheets/junto.css.erb | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index bfdc694a..7776dafd 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -1918,6 +1918,7 @@ Metamaps.Realtime = { webrtc: null, readyToCall: false, mappersOnMap: {}, + disconnected: false, chatOpen: false, status: true, // stores whether realtime is True/On or False/Off, broadcastingStatus: false, @@ -1943,7 +1944,12 @@ Metamaps.Realtime = { self.socket = new SocketIoConnection({ url: whichToConnect }); self.socket.on('connect', function () { console.log('connected'); - self.startActiveMap(); + if (!self.disconnected) { + self.startActiveMap(); + } else self.disconnected = false; + }); + self.socket.on('disconnect', function () { + self.disconnected = true; }); if (Metamaps.Active.Mapper) { @@ -2171,7 +2177,7 @@ Metamaps.Realtime = { var self = Metamaps.Realtime; self.webrtc.off('readyToCall'); - self.webrtc.on('readyToCall', function () { + self.webrtc.once('readyToCall', function () { self.videoInitialized = true; self.readyToCall = true; self.localVideo.view.$container.show(); diff --git a/app/assets/stylesheets/junto.css.erb b/app/assets/stylesheets/junto.css.erb index 1b8eac25..b84f9a07 100644 --- a/app/assets/stylesheets/junto.css.erb +++ b/app/assets/stylesheets/junto.css.erb @@ -110,6 +110,9 @@ background: url(<%= asset_path 'junto.png' %>) no-repeat 2px 9px, url(<%= asset_path 'tray_tab.png' %>) no-repeat; cursor: pointer; } +.chat-box .chat-button.active { + background: url(<%= asset_path 'junto.gif' %>) no-repeat 2px 9px, url(<%= asset_path 'tray_tab.png' %>) no-repeat !important; +} .chat-box .chat-button .chat-unread { display: none; background: #DAB539;