AbandonedChannelPreview: Handle blocked channels as well.
Issue 3800
This commit is contained in:
parent
be7eaff6f1
commit
86bae6eaee
2 changed files with 39 additions and 20 deletions
|
@ -1,10 +1,14 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { selectBlockedChannels } from 'lbry-redux';
|
||||||
import { doChannelUnsubscribe } from 'redux/actions/subscriptions';
|
import { doChannelUnsubscribe } from 'redux/actions/subscriptions';
|
||||||
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import AbandonedChannelPreview from './view';
|
import AbandonedChannelPreview from './view';
|
||||||
|
|
||||||
export default connect(
|
const select = (state, props) => ({
|
||||||
null,
|
blockedChannelUris: selectBlockedChannels(state),
|
||||||
{
|
});
|
||||||
doChannelUnsubscribe,
|
|
||||||
}
|
export default connect(select, {
|
||||||
)(AbandonedChannelPreview);
|
doChannelUnsubscribe,
|
||||||
|
doOpenModal,
|
||||||
|
})(AbandonedChannelPreview);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import { parseURI } from 'lbry-redux';
|
import { parseURI } from 'lbry-redux';
|
||||||
import * as ICONS from '../../constants/icons';
|
import * as ICONS from '../../constants/icons';
|
||||||
|
import * as MODALS from 'constants/modal_types';
|
||||||
|
|
||||||
type SubscriptionArgs = {
|
type SubscriptionArgs = {
|
||||||
channelName: string,
|
channelName: string,
|
||||||
|
@ -15,11 +16,14 @@ type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
doChannelUnsubscribe: SubscriptionArgs => void,
|
doChannelUnsubscribe: SubscriptionArgs => void,
|
||||||
type: string,
|
type: string,
|
||||||
|
blockedChannelUris: Array<string>,
|
||||||
|
doOpenModal: (string, {}) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function AbandonedChannelPreview(props: Props) {
|
function AbandonedChannelPreview(props: Props) {
|
||||||
const { uri, doChannelUnsubscribe, type } = props;
|
const { uri, doChannelUnsubscribe, type, blockedChannelUris, doOpenModal } = props;
|
||||||
const { channelName } = parseURI(uri);
|
const { channelName } = parseURI(uri);
|
||||||
|
const isBlockedChannel = blockedChannelUris.includes(uri);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={classnames('claim-preview__wrapper', 'claim-preview__wrapper--notice')}>
|
<li className={classnames('claim-preview__wrapper', 'claim-preview__wrapper--notice')}>
|
||||||
|
@ -33,20 +37,31 @@ function AbandonedChannelPreview(props: Props) {
|
||||||
<div className="media__subtitle">{__(`This channel may have been unpublished.`)}</div>
|
<div className="media__subtitle">{__(`This channel may have been unpublished.`)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="claim-preview__actions">
|
<div className="claim-preview__actions">
|
||||||
|
{isBlockedChannel && (
|
||||||
|
<Button
|
||||||
|
iconColor="red"
|
||||||
|
icon={ICONS.UNBLOCK}
|
||||||
|
button={'alt'}
|
||||||
|
label={__('Unblock')}
|
||||||
|
onClick={() => doOpenModal(MODALS.REMOVE_BLOCKED, { blockedUri: uri })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{/* SubscribeButton uses resolved permanentUri; modifying it didn't seem worth it. */}
|
{/* SubscribeButton uses resolved permanentUri; modifying it didn't seem worth it. */}
|
||||||
<Button
|
{!isBlockedChannel && (
|
||||||
iconColor="red"
|
<Button
|
||||||
icon={ICONS.UNSUBSCRIBE}
|
iconColor="red"
|
||||||
button={'alt'}
|
icon={ICONS.UNSUBSCRIBE}
|
||||||
label={__('Unfollow')}
|
button={'alt'}
|
||||||
onClick={e => {
|
label={__('Unfollow')}
|
||||||
e.stopPropagation();
|
onClick={e => {
|
||||||
doChannelUnsubscribe({
|
e.stopPropagation();
|
||||||
channelName: `@${channelName}`,
|
doChannelUnsubscribe({
|
||||||
uri,
|
channelName: `@${channelName}`,
|
||||||
});
|
uri,
|
||||||
}}
|
});
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue