Merge branch 'broadcast' into calendar

pull/1/head
yflory 4 years ago
commit b91f29dd1d

@ -141,7 +141,7 @@ var args_isMaintenance = function (args) {
var makeBroadcastSetter = function (attr, validation) {
return function (Env, args) {
if ((validation && !validation(args)) || !args_isString(args)) {
if ((validation && !validation(args)) && !args_isString(args)) {
throw new Error('INVALID_ARGS');
}
var str = args[0];

@ -1240,7 +1240,7 @@ define([
var send = function (data) {
$button.prop('disabled', 'disabled');
data.time = +new Date(); // XXX not used anymore?
common.mailbox.sendTo('BROADCAST_CUSTOM', data, {}, function (err /*, data */) { // XXX unused argument
common.mailbox.sendTo('BROADCAST_CUSTOM', data, {}, function (err) {
if (err) {
$button.prop('disabled', '');
console.error(err);
@ -1265,7 +1265,7 @@ define([
if (!activeUid) { return; }
common.mailbox.sendTo('BROADCAST_DELETE', {
uid: activeUid
}, {}, function (err /* , data */) { // XXX unused argument
}, {}, function (err) {
if (err) { return UI.warn(Messages.error); }
UI.log(Messages.saved);
refresh();
@ -1360,7 +1360,7 @@ define([
return;
}
// Maintenance applied, send notification
common.mailbox.sendTo('BROADCAST_MAINTENANCE', {}, {}, function (/* err, data */) { // XXX unused arguments
common.mailbox.sendTo('BROADCAST_MAINTENANCE', {}, {}, function () {
refresh();
checkLastBroadcastHash();
});
@ -1456,7 +1456,7 @@ define([
// Maintenance applied, send notification
common.mailbox.sendTo('BROADCAST_SURVEY', {
url: data
}, {}, function (/* err, data */) { // XXX unused arguments
}, {}, function () {
refresh();
checkLastBroadcastHash();
});

@ -415,7 +415,7 @@ define([
};
content.handler = function () {
common.openUnsafeURL(msg.url);
// XXX dismiss on click?
defaultDismiss(common, data)();
};
if (!content.archived) {
content.dismissHandler = defaultDismiss(common, data);
@ -440,7 +440,6 @@ define([
toShow = Util.fixHTML(toShow);
content.getFormatText = function () {
// XXX Add a title to custom messages? Or use a generic key in the notification and only display the text in the alert?
if (slice) {
return toShow.slice(0, 200) + '...';
}
@ -448,13 +447,11 @@ define([
};
if (slice) {
content.handler = function () {
// XXX Allow markdown (sanitized)?
var content = h('div', [
h('h4', Messages.broadcast_newCustom),
h('div.cp-admin-message', toShow)
]);
UI.alert(content);
// XXX Dismiss on click?
};
}
if (!content.archived) {

@ -217,11 +217,16 @@ define([
});
};
var historyState = false;
var onHistory = function () {};
var onHistoryEnd;
mailbox.getMoreHistory = function (type, count, lastKnownHash, cb) {
if (type !== "broadcast" && historyState) { return void cb("ALREADY_CALLED"); }
historyState = true;
if (type === "broadcast" && onHistoryEnd) {
onHistoryEnd.reg(cb);
return;
}
if (onHistoryEnd) { return void cb("ALREADY_CALLED"); }
onHistoryEnd = Util.mkEvent();
onHistoryEnd.reg(cb);
var txid = Util.uid();
execCommand('LOAD_HISTORY', {
type: type,
@ -237,8 +242,8 @@ define([
if (data.complete) {
onHistory = function () {};
var end = messages.length < count;
cb(null, messages, end);
historyState = false;
onHistoryEnd.fire(null, messages, end);
onHistoryEnd = undefined;
return;
}
if (data.hash !== lastKnownHash) {

Loading…
Cancel
Save