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

Pranav Kant pranavk at collabora.co.uk
Mon Aug 14 16:10:23 UTC 2017


 loleaflet/src/map/handler/Map.WOPI.js |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit f7e5b5f2e8eca1a857c1b0e0e361253c7334b717
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Jun 20 17:12:43 2017 +0530

    Warn users if they try to use post message API incorrectly
    
    Change-Id: I09ce1a14587f558765e02fc8197030f4a5d2cee0
    (cherry picked from commit 2abf2421f3e984693b114e8597d2e88fd1430ba8)
    Reviewed-on: https://gerrit.libreoffice.org/41138
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index b13bff44..70efcea4 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -104,6 +104,17 @@ L.Map.WOPI = L.Handler.extend({
 		}
 
 		var msg = JSON.parse(e.data);
+		if (msg.MessageId === 'Host_PostmessageReady') {
+			// We already have a listener for this in loleaflet.html, so ignore it here
+			return;
+		}
+
+		// For all other messages, warn if trying to interact before we are completely loaded
+		if (!this._appLoaded) {
+			console.error('LibreOffice Online not loaded yet. Listen for App_LoadingStatus (Document_Loaded) event before using PostMessage API. Ignoring post message \'' + msg.MessageId + '\'.');
+			return;
+		}
+
 		if (msg.MessageId === 'Insert_Button') {
 			if (msg.Values) {
 				if (msg.Values.id && !w2ui['toolbar-up'].get(msg.Values.id)


More information about the Libreoffice-commits mailing list