From 5ab165131f521f45b6cbbe743b536d8aa8855e50 Mon Sep 17 00:00:00 2001 From: jessop Date: Mon, 8 Jul 2019 16:54:58 -0400 Subject: [PATCH 1/5] adds user ability to block channels small changes blocked channels page most features done tweaks --- src/ui/analytics.js | 8 +++++ src/ui/component/blockButton/index.js | 15 +++++++++ src/ui/component/blockButton/view.jsx | 40 +++++++++++++++++++++++ src/ui/component/channelContent/index.js | 2 ++ src/ui/component/channelContent/view.jsx | 28 +++++++++++----- src/ui/component/claimPreview/index.js | 6 ++++ src/ui/component/claimPreview/view.jsx | 18 +++++++++- src/ui/component/common/icon-custom.jsx | 11 +++++++ src/ui/component/router/view.jsx | 2 ++ src/ui/component/subscribeButton/view.jsx | 4 +-- src/ui/constants/icons.js | 2 ++ src/ui/constants/pages.js | 1 + src/ui/page/channel/index.js | 4 +++ src/ui/page/channel/view.jsx | 20 ++++++++++-- src/ui/page/file/view.jsx | 2 +- src/ui/page/listBlocked/index.js | 12 +++++++ src/ui/page/listBlocked/view.jsx | 37 +++++++++++++++++++++ src/ui/page/settings/index.js | 3 +- src/ui/page/settings/view.jsx | 13 ++++++++ src/ui/reducers.js | 2 ++ src/ui/store.js | 3 ++ 21 files changed, 217 insertions(+), 16 deletions(-) create mode 100644 src/ui/component/blockButton/index.js create mode 100644 src/ui/component/blockButton/view.jsx create mode 100644 src/ui/page/listBlocked/index.js create mode 100644 src/ui/page/listBlocked/view.jsx diff --git a/src/ui/analytics.js b/src/ui/analytics.js index b4c6f4f80..2c887eeaa 100644 --- a/src/ui/analytics.js +++ b/src/ui/analytics.js @@ -89,6 +89,14 @@ const analytics: Analytics = { }); } }, + channelBlockEvent: (uri, blocked, location) => { + if (analyticsEnabled) { + ReactGA.event({ + category: blocked ? 'Channel-Hidden' : 'Channel-Unhidden', + action: uri, + }); + } + }, }; // Initialize google analytics diff --git a/src/ui/component/blockButton/index.js b/src/ui/component/blockButton/index.js new file mode 100644 index 000000000..f641ef9f1 --- /dev/null +++ b/src/ui/component/blockButton/index.js @@ -0,0 +1,15 @@ +import { connect } from 'react-redux'; +import { selectChannelIsBlocked, doToggleBlockChannel, doToast } from 'lbry-redux'; +import BlockButton from './view'; + +const select = (state, props) => ({ + channelIsBlocked: selectChannelIsBlocked(props.uri)(state), +}); + +export default connect( + select, + { + toggleBlockChannel: doToggleBlockChannel, + doToast, + } +)(BlockButton); diff --git a/src/ui/component/blockButton/view.jsx b/src/ui/component/blockButton/view.jsx new file mode 100644 index 000000000..912742b59 --- /dev/null +++ b/src/ui/component/blockButton/view.jsx @@ -0,0 +1,40 @@ +// @flow +import * as ICONS from 'constants/icons'; +import * as PAGES from 'constants/pages'; +import React, { useRef } from 'react'; +import Button from 'component/button'; +import useHover from 'util/use-hover'; + +type Props = { + uri: string, + isSubscribed: boolean, + toggleBlockChannel: (uri: string) => void, + channelIsBlocked: boolean, + doToast: ({ message: string, linkText: string, linkTarget: string }) => void, +}; + +export default function BlockButton(props: Props) { + const { uri, toggleBlockChannel, channelIsBlocked, doToast } = props; + + const blockRef = useRef(); + const isHovering = useHover(blockRef); + const blockLabel = channelIsBlocked ? __('Blocked') : __('Block'); + const blockedOverride = channelIsBlocked && isHovering && __('Unblock'); + + return ( +