From 0cbe14acf5f11636abce5ca1c740cc7c8dc7aa24 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 27 Apr 2020 15:09:29 +0200 Subject: [PATCH] Ability to disable comments notifications --- www/common/outer/mailbox-handlers.js | 5 +++-- www/settings/inner.js | 33 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index cc90861c1..0998a4511 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -534,9 +534,10 @@ define([ var msg = data.msg; var hash = data.hash; var content = msg.content; - // content.channel - //if (isMuted(ctx, data)) { return void cb(true); } + if (Util.find(ctx.store.proxy, ['settings', 'pad', 'disableNotif'])) { + return void cb(true); + } var channel = content.channel; if (!channel) { return void cb(true); } diff --git a/www/settings/inner.js b/www/settings/inner.js index 5541277ed..9353b2c64 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -78,6 +78,7 @@ define([ 'pad': [ 'cp-settings-pad-width', 'cp-settings-pad-spellcheck', + 'cp-settings-pad-notif', ], 'code': [ 'cp-settings-code-indent-unit', @@ -1275,6 +1276,38 @@ define([ return $div; }; + // XXX Messages.settings_padNotifTitle + // XXX Messages.settings_padNotifHint + // XXX Messages.settings_padNotifCheckbox ("disable comments notifications") + Messages.settings_padNotifTitle = "Comments notifications"; // XXX + Messages.settings_padNotifHint = "Block notifications when someone replies to one of your comments"; // XXX + Messages.settings_padNotifCheckbox = "Disable comment notifications"; + makeBlock('pad-notif', function (cb) { + var $cbox = $(UI.createCheckbox('cp-settings-pad-notif', + Messages.settings_padNotifCheckbox, + false, { label: {class: 'noTitle'} })); + + var spinner = UI.makeSpinner($cbox); + + // Checkbox: "Enable safe links" + var $checkbox = $cbox.find('input').on('change', function () { + spinner.spin(); + var val = $checkbox.is(':checked'); + common.setAttribute(['pad', 'disableNotif'], val, function () { + spinner.done(); + }); + }); + + common.getAttribute(['pad', 'disableNotif'], function (e, val) { + if (e) { return void console.error(e); } + if (val === true) { + $checkbox.attr('checked', 'checked'); + } + }); + + cb($cbox); + }, true); + // Code settings create['code-indent-unit'] = function () {