Start listening for standard post messages and ignore deprecated ones (#126)

New online versions emits both the post messages (the older one with a
deprecated flag and newer one without). Ignore if the deprecated flag is
mentioned because it means that we would get another post message
without deprecated flag.
This commit is contained in:
Pranav Kant 2017-10-20 11:26:26 +02:00 committed by Andras Timar
parent 0434e383ba
commit 72cb1956b0

View File

@ -353,13 +353,25 @@ var documentsMain = {
}
try {
var msg = JSON.parse(e.data).MessageId;
var msg = JSON.parse(e.data);
var msgId = msg.MessageId;
var args = msg.Values;
var deprecated = !!args.Deprecated;
} catch(exc) {
msg = e.data;
msgId = e.data;
}
if (msg === 'UI_Close' || msg === 'close') {
if (msgId === 'UI_Close' || msgId === 'close' /* deprecated */) {
// If a postmesage API is deprecated, we must ignore it and wait for the standard postmessage
// (or it might already have been fired)
if (deprecated)
return;
documentsMain.onClose();
} else if (msg === 'rev-history') {
} else if (msgId === 'UI_FileVersions' || msgId === 'rev-history' /* deprecated */) {
if (deprecated)
return;
documentsMain.UI.showRevHistory(documentsMain.fullPath);
}
});