notification category filters

Summary:
Allows filtering notification by category. Category filters are also persisted in redux.

Adds a test suite for notification reducer

Reviewed By: passy

Differential Revision: D12999884

fbshipit-source-id: 5f8d2357e52f091c17b726e1f89ed68f3b7294fb
This commit is contained in:
Daniel Büchele
2018-11-12 01:47:52 -08:00
committed by Facebook Github Bot
parent 8cb715bb3a
commit bd03f891d0
4 changed files with 156 additions and 18 deletions

View File

@@ -15,6 +15,7 @@ import {selectPlugin} from '../reducers/connections';
import {
setActiveNotifications,
updatePluginBlacklist,
updateCategoryBlacklist,
} from '../reducers/notifications';
import {textContent} from '../utils/index';
import {clientPlugins} from '../plugins/index.js';
@@ -54,6 +55,14 @@ export default (store: Store, logger: Logger) => {
'notification-hide-category',
pluginNotification,
);
const {category} = pluginNotification.notification;
const {blacklistedCategories} = store.getState().notifications;
if (category && blacklistedCategories.indexOf(category) === -1) {
store.dispatch(
updateCategoryBlacklist([...blacklistedCategories, category]),
);
}
} else if (arg === 2) {
// Hide plugin
logger.track('usage', 'notification-hide-plugin', pluginNotification);
@@ -102,13 +111,19 @@ export default (store: Store, logger: Logger) => {
}
});
const {activeNotifications, blacklistedPlugins} = notifications;
const {
activeNotifications,
blacklistedPlugins,
blacklistedCategories,
} = notifications;
activeNotifications.forEach((n: PluginNotification) => {
if (
store.getState().connections.selectedPlugin !== 'notifications' &&
!knownNotifications.has(n.notification.id) &&
blacklistedPlugins.indexOf(n.pluginId) === -1
blacklistedPlugins.indexOf(n.pluginId) === -1 &&
(!n.notification.category ||
blacklistedCategories.indexOf(n.notification.category) === -1)
) {
ipcRenderer.send('sendNotification', {
payload: {