2020-06-15 22:33:03 +02:00
|
|
|
import REWARD_TYPES from 'rewards';
|
2020-04-13 21:16:07 +02:00
|
|
|
import { connect } from 'react-redux';
|
2021-02-17 19:25:52 +01:00
|
|
|
import { selectGetSyncIsPending, selectSyncHash, selectPrefsReady } from 'redux/selectors/sync';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { doClaimRewardType } from 'redux/actions/rewards';
|
2020-09-15 15:54:05 +02:00
|
|
|
import { doSetClientSetting } from 'redux/actions/settings';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { selectClaimedRewards, makeSelectIsRewardClaimPending } from 'redux/selectors/rewards';
|
|
|
|
import { doUserFetch } from 'redux/actions/user';
|
2020-04-13 21:16:07 +02:00
|
|
|
import {
|
2020-06-15 22:33:03 +02:00
|
|
|
selectUserIsPending,
|
|
|
|
selectYoutubeChannels,
|
2020-04-13 21:16:07 +02:00
|
|
|
selectEmailToVerify,
|
|
|
|
selectUser,
|
|
|
|
selectAccessToken,
|
2020-06-15 22:33:03 +02:00
|
|
|
} from 'redux/selectors/user';
|
2020-07-10 23:04:36 +02:00
|
|
|
import {
|
|
|
|
selectMyChannelClaims,
|
|
|
|
selectBalance,
|
|
|
|
selectFetchingMyChannels,
|
|
|
|
selectCreatingChannel,
|
|
|
|
SETTINGS,
|
|
|
|
} from 'lbry-redux';
|
2020-04-13 21:16:07 +02:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
2020-09-04 22:11:28 +02:00
|
|
|
import { selectInterestedInYoutubeSync } from 'redux/selectors/app';
|
|
|
|
import { doToggleInterestedInYoutubeSync } from 'redux/actions/app';
|
2020-04-13 21:16:07 +02:00
|
|
|
import UserSignIn from './view';
|
|
|
|
|
2021-02-17 19:25:52 +01:00
|
|
|
const select = (state) => ({
|
2020-04-13 21:16:07 +02:00
|
|
|
emailToVerify: selectEmailToVerify(state),
|
|
|
|
user: selectUser(state),
|
|
|
|
accessToken: selectAccessToken(state),
|
|
|
|
channels: selectMyChannelClaims(state),
|
|
|
|
claimedRewards: selectClaimedRewards(state),
|
|
|
|
claimingReward: makeSelectIsRewardClaimPending()(state, {
|
|
|
|
reward_type: REWARD_TYPES.TYPE_CONFIRM_EMAIL,
|
|
|
|
}),
|
|
|
|
balance: selectBalance(state),
|
|
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
|
|
|
youtubeChannels: selectYoutubeChannels(state),
|
|
|
|
userFetchPending: selectUserIsPending(state),
|
|
|
|
syncEnabled: makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state),
|
2020-08-24 06:00:10 +02:00
|
|
|
followingAcknowledged: makeSelectClientSetting(SETTINGS.FOLLOWING_ACKNOWLEDGED)(state),
|
|
|
|
tagsAcknowledged: makeSelectClientSetting(SETTINGS.TAGS_ACKNOWLEDGED)(state),
|
|
|
|
rewardsAcknowledged: makeSelectClientSetting(SETTINGS.REWARDS_ACKNOWLEDGED)(state),
|
2020-04-13 21:16:07 +02:00
|
|
|
syncingWallet: selectGetSyncIsPending(state),
|
|
|
|
hasSynced: Boolean(selectSyncHash(state)),
|
|
|
|
creatingChannel: selectCreatingChannel(state),
|
2020-09-04 22:11:28 +02:00
|
|
|
interestedInYoutubeSync: selectInterestedInYoutubeSync(state),
|
2021-02-17 19:25:52 +01:00
|
|
|
prefsReady: selectPrefsReady(state),
|
2020-04-13 21:16:07 +02:00
|
|
|
});
|
|
|
|
|
2021-02-17 19:25:52 +01:00
|
|
|
const perform = (dispatch) => ({
|
2020-04-13 21:16:07 +02:00
|
|
|
fetchUser: () => dispatch(doUserFetch()),
|
2020-08-27 19:56:18 +02:00
|
|
|
claimConfirmEmailReward: () =>
|
2020-04-13 21:16:07 +02:00
|
|
|
dispatch(
|
|
|
|
doClaimRewardType(REWARD_TYPES.TYPE_CONFIRM_EMAIL, {
|
|
|
|
notifyError: false,
|
|
|
|
})
|
|
|
|
),
|
2020-08-27 19:56:18 +02:00
|
|
|
claimNewUserReward: () =>
|
|
|
|
dispatch(
|
|
|
|
doClaimRewardType(REWARD_TYPES.NEW_USER, {
|
|
|
|
notifyError: false,
|
|
|
|
})
|
|
|
|
),
|
2020-09-15 15:54:05 +02:00
|
|
|
setClientSetting: (setting, value, pushToPrefs) => dispatch(doSetClientSetting(setting, value, pushToPrefs)),
|
2020-09-04 22:11:28 +02:00
|
|
|
doToggleInterestedInYoutubeSync: () => dispatch(doToggleInterestedInYoutubeSync()),
|
2020-04-13 21:16:07 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(select, perform)(UserSignIn);
|