[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/src

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Apr 18 09:53:18 UTC 2017


 loleaflet/src/core/Socket.js |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

New commits:
commit 1ef7285a3b09cdd0184962d0746fca2ba812a734
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Apr 16 15:00:53 2017 -0400

    loleaflet: reconnect when load fails due to unloading
    
    Retry up to 10 times with a delay of 1 second in between.
    
    Also, show the user a message (after first reconnection
    fails) that the document is unloading to try again
    (but of course we auto-retry anyway).
    
    Change-Id: I616d7643f146a6d5b7ccda7bb2aa567e3a9efe47
    Reviewed-on: https://gerrit.libreoffice.org/36596
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 5479788e52f52c1a039ad72d1f78bfb0c310ce50)
    Reviewed-on: https://gerrit.libreoffice.org/36606
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index c2ef985b..8870f8cb 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -6,6 +6,7 @@
 /* global _ vex $ errorMessages */
 L.Socket = L.Class.extend({
 	ProtocolVersionNumber: '0.1',
+	ReconnectCount: 0,
 
 	getParameterValue: function (s) {
 		var i = s.indexOf('=');
@@ -358,6 +359,26 @@ L.Socket = L.Class.extend({
 			} else if (errorKind.startsWith('faileddocloading')) {
 				this._map._fatal = true;
 				this._map.fire('error', {msg: errorMessages.faileddocloading});
+			} else if (errorKind.startsWith('docunloading')) {
+				// The document is unloading. Have to wait a bit.
+				this._map._active = false;
+				if (vex.dialogID <= 0 && this.ReconnectCount > 0) {
+					this._map.fire('error', {msg: _('The document is currently unloading. Please try again.'), cmd: 'socket', kind: 'closed', id: 4});
+				}
+
+				if (this.ReconnectCount++ >= 10) {
+					clearTimeout(vex.timer);
+					return; // Give up.
+				}
+
+				map = this._map;
+				vex.timer = setInterval(function() {
+					try {
+						// Activate and cancel timer and dialogs.
+						map._activate();
+					} catch (error) {
+					}
+				}, 1000);
 			}
 
 			if (passwordNeeded) {
@@ -418,6 +439,16 @@ L.Socket = L.Class.extend({
 		else if (textMsg.startsWith('statusindicator:')) {
 			//FIXME: We should get statusindicator when saving too, no?
 			this._map.showBusy(_('Connecting...'), false);
+			if (textMsg.startsWith('statusindicator: ready')) {
+				// We're connected: cancel timer and dialog.
+				this.ReconnectCount = 0;
+				clearTimeout(vex.timer);
+				if (vex.dialogID > 0) {
+					var id = vex.dialogID;
+					vex.dialogID = -1;
+					vex.close(id);
+				}
+			}
 		}
 		else if (!textMsg.startsWith('tile:') && !textMsg.startsWith('renderfont:')) {
 			// log the tile msg separately as we need the tile coordinates


More information about the Libreoffice-commits mailing list