diff --git a/app/src/component/fileDownloadButton/index.js b/app/src/component/fileDownloadButton/index.js index c6e8563..89a2b8b 100644 --- a/app/src/component/fileDownloadButton/index.js +++ b/app/src/component/fileDownloadButton/index.js @@ -6,7 +6,7 @@ import { makeSelectLoadingForUri, makeSelectCostInfoForUri } from 'lbry-redux'; -import { doPurchaseUri, doStartDownload } from '../../redux/actions/file'; +import { doPurchaseUri, doStartDownload } from 'redux/actions/file'; import FileDownloadButton from './view'; const select = (state, props) => ({ diff --git a/app/src/component/subscribeNotificationButton/index.js b/app/src/component/subscribeNotificationButton/index.js new file mode 100644 index 0000000..bd4da01 --- /dev/null +++ b/app/src/component/subscribeNotificationButton/index.js @@ -0,0 +1,25 @@ +import { connect } from 'react-redux'; +import { + doChannelSubscriptionEnableNotifications, + doChannelSubscriptionDisableNotifications, + selectEnabledChannelNotifications, + selectSubscriptions, + makeSelectIsSubscribed, +} from 'lbryinc'; +import { doToast } from 'lbry-redux'; +import SubscribeNotificationButton from './view'; + +const select = (state, props) => ({ + enabledChannelNotifications: selectEnabledChannelNotifications(state), + subscriptions: selectSubscriptions(state), + isSubscribed: makeSelectIsSubscribed(props.uri, true)(state), +}); + +export default connect( + select, + { + doChannelSubscriptionEnableNotifications, + doChannelSubscriptionDisableNotifications, + doToast, + } +)(SubscribeNotificationButton); diff --git a/app/src/component/subscribeNotificationButton/view.js b/app/src/component/subscribeNotificationButton/view.js new file mode 100644 index 0000000..a600a48 --- /dev/null +++ b/app/src/component/subscribeNotificationButton/view.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { parseURI } from 'lbry-redux'; +import { NativeModules, Text, View, TouchableOpacity } from 'react-native'; +import Button from 'component/button'; +import Colors from 'styles/colors'; + +class SubscribeNotificationButton extends React.PureComponent { + render() { + const { + uri, + name, + doChannelSubscriptionEnableNotifications, + doChannelSubscriptionDisableNotifications, + doToast, + enabledChannelNotifications, + isSubscribed, + style + } = this.props; + + if (!isSubscribed) { + return null; + } + + let styles = []; + if (style) { + if (style.length) { + styles = styles.concat(style); + } else { + styles.push(style); + } + } + + const shouldNotify = enabledChannelNotifications.indexOf(name) > -1; + const { claimName } = parseURI(uri); + + return ( +