loleaflet/src/core/Socket.js |   14 +++++---------
 loleaflet/src/map/Map.js     |    3 +++
 2 files changed, 8 insertions(+), 9 deletions(-)

New commits:
commit c8ddd967534cebfcd068c96e9934b40a0b925224
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Apr 24 16:54:23 2016 -0400

    loleaflet: track active state in Map, not Socket
    
    Change-Id: Id6f699a8d491e361a0c091989cee0f1257703324
    Reviewed-on: https://gerrit.libreoffice.org/24352
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 35a8017..9efb60f 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -8,7 +8,6 @@ L.Socket = L.Class.extend({
 
        initialize: function (map) {
                this._map = map;
-               this._active = true;
                try {
                        this.socket = new WebSocket(map.options.server + '/' + 
map.options.doc);
                } catch (e) {
@@ -35,18 +34,11 @@ L.Socket = L.Class.extend({
        },
 
        sendMessage: function (msg, coords) {
-               if (!msg.startsWith('useractive') && 
!msg.startsWith('userinactive') && !this._active) {
+               if (!msg.startsWith('useractive') && 
!msg.startsWith('userinactive') && !this._map._active) {
                        // Avoid communicating when we're inactive.
                        return;
                }
 
-               if (msg.startsWith('useractive')) {
-                       this._active = true;
-               }
-               else if (msg.startsWith('userinactive')) {
-                       this._active = false;
-               }
-
                var socketState = this.socket.readyState;
                if (socketState === 2 || socketState === 3) {
                        this.initialize(this._map);
@@ -269,6 +261,10 @@ L.Socket = L.Class.extend({
 
        _onSocketClose: function () {
                this.hideBusy();
+               if (this._map) {
+                       this._map._active = false;
+               }
+
                if (this.fail) {
                        this.fire('error', {msg: _('Well, this is embarrassing, 
we cannot connect to your document. Please try again.'), cmd: 'socket', kind: 
'closed', id: 4});
                }
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 2923f8c..5a8cd68 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -62,6 +62,7 @@ L.Map = L.Evented.extend({
                this._zoomBoundLayers = {};
                this._sizeChanged = true;
                this._bDisableKeyboard = false;
+               this._active = true;
 
                this.callInitHooks();
 
@@ -698,6 +699,8 @@ L.Map = L.Evented.extend({
        _deactivate: function () {
                var map = this;
                vex.timer = setTimeout(function() {
+                       L.Log.log("Deactivating");
+                       this._active = false;
                        clearTimeout(vex.timer);
 
                        options = $.extend({}, vex.defaultOptions, {contentCSS: 
{"background":"rgba(0, 0, 0, 0)"}});
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to