lbry-desktop/ui/component/channelBlockButton/view.jsx

42 lines
936 B
React
Raw Normal View History

// @flow
import React from 'react';
import Button from 'component/button';
type Props = {
uri: string,
isBlocked: boolean,
isBlockingOrUnBlocking: boolean,
2021-06-11 22:49:18 +02:00
doCommentModUnBlock: (string, boolean) => void,
doCommentModBlock: (string, boolean) => void,
};
function ChannelBlockButton(props: Props) {
const { uri, doCommentModUnBlock, doCommentModBlock, isBlocked, isBlockingOrUnBlocking } = props;
function handleClick() {
if (isBlocked) {
2021-06-11 22:49:18 +02:00
doCommentModUnBlock(uri, false);
} else {
2021-06-11 22:49:18 +02:00
doCommentModBlock(uri, false);
}
}
return (
<Button
button={isBlocked ? 'alt' : 'secondary'}
label={
isBlocked
? isBlockingOrUnBlocking
? __('Unblocking...')
: __('Unblock')
: isBlockingOrUnBlocking
2021-06-11 22:49:18 +02:00
? __('Blocking...')
: __('Block')
}
onClick={handleClick}
/>
);
}
export default ChannelBlockButton;