From 2c56c784678378fc8513e646d3bf869b9f0cedea Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 21 Jan 2019 17:11:31 +0100 Subject: [PATCH] Subscription notifications implementation (#407) * add notifications for unread subscriptions --- app/src/component/fileDownloadButton/index.js | 2 +- .../subscribeNotificationButton/index.js | 25 +++++ .../subscribeNotificationButton/view.js | 55 +++++++++++ app/src/index.js | 2 +- app/src/page/discover/index.js | 16 +++- app/src/page/discover/view.js | 61 +++++++++++- app/src/page/file/index.js | 3 +- app/src/page/file/view.js | 85 ++++++++++------- app/src/page/splash/index.js | 4 +- app/src/page/splash/view.js | 6 +- app/src/styles/downloads.js | 2 +- app/src/styles/filePage.js | 21 +++-- app/src/utils/helper.js | 35 ++++++- buildozer.spec.sample | 2 +- buildozer.spec.travis | 2 +- buildozer.spec.vagrant | 2 +- .../java/io/lbry/browser/MainActivity.java | 33 ++++--- .../reactmodules/DownloadManagerModule.java | 8 +- .../browser/reactmodules/UtilityModule.java | 93 +++++++++++++++++++ 19 files changed, 389 insertions(+), 68 deletions(-) create mode 100644 app/src/component/subscribeNotificationButton/index.js create mode 100644 app/src/component/subscribeNotificationButton/view.js diff --git a/app/src/component/fileDownloadButton/index.js b/app/src/component/fileDownloadButton/index.js index c6e85634..89a2b8b5 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 00000000..bd4da018 --- /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 00000000..a600a48a --- /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 ( +