fix: better subscribe button for both mobile and desktop

This commit is contained in:
Mr. X 2020-04-23 22:04:47 +05:30 committed by Sean Yesmunt
parent 4efc0fbd3e
commit f4c63f4fc3

View file

@ -36,27 +36,26 @@ export default function SubscribeButton(props: Props) {
doToast,
shrinkOnMobile = false,
} = props;
const buttonRef = useRef();
const isHovering = useHover(buttonRef);
const isMobile = useIsMobile();
let isHovering = useHover(buttonRef);
isHovering = isMobile ? true : isHovering;
const { channelName } = parseURI(permanentUrl);
const claimName = '@' + channelName;
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
const subscriptionLabel = isSubscribed ? __('Following') : __('Follow');
const unfollowOverride = isSubscribed && isHovering && __('Unfollow');
const label = isMobile && shrinkOnMobile ? '' : unfollowOverride || subscriptionLabel;
let longestStr = __('Following');
if (__('Following').length < __('Unfollow').length) {
longestStr = __('Unfollow');
}
return permanentUrl ? (
<Button
ref={buttonRef}
iconColor="red"
largestLabel={isSubscribed ? longestStr : undefined}
largestLabel={isMobile && shrinkOnMobile ? '' : subscriptionLabel}
icon={unfollowOverride ? ICONS.UNSUBSCRIBE : ICONS.SUBSCRIBE}
button={'alt'}
requiresAuth={IS_WEB}