From 875cee7b32d2c18ba75228a517821d37578acf0c Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 30 Mar 2021 17:59:54 +0200 Subject: [PATCH] broadcast fixes --- www/admin/inner.js | 20 +++++++++++++++++++- www/common/outer/mailbox-handlers.js | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/www/admin/inner.js b/www/admin/inner.js index 73f836a9f..32dcf3886 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -1381,6 +1381,14 @@ define([ }); refresh(); + Common.makeUniversal('broadcast', { + onEvent: function (obj) { + var cmd = obj.ev; + if (cmd !== "MAINTENANCE") { return; } + refresh(); + } + }); + return $div; }; create['survey'] = function () { @@ -1435,7 +1443,9 @@ define([ return; } // Maintenance applied, send notification - common.mailbox.sendTo('BROADCAST_SURVEY', {}, {}, function (err, data) { + common.mailbox.sendTo('BROADCAST_SURVEY', { + url: data + }, {}, function (err, data) { refresh(); checkLastBroadcastHash(); }); @@ -1465,6 +1475,14 @@ define([ }); refresh(); + Common.makeUniversal('broadcast', { + onEvent: function (obj) { + var cmd = obj.ev; + if (cmd !== "SURVEY") { return; } + refresh(); + } + }); + return $div; }; diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 7751fd5d7..f9cfd994d 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -697,6 +697,7 @@ define([ var activeSurvey; handlers['BROADCAST_SURVEY'] = function (ctx, box, data, cb) { var msg = data.msg; + var content = msg.content; var uid = msg.uid; var old = activeSurvey; activeSurvey = { @@ -704,7 +705,8 @@ define([ hash: data.hash }; ctx.Store.onSurveyUpdate(uid); - cb(false, old); + var dismiss = !content.url; + cb(dismiss, old); }; var activeCustom handlers['BROADCAST_CUSTOM'] = function (ctx, box, data, cb) {