lbry-desktop/ui/component/channelSelector/index.js
Rafael f2558f19f9 Add a clear function when a channel selector component is used
- this way, you can choose an active channel for something like commenting but when that component is unmounted, you always go back to the default channel (like leaving page)
2022-05-05 11:24:22 -04:00

31 lines
1.2 KiB
JavaScript

import { connect } from 'react-redux';
import * as SETTINGS from 'constants/settings';
import { selectMyChannelClaims, selectClaimsByUri, selectOdyseeMembershipForUri } from 'redux/selectors/claims';
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
import { doFetchUserMemberships } from 'redux/actions/user';
import { doSetClientSetting } from 'redux/actions/settings';
import { selectClientSetting } from 'redux/selectors/settings';
import ChannelSelector from './view';
const select = (state, props) => {
const activeChannelClaim = selectActiveChannelClaim(state);
return {
channels: selectMyChannelClaims(state),
activeChannelClaim,
incognito: selectIncognito(state),
odyseeMembershipByUri: (uri) => selectOdyseeMembershipForUri(state, uri),
claimsByUri: selectClaimsByUri(state),
hasDefaultChannel: Boolean(selectClientSetting(state, SETTINGS.ACTIVE_CHANNEL_CLAIM)),
};
};
const perform = {
doSetActiveChannel,
doSetIncognito,
doFetchUserMemberships,
doSetClientSetting,
};
export default connect(select, perform)(ChannelSelector);