Warn users if they try to use post message API incorrectly

Change-Id: I09ce1a14587f558765e02fc8197030f4a5d2cee0
This commit is contained in:
Pranav Kant 2017-06-20 17:12:43 +05:30
parent 8ca5efb671
commit 2abf2421f3

View file

@ -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)