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

Pranav Kant pranavk at collabora.co.uk
Tue Aug 1 14:38:38 UTC 2017


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

New commits:
commit 9fd3b29485e444ff30d0c41a2c6610ef052d8381
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/40618
    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 dd4ddb21..8e96efcc 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -100,6 +100,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