lbry-redux/src/redux/selectors/notifications.js

31 lines
804 B
JavaScript
Raw Normal View History

2018-04-05 03:57:29 +01:00
import { createSelector } from 'reselect';
export const selectState = state => state.notifications || {};
export const selectNotificationData = createSelector(
2018-04-05 03:57:29 +01:00
selectState,
state => (state.queue.length > 0 ? state.queue[0] : {})
);
export const selectNotification = createSelector(
selectNotificationData,
notificationData => notificationData.notification
);
export const selectNotificationProps = createSelector(
selectNotificationData,
notificationData => notificationData.notificationProps
);
export const selectSnack = createSelector(
// No props for snackbar
selectNotification,
notification => {
if (notification && notification.displayType) {
return notification.displayType.indexOf('snackbar') > -1 ? notification : undefined;
}
return undefined;
}
);