lbry-desktop/ui/js/selectors/user.js

76 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-06-08 02:56:52 +02:00
import { createSelector } from "reselect";
2017-06-01 18:20:12 +02:00
2017-06-08 02:56:52 +02:00
export const _selectState = state => state.user || {};
2017-06-01 18:20:12 +02:00
export const selectAuthenticationIsPending = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.authenticationIsPending
);
2017-06-01 18:20:12 +02:00
2017-06-08 23:15:34 +02:00
export const selectUserIsPending = createSelector(
_selectState,
state => state.userIsPending
);
2017-07-16 18:29:46 +02:00
export const selectUser = createSelector(_selectState, state => state.user);
2017-06-08 02:56:52 +02:00
export const selectEmailToVerify = createSelector(
2017-06-03 01:09:52 +02:00
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailToVerify
);
2017-07-19 01:00:13 +02:00
export const selectUserEmail = createSelector(
selectUser,
2017-07-20 21:03:01 +02:00
user => (user ? user.primary_email : null)
2017-06-08 02:56:52 +02:00
);
export const selectUserIsRewardApproved = createSelector(
selectUser,
2017-06-08 23:15:34 +02:00
user => user && user.is_reward_approved
2017-06-08 02:56:52 +02:00
);
2017-06-03 01:09:52 +02:00
export const selectEmailNewIsPending = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailNewIsPending
);
export const selectEmailNewErrorMessage = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailNewErrorMessage
);
export const selectEmailNewDeclined = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailNewDeclined
);
2017-06-03 01:09:52 +02:00
export const selectEmailVerifyIsPending = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailVerifyIsPending
);
2017-06-03 01:09:52 +02:00
export const selectEmailVerifyErrorMessage = createSelector(
_selectState,
2017-06-08 02:56:52 +02:00
state => state.emailVerifyErrorMessage
);
2017-07-19 01:00:13 +02:00
export const selectIdentityVerifyIsPending = createSelector(
_selectState,
state => state.identityVerifyIsPending
);
export const selectIdentityVerifyErrorMessage = createSelector(
_selectState,
state => state.identityVerifyErrorMessage
);
2017-06-08 02:56:52 +02:00
export const selectUserIsVerificationCandidate = createSelector(
selectUser,
2017-07-16 18:29:46 +02:00
user => user && (!user.has_verified_email || !user.is_identity_verified)
2017-06-08 02:56:52 +02:00
);
2017-07-21 08:23:39 +02:00
export const selectAccessToken = createSelector(
_selectState,
state => state.accessToken
);