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

33 lines
556 B
JavaScript
Raw Normal View History

2018-04-05 03:57:29 +01:00
import { createSelector } from 'reselect';
2020-01-13 16:55:28 -05:00
export const selectState = state => state.notifications || {};
2018-04-05 03:57:29 +01:00
2020-01-13 16:55:28 -05:00
export const selectToast = createSelector(
selectState,
state => {
if (state.toasts.length) {
const { id, params } = state.toasts[0];
return {
id,
...params,
};
}
return null;
2018-11-12 13:01:14 -05:00
}
2020-01-13 16:55:28 -05:00
);
2020-01-13 16:55:28 -05:00
export const selectError = createSelector(
selectState,
state => {
if (state.errors.length) {
const { error } = state.errors[0];
return {
error,
};
}
2020-01-13 16:55:28 -05:00
return null;
}
2020-01-13 16:55:28 -05:00
);