lbry-desktop/ui/redux/selectors/notifications.js
2020-06-16 09:56:32 -04:00

26 lines
510 B
JavaScript

import { createSelector } from 'reselect';
export const selectState = state => state.notifications || {};
export const selectToast = createSelector(selectState, state => {
if (state.toasts.length) {
const { id, params } = state.toasts[0];
return {
id,
...params,
};
}
return null;
});
export const selectError = createSelector(selectState, state => {
if (state.errors.length) {
const { error } = state.errors[0];
return {
error,
};
}
return null;
});