Disable calendar notifications

pull/1/head
yflory 4 years ago
parent 6de01a79b4
commit 8ebc71cd96

@ -109,7 +109,8 @@ define([
} }
var send = function () { var send = function () {
console.error(ev); var hide = Util.find(ctx, ['store', 'proxy', 'settings', 'general', 'calendar', 'hideNotif']);
if (hide) { console.error('hidden'); return; }
ctx.store.mailbox.showMessage('reminders', { ctx.store.mailbox.showMessage('reminders', {
msg: { msg: {
ctime: +new Date(), ctime: +new Date(),

@ -520,7 +520,10 @@ proxy.mailboxes = {
msg: ctx.boxes[type].content[h], msg: ctx.boxes[type].content[h],
hash: h hash: h
}; };
showMessage(ctx, type, message, cId); showMessage(ctx, type, message, cId, function (obj) {
Notify.system(undefined, obj.msg);
cb();
});
}); });
}); });
// Subscribe to new notifications // Subscribe to new notifications
@ -610,7 +613,10 @@ proxy.mailboxes = {
// Hide existing messages for this event // Hide existing messages for this event
hideMessage(ctx, type, msg.hash, ctx.clients); hideMessage(ctx, type, msg.hash, ctx.clients);
} }
showMessage(ctx, type, msg, cId, cb); showMessage(ctx, type, msg, cId, function (obj) {
Notify.system(undefined, obj.msg);
if (cb) { cb(); }
});
}; };
mailbox.open = function (key, m, cb, team, opts) { mailbox.open = function (key, m, cb, team, opts) {

@ -95,6 +95,9 @@ define([
'kanban': [ // Msg.settings_cat_kanban 'kanban': [ // Msg.settings_cat_kanban
'cp-settings-kanban-tags', 'cp-settings-kanban-tags',
], ],
'notifications': [
'cp-settings-notif-calendar'
],
'subscription': { 'subscription': {
onClick: function() { onClick: function() {
var urls = common.getMetadataMgr().getPrivateData().accounts; var urls = common.getMetadataMgr().getPrivateData().accounts;
@ -1566,6 +1569,43 @@ define([
cb($d); cb($d);
}, true); }, true);
Messages.settings_notifCalendarTitle = "Calendar notifications";
Messages.settings_notifCalendarHint = "You can disable completely calendar notifications for incoming events.";
Messages.settings_notifCalendarCheckbox = "Enable calendar notifications";
makeBlock('notif-calendar', function(cb) { // Msg.settings_notifCalendarHint, .settings_notifCalendarTitle
var $cbox = $(UI.createCheckbox('cp-settings-cache',
Messages.settings_notifCalendarCheckbox,
false, { label: { class: 'noTitle' } }));
var spinner = UI.makeSpinner($cbox);
var $checkbox = $cbox.find('input').on('change', function() {
spinner.spin();
var val = !$checkbox.is(':checked');
common.setAttribute(['general', 'calendar', 'hideNotif'], val, function(e) {
if (e) {
console.error(e);
// error: restore previous value
if (val) { $checkbox.attr('checked', ''); }
else { $checkbox.attr('checked', 'checked'); }
spinner.hide();
return void console.error(e);
}
spinner.done();
});
});
common.getAttribute(['general', 'calendar', 'hideNotif'], function(e, val) {
if (e) { return void console.error(e); }
if (!val) {
$checkbox.attr('checked', 'checked');
}
});
cb($cbox[0]);
}, true);
// Settings app // Settings app
var createUsageButton = function() { var createUsageButton = function() {
@ -1595,8 +1635,10 @@ define([
subscription: 'fa fa-star-o', subscription: 'fa fa-star-o',
kanban: 'cptools cptools-kanban', kanban: 'cptools cptools-kanban',
style: 'cptools cptools-palette', style: 'cptools cptools-palette',
notifications: 'fa fa-bell'
}; };
Messages.settings_cat_notifications = Messages.notificationsPage;
var createLeftside = function() { var createLeftside = function() {
var $categories = $('<div>', { 'class': 'cp-sidebarlayout-categories' }) var $categories = $('<div>', { 'class': 'cp-sidebarlayout-categories' })
.appendTo(APP.$leftside); .appendTo(APP.$leftside);

Loading…
Cancel
Save