From 0f372b2ed5b02519f782c1779e91ba1fe973b13b Mon Sep 17 00:00:00 2001 From: ClemDee Date: Thu, 27 Jun 2019 11:25:31 +0200 Subject: [PATCH] Operationnal dismissAll button & code restructuring --- www/common/notifications.js | 6 ++- www/common/sframe-common-mailbox.js | 1 - www/notifications/inner.js | 84 ++++++++++++++++++----------- 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/www/common/notifications.js b/www/common/notifications.js index de9f56a81..7f6070cf2 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -10,8 +10,10 @@ define([ var defaultDismiss = function (common, data) { return function (e) { - e.preventDefault(); - e.stopPropagation(); + if (e) { + e.preventDefault(); + e.stopPropagation(); + } common.mailbox.dismiss(data, function (err) { if (err) { return void console.error(err); } }); diff --git a/www/common/sframe-common-mailbox.js b/www/common/sframe-common-mailbox.js index c21af2f16..032d63a87 100644 --- a/www/common/sframe-common-mailbox.js +++ b/www/common/sframe-common-mailbox.js @@ -93,7 +93,6 @@ define([ var el; if (data.type === 'notifications') { Notifications.add(Common, data); - console.log(data); el = createElement(data); } f(data, el); diff --git a/www/notifications/inner.js b/www/notifications/inner.js index bb998a44e..a953b796f 100644 --- a/www/notifications/inner.js +++ b/www/notifications/inner.js @@ -36,59 +36,81 @@ define([ 'cp-notifications-all', ], 'friends': [ - 'cp-notifications-friend-requests', + 'cp-notifications-friends', ], 'pads': [ - 'cp-notifications-shared-app', + 'cp-notifications-pads', ], }; var create = {}; - var makeBlock = function (key, addButton) { - // Convert to camlCase for translation keys + // create the list of notifications + // show only notifs with type in filterTypes array. If filterTypes empty, don't filter. + var makeNotificationList = function (key, filterTypes) { + filterTypes = filterTypes || []; var safeKey = key.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); + var categoryName = Messages['notification_cat_' + safeKey] || safeKey; + var notifsData = []; var $div = $('
', {'class': 'cp-notifications-' + key + ' cp-sidebarlayout-element'}); - $('