|
|
|
@ -970,8 +970,19 @@ define([
|
|
|
|
|
var getApi = function (cb) {
|
|
|
|
|
return function () {
|
|
|
|
|
require(['/api/broadcast?'+ (+new Date())], function (Broadcast) {
|
|
|
|
|
// XXX require.s.contexts._ can be used to erase old loaded objects
|
|
|
|
|
cb(Broadcast);
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
try {
|
|
|
|
|
var ctx = require.s.contexts._;
|
|
|
|
|
var defined = ctx.defined;
|
|
|
|
|
Object.keys(defined).forEach(function (href) {
|
|
|
|
|
if (/^\/api\/broadcast\?[0-9]{13}/.test(href)) {
|
|
|
|
|
delete defined[href];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
@ -1061,7 +1072,7 @@ define([
|
|
|
|
|
var form = h('div.cp-admin-broadcast-form');
|
|
|
|
|
var $form = $(form).appendTo($div);
|
|
|
|
|
|
|
|
|
|
var refresh = getApi(function (/* Broadcast */) { // XXX unused argument
|
|
|
|
|
var refresh = getApi(function (Broadcast) {
|
|
|
|
|
var button = h('button.btn.btn-primary', Messages.admin_broadcastButton);
|
|
|
|
|
var $button = $(button);
|
|
|
|
|
var removeButton = h('button.btn.btn-danger', Messages.admin_broadcastCancel);
|
|
|
|
@ -1071,8 +1082,7 @@ define([
|
|
|
|
|
var deleted = [];
|
|
|
|
|
|
|
|
|
|
// Render active message (if there is one)
|
|
|
|
|
require(['/api/broadcast?'+ (+new Date())], function (BCast) {
|
|
|
|
|
var hash = BCast.lastBroadcastHash || '1'; // Truthy value if no lastKnownHash
|
|
|
|
|
var hash = Broadcast.lastBroadcastHash || '1'; // Truthy value if no lastKnownHash
|
|
|
|
|
common.mailbox.getNotificationsHistory('broadcast', null, hash, function (e, msgs) {
|
|
|
|
|
if (e) { return void console.error(e); }
|
|
|
|
|
if (!Array.isArray(msgs)) { return; }
|
|
|
|
@ -1109,7 +1119,6 @@ define([
|
|
|
|
|
});
|
|
|
|
|
if (!activeUid) { $active.hide(); }
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Custom message
|
|
|
|
|
var container = h('div.cp-broadcast-container');
|
|
|
|
|