Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f609fa900 | ||
|
|
5329154121 | ||
|
|
3a9187d795 | ||
|
|
e4e23e8017 | ||
|
|
9638ad4f06 | ||
|
|
c8de700460 | ||
|
|
e0f746b5ae | ||
|
|
9efcc36e15 | ||
|
|
918a7e64bd | ||
|
|
7f6874b791 | ||
|
|
1731462b41 | ||
|
|
654d50cd1b |
No files matched your search
Generated
+4
-4
@@ -4060,8 +4060,8 @@
|
||||
}
|
||||
},
|
||||
"lbry-redux": {
|
||||
"version": "github:lbryio/lbry-redux#18fec9f1f0f5ad366ebe12279e5dd0d67a37b2d5",
|
||||
"from": "github:lbryio/lbry-redux#mobile-channel-pagination",
|
||||
"version": "github:lbryio/lbry-redux#3ab065b11a52d3e2e6a50a25459f9ff0aac03b13",
|
||||
"from": "github:lbryio/lbry-redux",
|
||||
"requires": {
|
||||
"proxy-polyfill": "0.1.6",
|
||||
"reselect": "^3.0.0",
|
||||
@@ -4076,8 +4076,8 @@
|
||||
}
|
||||
},
|
||||
"lbryinc": {
|
||||
"version": "github:lbryio/lbryinc#4d24cef00106294d3e848b6c2b261e01382fce17",
|
||||
"from": "github:lbryio/lbryinc#subscriptions",
|
||||
"version": "github:lbryio/lbryinc#fff1a8979f9aca6ce7e8917396270704cc497f82",
|
||||
"from": "github:lbryio/lbryinc",
|
||||
"requires": {
|
||||
"bluebird": "^3.5.1",
|
||||
"lbry-redux": "github:lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404",
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@
|
||||
"dependencies": {
|
||||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"lbry-redux": "lbryio/lbry-redux#mobile-channel-pagination",
|
||||
"lbryinc": "lbryio/lbryinc#subscriptions",
|
||||
"lbry-redux": "lbryio/lbry-redux#old-search",
|
||||
"lbryinc": "lbryio/lbryinc",
|
||||
"moment": "^2.22.1",
|
||||
"react": "16.2.0",
|
||||
"react-native": "0.55.3",
|
||||
|
||||
@@ -38,6 +38,7 @@ import { doDeleteCompleteBlobs } from 'redux/actions/file';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { SETTINGS, doDismissToast, doToast, selectToast } from 'lbry-redux';
|
||||
import {
|
||||
doUserCheckEmailVerified,
|
||||
doUserEmailVerify,
|
||||
doUserEmailVerifyFailure,
|
||||
selectEmailToVerify,
|
||||
@@ -114,7 +115,7 @@ const myLbryStack = createStackNavigator({
|
||||
Downloads: {
|
||||
screen: DownloadsPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'My LBRY',
|
||||
title: 'Downloads',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
headerTitleStyle: discoverStyle.titleText
|
||||
})
|
||||
@@ -125,7 +126,7 @@ const mySubscriptionsStack = createStackNavigator({
|
||||
Subscriptions: {
|
||||
screen: SubscriptionsPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'My Subscriptions',
|
||||
title: 'Subscriptions',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
headerTitleStyle: discoverStyle.titleText
|
||||
})
|
||||
@@ -172,16 +173,16 @@ const drawer = createDrawerNavigator({
|
||||
title: 'Trending', drawerIcon: ({ tintColor }) => <Icon name="fire" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
MySubscriptionsStack: { screen: mySubscriptionsStack, navigationOptions: {
|
||||
title: 'My Subscriptions', drawerIcon: ({ tintColor }) => <Icon name="rss-square" size={20} style={{ color: tintColor }} />
|
||||
title: 'Subscriptions', drawerIcon: ({ tintColor }) => <Icon name="heart" solid={true} size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
WalletStack: { screen: walletStack, navigationOptions: {
|
||||
title: 'Wallet', drawerIcon: ({ tintColor }) => <Icon name="wallet" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
Rewards: { screen: rewardsStack, navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="trophy" size={20} style={{ color: tintColor }} />
|
||||
drawerIcon: ({ tintColor }) => <Icon name="award" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
MyLBRYStack: { screen: myLbryStack, navigationOptions: {
|
||||
title: 'My LBRY', drawerIcon: ({ tintColor }) => <Icon name="folder" size={20} style={{ color: tintColor }} />
|
||||
title: 'Downloads', drawerIcon: ({ tintColor }) => <Icon name="folder" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
Settings: { screen: SettingsPage, navigationOptions: {
|
||||
drawerLockMode: 'locked-closed',
|
||||
@@ -235,8 +236,10 @@ class AppWithNavigationState extends React.Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.emailVerifyCheckInterval = null;
|
||||
this.state = {
|
||||
emailVerifyDone: false
|
||||
emailVerifyDone: false,
|
||||
verifyPending: false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -262,15 +265,37 @@ class AppWithNavigationState extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000);
|
||||
Linking.addEventListener('url', this._handleUrl);
|
||||
}
|
||||
|
||||
checkEmailVerification = () => {
|
||||
const { dispatch } = this.props;
|
||||
AsyncStorage.getItem(Constants.KEY_EMAIL_VERIFY_PENDING).then(pending => {
|
||||
this.setState({ verifyPending: ('true' === pending) });
|
||||
if ('true' === pending) {
|
||||
dispatch(doUserCheckEmailVerified());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.removeEventListener('hardwareBackPress');
|
||||
Linking.removeEventListener('url', this._handleUrl);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const { user } = this.props;
|
||||
if (this.state.verifyPending && this.emailVerifyCheckInterval > 0 && user && user.has_verified_email) {
|
||||
clearInterval(this.emailVerifyCheckInterval);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false');
|
||||
this.setState({ verifyPending: false });
|
||||
|
||||
ToastAndroid.show('Your email address was successfully verified.', ToastAndroid.LONG);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps) {
|
||||
const { dispatch } = this.props;
|
||||
const {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doUserEmailNew,
|
||||
doUserResendVerificationEmail,
|
||||
selectEmailNewErrorMessage,
|
||||
selectEmailNewIsPending,
|
||||
selectEmailToVerify
|
||||
selectEmailToVerify,
|
||||
} from 'lbryinc';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import EmailRewardSubcard from './view';
|
||||
@@ -16,7 +17,8 @@ const select = state => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
notify: data => dispatch(doToast(data))
|
||||
notify: data => dispatch(doToast(data)),
|
||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(EmailRewardSubcard);
|
||||
@@ -18,6 +18,8 @@ import rewardStyle from '../../styles/reward';
|
||||
class EmailRewardSubcard extends React.PureComponent {
|
||||
state = {
|
||||
email: null,
|
||||
emailAlreadySet: false,
|
||||
previousEmail: null,
|
||||
verfiyStarted: false
|
||||
};
|
||||
|
||||
@@ -25,9 +27,9 @@ class EmailRewardSubcard extends React.PureComponent {
|
||||
const { emailToVerify } = this.props;
|
||||
AsyncStorage.getItem(Constants.KEY_FIRST_RUN_EMAIL).then(email => {
|
||||
if (email && email.trim().length > 0) {
|
||||
this.setState({ email });
|
||||
this.setState({ email, emailAlreadySet: true, previousEmail: email });
|
||||
} else {
|
||||
this.setState({ email: emailToVerify });
|
||||
this.setState({ email: emailToVerify, previousEmail: emailToVerify });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -41,9 +43,8 @@ class EmailRewardSubcard extends React.PureComponent {
|
||||
notify({ message: String(emailNewErrorMessage), isError: true });
|
||||
this.setState({ verifyStarted: false });
|
||||
} else {
|
||||
notify({
|
||||
message: 'Please follow the instructions in the email sent to your address to continue.',
|
||||
});
|
||||
notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +60,7 @@ class EmailRewardSubcard extends React.PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const { addUserEmail, notify } = this.props;
|
||||
const { addUserEmail, notify, resendVerificationEmail } = this.props;
|
||||
const { email } = this.state;
|
||||
if (!email || email.trim().length === 0 || email.indexOf('@') === -1) {
|
||||
return notify({
|
||||
@@ -68,6 +69,14 @@ class EmailRewardSubcard extends React.PureComponent {
|
||||
}
|
||||
|
||||
this.setState({ verifyStarted: true });
|
||||
if (this.state.emailAlreadySet && this.state.previousEmail === email) {
|
||||
// resend verification email if there was one previously set (and it wasn't changed)
|
||||
resendVerificationEmail(email);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
|
||||
notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
|
||||
return;
|
||||
}
|
||||
|
||||
addUserEmail(email);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,15 @@ class FileItem extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
navigateToFileUri = () => {
|
||||
const { navigation, uri } = this.props;
|
||||
const normalizedUri = normalizeURI(uri);
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Discover Tap', { Uri: normalizeURI });
|
||||
}
|
||||
navigateToUri(navigation, normalizedUri);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
claim,
|
||||
@@ -42,7 +51,10 @@ class FileItem extends React.PureComponent {
|
||||
rewardedContentClaimIds,
|
||||
style,
|
||||
mediaStyle,
|
||||
navigation
|
||||
navigation,
|
||||
showDetails,
|
||||
compactView,
|
||||
titleBeforeThumbnail
|
||||
} = this.props;
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
@@ -51,36 +63,34 @@ class FileItem extends React.PureComponent {
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const channelName = claim ? claim.channel_name : null;
|
||||
const channelClaimId = claim && claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
|
||||
const height = claim ? claim.height : null;
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<TouchableOpacity style={discoverStyle.container} onPress={() => {
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Discover Tap', { Uri: uri });
|
||||
}
|
||||
navigateToUri(navigation, uri);
|
||||
}
|
||||
}>
|
||||
<TouchableOpacity style={discoverStyle.container} onPress={this.navigateToFileUri}>
|
||||
{!compactView && titleBeforeThumbnail && <Text style={[discoverStyle.fileItemName, discoverStyle.rewardTitle]}>{title}</Text>}
|
||||
<FileItemMedia title={title}
|
||||
thumbnail={thumbnail}
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
resizeMode="cover"
|
||||
isResolvingUri={isResolvingUri}
|
||||
style={mediaStyle} />
|
||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
||||
<View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
|
||||
|
||||
{!compactView && <FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />}
|
||||
{!compactView && <View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
|
||||
<Text style={[discoverStyle.fileItemName, discoverStyle.rewardTitle]}>{title}</Text>
|
||||
{isRewardContent && <Icon style={discoverStyle.rewardIcon} name="award" size={20} />}
|
||||
</View>
|
||||
</View>}
|
||||
{(!compactView && showDetails) &&
|
||||
<View style={discoverStyle.detailsRow}>
|
||||
{channelName &&
|
||||
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
||||
const channelUri = normalizeURI(channelName);
|
||||
navigateToUri(navigation, channelUri);
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />}
|
||||
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo block={height} />
|
||||
</View>
|
||||
</View>}
|
||||
</TouchableOpacity>
|
||||
{obscureNsfw && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
|
||||
</View>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import * as React from 'react';
|
||||
import { buildURI } from 'lbry-redux';
|
||||
import { FlatList } from 'react-native';
|
||||
import FileItem from '../fileItem';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import FileItem from 'component/fileItem';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
// In the future, all Flow types need to be specified in a common source (lbry-redux, perhaps?)
|
||||
type FileInfo = {
|
||||
@@ -145,7 +145,15 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
sortFunctions: {};
|
||||
|
||||
render() {
|
||||
const { fileInfos, hideFilter, checkPending, navigation, style } = this.props;
|
||||
const {
|
||||
contentContainerStyle,
|
||||
fileInfos,
|
||||
hideFilter,
|
||||
checkPending,
|
||||
navigation,
|
||||
onEndReached,
|
||||
style
|
||||
} = this.props;
|
||||
const { sortBy } = this.state;
|
||||
const items = [];
|
||||
|
||||
@@ -170,12 +178,16 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
return (
|
||||
<FlatList
|
||||
style={style}
|
||||
contentContainerStyle={contentContainerStyle}
|
||||
data={items}
|
||||
onEndReached={onEndReached}
|
||||
keyExtractor={(item, index) => item}
|
||||
renderItem={({item}) => (
|
||||
<FileItem style={discoverStyle.fileItem}
|
||||
uri={item}
|
||||
navigation={navigation} />
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
compactView={false} />
|
||||
)} />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectIsUriResolving,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from '../../redux/selectors/settings';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileListItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
|
||||
@@ -63,11 +63,13 @@ class FileListItem extends React.PureComponent {
|
||||
const isResolving = !fileInfo && isResolvingUri;
|
||||
const title = fileInfo ? fileInfo.metadata.title : metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
|
||||
|
||||
let name, channel, height;
|
||||
let name, channel, height, channelClaimId, fullChannelUri;
|
||||
if (claim) {
|
||||
name = claim.name;
|
||||
channel = claim.channel_name;
|
||||
height = claim.height;
|
||||
channelClaimId = claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -90,8 +92,7 @@ class FileListItem extends React.PureComponent {
|
||||
{(title || name) && <Text style={fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
|
||||
{channel &&
|
||||
<Link style={fileListStyle.publisher} text={channel} onPress={() => {
|
||||
const channelUri = normalizeURI(channel);
|
||||
navigateToUri(navigation, channelUri);
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />}
|
||||
|
||||
<View style={fileListStyle.info}>
|
||||
|
||||
@@ -44,6 +44,10 @@ class RewardSummary extends React.Component {
|
||||
render() {
|
||||
const { fetching, navigation, unclaimedRewardAmount, user } = this.props;
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.state.dismissed ||
|
||||
(user && user.is_reward_approved) ||
|
||||
this.state.actionsLeft === 0 ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
|
||||
import Button from '../button';
|
||||
import Colors from '../../styles/colors';
|
||||
@@ -39,7 +39,7 @@ class SubscribeButton extends React.PureComponent {
|
||||
onPress={() => {
|
||||
subscriptionHandler({
|
||||
channelName: claimName,
|
||||
uri,
|
||||
uri: normalizeURI(uri),
|
||||
});
|
||||
}} />
|
||||
);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectClaimsInChannelForPage,
|
||||
doFetchClaimsByChannel,
|
||||
doResolveUris,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import SuggestedSubscriptionItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claims: makeSelectClaimsInChannelForPage(props.categoryLink)(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
|
||||
resolveUris: uris => dispatch(doResolveUris(uris, true)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(SuggestedSubscriptionItem);
|
||||
@@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import { buildURI, normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FileItem from 'component/fileItem';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
|
||||
class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { fetching, categoryLink, fetchChannel, resolveUris, claims } = this.props;
|
||||
if (!fetching && categoryLink && (!claims || claims.length)) {
|
||||
fetchChannel(categoryLink);
|
||||
}
|
||||
}
|
||||
|
||||
uriForClaim = (claim) => {
|
||||
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = claim;
|
||||
const uriParams = {};
|
||||
|
||||
// This is unfortunate
|
||||
// https://github.com/lbryio/lbry/issues/1159
|
||||
const name = claimName || claimNameDownloaded;
|
||||
uriParams.contentName = name;
|
||||
uriParams.claimId = claimId;
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { categoryLink, fetching, obscureNsfw, claims, navigation } = this.props;
|
||||
|
||||
if (!claims || !claims.length) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (claims && claims.length > 0) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.suggestedContainer}>
|
||||
<FileItem
|
||||
style={subscriptionsStyle.fileItem}
|
||||
mediaStyle={subscriptionsStyle.fileItemMedia}
|
||||
uri={this.uriForClaim(claims[0])}
|
||||
navigation={navigation} />
|
||||
{(claims.length > 1) &&
|
||||
<FlatList style={subscriptionsStyle.compactItems}
|
||||
horizontal={true}
|
||||
renderItem={ ({item}) => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.compactFileItem}
|
||||
mediaStyle={subscriptionsStyle.compactFileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
compactView={true} />
|
||||
)
|
||||
}
|
||||
data={claims.slice(1, 4).map(claim => this.uriForClaim(claim))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default SuggestedSubscriptionItem;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'lbryinc';
|
||||
import SuggestedSubscriptions from './view';
|
||||
|
||||
const select = state => ({
|
||||
suggested: selectSuggestedChannels(state),
|
||||
loading: selectIsFetchingSuggested(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
null
|
||||
)(SuggestedSubscriptions);
|
||||
@@ -0,0 +1,52 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import Link from 'component/link';
|
||||
|
||||
class SuggestedSubscriptions extends React.PureComponent {
|
||||
render() {
|
||||
const { suggested, loading, navigation } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return suggested ? (
|
||||
<SectionList style={subscriptionsStyle.scrollContainer}
|
||||
renderItem={ ({item, index, section}) => (
|
||||
<SuggestedSubscriptionItem
|
||||
key={item}
|
||||
categoryLink={normalizeURI(item)}
|
||||
navigation={navigation} />
|
||||
)
|
||||
}
|
||||
renderSectionHeader={
|
||||
({section: {title}}) => {
|
||||
const titleParts = title.split(';');
|
||||
const channelName = titleParts[0];
|
||||
const channelUri = normalizeURI(titleParts[1]);
|
||||
return (
|
||||
<View style={subscriptionsStyle.titleRow}>
|
||||
<Link style={subscriptionsStyle.channelTitle} text={channelName} href={channelUri} />
|
||||
<SubscribeButton style={subscriptionsStyle.subscribeButton} uri={channelUri} name={channelName} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
sections={suggested.map(({ uri, label }) => ({ title: (label + ';' + uri), data: [uri] }))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
) : null;
|
||||
}
|
||||
}
|
||||
|
||||
export default SuggestedSubscriptions;
|
||||
+11
-1
@@ -1,8 +1,12 @@
|
||||
const Constants = {
|
||||
KEY_FIRST_RUN_EMAIL: "firstRunEmail",
|
||||
KEY_SHOULD_VERIFY_EMAIL: "shouldVerifyEmail",
|
||||
KEY_EMAIL_VERIFY_PENDING: "emailVerifyPending",
|
||||
|
||||
SETTING_ALPHA_UNDERSTANDS_RISKS: "alphaUnderstandRisks",
|
||||
SETTING_SUBSCRIPTIONS_VIEW_MODE: "subscriptionsViewMode",
|
||||
SETTING_RATING_REMINDER_LAST_SHOWN: "ratingReminderLastShown",
|
||||
SETTING_RATING_REMINDER_DISABLED: "ratingReminderDisabled",
|
||||
|
||||
ACTION_DELETE_COMPLETED_BLOBS: "DELETE_COMPLETED_BLOBS",
|
||||
ACTION_FIRST_RUN_PAGE_CHANGED: "FIRST_RUN_PAGE_CHANGED",
|
||||
@@ -22,7 +26,13 @@ const Constants = {
|
||||
DRAWER_ROUTE_REWARDS: "Rewards",
|
||||
DRAWER_ROUTE_WALLET: "Wallet",
|
||||
DRAWER_ROUTE_SETTINGS: "Settings",
|
||||
DRAWER_ROUTE_ABOUT: "About"
|
||||
DRAWER_ROUTE_ABOUT: "About",
|
||||
|
||||
SUBSCRIPTIONS_VIEW_ALL: 'view_all',
|
||||
SUBSCRIPTIONS_VIEW_LATEST_FIRST: 'view_latest_first',
|
||||
|
||||
PLAY_STORE_URL: 'https://play.google.com/store/apps/details?id=io.lbry.browser',
|
||||
RATING_REMINDER_INTERVAL: 604800, // 7 days (7 * 24 * 3600s)
|
||||
};
|
||||
|
||||
export default Constants;
|
||||
|
||||
@@ -11,7 +11,8 @@ import channelPageStyle from 'styles/channelPage';
|
||||
|
||||
class ChannelPage extends React.PureComponent {
|
||||
state = {
|
||||
page: 1
|
||||
page: 1,
|
||||
showPageButtons: false
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -26,7 +27,7 @@ class ChannelPage extends React.PureComponent {
|
||||
handlePreviousPage = () => {
|
||||
const { uri, fetchClaims } = this.props;
|
||||
if (this.state.page > 1) {
|
||||
this.setState({ page: this.state.page - 1 }, () => {
|
||||
this.setState({ page: this.state.page - 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
@@ -35,7 +36,7 @@ class ChannelPage extends React.PureComponent {
|
||||
handleNextPage = () => {
|
||||
const { uri, fetchClaims, totalPages } = this.props;
|
||||
if (this.state.page < totalPages) {
|
||||
this.setState({ page: this.state.page + 1 }, () => {
|
||||
this.setState({ page: this.state.page + 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
@@ -69,7 +70,9 @@ class ChannelPage extends React.PureComponent {
|
||||
hideFilter
|
||||
fileInfos={claimsInChannel}
|
||||
navigation={navigation}
|
||||
style={channelPageStyle.fileList} />
|
||||
style={channelPageStyle.fileList}
|
||||
contentContainerStyle={channelPageStyle.fileListContent}
|
||||
onEndReached={() => this.setState({ showPageButtons: true })} />
|
||||
) : (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>No content found.</Text>
|
||||
@@ -81,7 +84,7 @@ class ChannelPage extends React.PureComponent {
|
||||
<View style={channelPageStyle.container}>
|
||||
<PageHeader title={name} onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
|
||||
{contentList}
|
||||
{(totalPages > 1) &&
|
||||
{(totalPages > 1) && this.state.showPageButtons &&
|
||||
<View style={channelPageStyle.pageButtons}>
|
||||
<View>
|
||||
{(this.state.page > 1) && <Button
|
||||
|
||||
@@ -13,6 +13,9 @@ import {
|
||||
selectSubscriptionClaims,
|
||||
selectUnreadSubscriptions,
|
||||
} from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import DiscoverPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -21,6 +24,8 @@ const select = state => ({
|
||||
enabledChannelNotifications: selectEnabledChannelNotifications(state),
|
||||
featuredUris: selectFeaturedUris(state),
|
||||
fetchingFeaturedUris: selectFetchingFeaturedUris(state),
|
||||
ratingReminderDisabled: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED)(state),
|
||||
ratingReminderLastShown: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN)(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
});
|
||||
|
||||
@@ -29,6 +34,7 @@ const perform = dispatch => ({
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(DiscoverPage);
|
||||
export default connect(select, perform)(DiscoverPage);
|
||||
@@ -1,21 +1,24 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import {
|
||||
Alert,
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Linking,
|
||||
NativeModules,
|
||||
SectionList,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import moment from 'moment';
|
||||
import Colors from '../../styles/colors';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import FloatingWalletBalance from '../../component/floatingWalletBalance';
|
||||
import FileItem from '../../component/fileItem';
|
||||
import RewardSummary from '../../component/rewardSummary';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import Constants from 'constants';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import FileItem from 'component/fileItem';
|
||||
import RewardSummary from 'component/rewardSummary';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class DiscoverPage extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
@@ -50,6 +53,8 @@ class DiscoverPage extends React.PureComponent {
|
||||
fetchFeaturedUris();
|
||||
fetchRewardedContent();
|
||||
fetchSubscriptions();
|
||||
|
||||
this.showRatingReminder();
|
||||
}
|
||||
|
||||
subscriptionForUri = (uri, channelName) => {
|
||||
@@ -59,6 +64,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
if (allSubscriptions) {
|
||||
for (let i = 0; i < allSubscriptions.length; i++) {
|
||||
const sub = allSubscriptions[i];
|
||||
|
||||
if (sub.claim_id === claimId && sub.name === claimName && sub.channel_name === channelName) {
|
||||
return sub;
|
||||
}
|
||||
@@ -69,7 +75,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { allSubscriptions, unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||
|
||||
const utility = NativeModules.UtilityModule;
|
||||
if (utility) {
|
||||
@@ -84,18 +90,20 @@ class DiscoverPage extends React.PureComponent {
|
||||
// check if notifications are enabled for the channel
|
||||
if (enabledChannelNotifications.indexOf(channelName) > -1) {
|
||||
uris.forEach(uri => {
|
||||
const sub = this.subscriptionForUri(uri, channelName);
|
||||
if (sub && sub.value && sub.value.stream) {
|
||||
let isPlayable = false;
|
||||
const source = sub.value.stream.source;
|
||||
const metadata = sub.value.stream.metadata;
|
||||
if (source) {
|
||||
isPlayable = source.contentType && ['audio', 'video'].indexOf(source.contentType.substring(0, 5)) > -1;
|
||||
Lbry.resolve({ urls: uri }).then(result => {
|
||||
const sub = result[uri].claim;
|
||||
if (sub && sub.value && sub.value.stream) {
|
||||
let isPlayable = false;
|
||||
const source = sub.value.stream.source;
|
||||
const metadata = sub.value.stream.metadata;
|
||||
if (source) {
|
||||
isPlayable = source.contentType && ['audio', 'video'].indexOf(source.contentType.substring(0, 5)) > -1;
|
||||
}
|
||||
if (metadata) {
|
||||
utility.showNotificationForContent(uri, metadata.title, channelName, metadata.thumbnail, isPlayable);
|
||||
}
|
||||
}
|
||||
if (metadata) {
|
||||
utility.showNotificationForContent(uri, metadata.title, channelName, metadata.thumbnail, isPlayable);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -103,6 +111,46 @@ class DiscoverPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
showRatingReminder = () => {
|
||||
const { ratingReminderDisabled, ratingReminderLastShown, setClientSetting } = this.props;
|
||||
|
||||
const now = moment().unix();
|
||||
if ('true' !== ratingReminderDisabled && ratingReminderLastShown) {
|
||||
const lastShownParts = ratingReminderLastShown.split('|');
|
||||
if (lastShownParts.length === 2) {
|
||||
const lastShownTime = parseInt(lastShownParts[0], 10);
|
||||
const lastShownCount = parseInt(lastShownParts[1], 10);
|
||||
if (!isNaN(lastShownTime) && !isNaN(lastShownCount)) {
|
||||
if (now > (lastShownTime + (Constants.RATING_REMINDER_INTERVAL * lastShownCount))) {
|
||||
Alert.alert(
|
||||
'Enjoying LBRY?',
|
||||
'Are you enjoying your experience with the LBRY app? You can leave a review for us on the Play Store.',
|
||||
[
|
||||
{ text: 'Never ask again', onPress: () => setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true')},
|
||||
{ text: 'Maybe later', onPress: () => this.updateRatingReminderShown(lastShownCount)},
|
||||
{ text: 'Rate app', onPress: () => {
|
||||
setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true');
|
||||
Linking.openURL(Constants.PLAY_STORE_URL);
|
||||
}}
|
||||
],
|
||||
{ cancelable: false }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ratingReminderLastShown) {
|
||||
// first time, so set a value for the next interval multiplier
|
||||
this.updateRatingReminderShown(0);
|
||||
}
|
||||
}
|
||||
|
||||
updateRatingReminderShown = (lastShownCount) => {
|
||||
const { setClientSetting } = this.props;
|
||||
const settingString = (moment().unix() + '|' + (lastShownCount + 1));
|
||||
setClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN, settingString);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { featuredUris, fetchingFeaturedUris, navigation } = this.props;
|
||||
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length,
|
||||
@@ -117,15 +165,17 @@ class DiscoverPage extends React.PureComponent {
|
||||
<Text style={discoverStyle.title}>Fetching content...</Text>
|
||||
</View>
|
||||
)}
|
||||
{hasContent &&
|
||||
<SectionList style={discoverStyle.scrollContainer}
|
||||
{(!!hasContent) &&
|
||||
(<SectionList style={discoverStyle.scrollContainer}
|
||||
renderItem={ ({item, index, section}) => (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation} />
|
||||
navigation={navigation}
|
||||
compactView={false}
|
||||
showDetails={true} />
|
||||
)
|
||||
}
|
||||
renderSectionHeader={
|
||||
@@ -133,7 +183,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
}
|
||||
sections={Object.keys(featuredUris).map(category => ({ title: category, data: featuredUris[category] }))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
/>)
|
||||
}
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
<UriBar navigation={navigation} />
|
||||
|
||||
@@ -21,7 +21,7 @@ import fileListStyle from '../../styles/fileList';
|
||||
|
||||
class DownloadsPage extends React.PureComponent {
|
||||
static navigationOptions = {
|
||||
title: 'My LBRY'
|
||||
title: 'Downloads'
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
@@ -428,9 +428,9 @@ class FilePage extends React.PureComponent {
|
||||
const { height, channel_name: channelName, value } = claim;
|
||||
const showActions = !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView;
|
||||
const showFileActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||
const channelClaimId =
|
||||
value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||
const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullChannelUri = channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||
|
||||
const playerStyle = [filePageStyle.player,
|
||||
this.state.isLandscape ? filePageStyle.containedPlayerLandscape :
|
||||
@@ -575,8 +575,7 @@ class FilePage extends React.PureComponent {
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={"tail"}
|
||||
onPress={() => {
|
||||
const channelUri = normalizeURI(channelName);
|
||||
navigateToUri(navigation, channelUri);
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
@@ -588,11 +587,11 @@ class FilePage extends React.PureComponent {
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={channelUri}
|
||||
uri={fullChannelUri}
|
||||
name={channelName} />
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={channelUri}
|
||||
uri={fullChannelUri}
|
||||
name={channelName} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import {
|
||||
doGenerateAuthToken,
|
||||
doAuthenticate,
|
||||
doUserEmailNew,
|
||||
selectAuthToken,
|
||||
selectEmailNewErrorMessage,
|
||||
selectEmailNewIsPending,
|
||||
selectEmailToVerify,
|
||||
selectIsAuthenticating
|
||||
selectAuthenticationIsPending
|
||||
} from 'lbryinc';
|
||||
import FirstRun from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
authenticating: selectIsAuthenticating(state),
|
||||
authenticating: selectAuthenticationIsPending(state),
|
||||
authToken: selectAuthToken(state),
|
||||
emailToVerify: selectEmailToVerify(state),
|
||||
emailNewErrorMessage: selectEmailNewErrorMessage(state),
|
||||
@@ -21,7 +21,7 @@ const select = (state) => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
generateAuthToken: installationId => dispatch(doGenerateAuthToken(installationId)),
|
||||
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
|
||||
notify: data => dispatch(doToast(data))
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Linking,
|
||||
NativeModules,
|
||||
Platform,
|
||||
Text,
|
||||
TextInput,
|
||||
View
|
||||
@@ -46,19 +48,21 @@ class EmailCollectPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
startAuthenticating = () => {
|
||||
const { generateAuthToken } = this.props;
|
||||
const { authenticate } = this.props;
|
||||
this.setState({ authenticationStarted: true, authenticationFailed: false });
|
||||
Lbry.status().then(info => {
|
||||
generateAuthToken(info.installation_id)
|
||||
}).catch(error => {
|
||||
if (this.state.statusTries >= EmailCollectPage.MAX_STATUS_TRIES) {
|
||||
this.setState({ authenticationFailed: true });
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startAuthenticating();
|
||||
this.setState({ statusTries: this.state.statusTries + 1 });
|
||||
}, 1000); // Retry every second for a maximum of MAX_STATUS_TRIES tries (30 seconds)
|
||||
}
|
||||
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
||||
Lbry.status().then(info => {
|
||||
authenticate(appVersion, Platform.OS)
|
||||
}).catch(error => {
|
||||
if (this.state.statusTries >= EmailCollectPage.MAX_STATUS_TRIES) {
|
||||
this.setState({ authenticationFailed: true });
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startAuthenticating();
|
||||
this.setState({ statusTries: this.state.statusTries + 1 });
|
||||
}, 1000); // Retry every second for a maximum of MAX_STATUS_TRIES tries (30 seconds)
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,6 +74,7 @@ class EmailCollectPage extends React.PureComponent {
|
||||
onEmailChanged(text);
|
||||
}
|
||||
AsyncStorage.setItem(Constants.KEY_FIRST_RUN_EMAIL, text);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -160,9 +160,9 @@ class FirstRunScreen extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
authenticate,
|
||||
authenticating,
|
||||
authToken,
|
||||
generateAuthToken,
|
||||
emailNewErrorMessage,
|
||||
emailNewPending,
|
||||
emailToVerify
|
||||
@@ -175,7 +175,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
} else if (this.state.currentPage === 'email-collect') {
|
||||
page = (<EmailCollectPage authenticating={authenticating}
|
||||
authToken={authToken}
|
||||
generateAuthToken={generateAuthToken}
|
||||
authenticate={authenticate}
|
||||
onEmailChanged={this.onEmailChanged}
|
||||
onEmailViewLayout={this.onEmailViewLayout} />);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class SplashScreen extends React.PureComponent {
|
||||
const { deleteCompleteBlobs, fetchSubscriptions } = this.props;
|
||||
const startupStatus = status.startup_status;
|
||||
// At the minimum, wallet should be started and blocks_behind equal to 0 before calling resolve
|
||||
const hasStarted = startupStatus.file_manager && startupStatus.wallet && status.wallet.blocks_behind <= 0;
|
||||
const hasStarted = startupStatus.stream_manager && startupStatus.wallet && status.wallet.blocks_behind <= 0;
|
||||
if (hasStarted) {
|
||||
deleteCompleteBlobs();
|
||||
|
||||
@@ -142,7 +142,7 @@ class SplashScreen extends React.PureComponent {
|
||||
});
|
||||
|
||||
// fetch subscriptions, so that we can check for new content after resolve
|
||||
Lbry.resolve({ uri: 'lbry://one' }).then(() => {
|
||||
Lbry.resolve({ urls: 'lbry://one' }).then(() => {
|
||||
// Leave the splash screen
|
||||
const {
|
||||
authenticate,
|
||||
|
||||
@@ -3,8 +3,6 @@ import {
|
||||
doFetchMySubscriptions,
|
||||
doSetViewMode,
|
||||
doFetchRecommendedSubscriptions,
|
||||
doCompleteFirstRun,
|
||||
doShowSuggestedSubs,
|
||||
selectSubscriptionClaims,
|
||||
selectSubscriptions,
|
||||
selectSubscriptionsBeingFetched,
|
||||
@@ -15,6 +13,8 @@ import {
|
||||
selectShowSuggestedSubs
|
||||
} from 'lbryinc';
|
||||
import { doPushDrawerStack } from 'redux/actions/drawer';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import SubscriptionsPage from './view';
|
||||
|
||||
@@ -23,6 +23,7 @@ const select = state => ({
|
||||
selectIsFetchingSubscriptions(state) ||
|
||||
Boolean(Object.keys(selectSubscriptionsBeingFetched(state)).length),
|
||||
subscribedChannels: selectSubscriptions(state),
|
||||
subscriptionsViewMode: makeSelectClientSetting(Constants.SETTING_SUBSCRIPTIONS_VIEW_MODE)(state),
|
||||
allSubscriptions: selectSubscriptionClaims(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
viewMode: selectViewMode(state),
|
||||
@@ -31,12 +32,11 @@ const select = state => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
doFetchMySubscriptions,
|
||||
doSetViewMode,
|
||||
doFetchRecommendedSubscriptions,
|
||||
doCompleteFirstRun,
|
||||
doShowSuggestedSubs,
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SUBSCRIPTIONS))
|
||||
doFetchMySubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||
doFetchRecommendedSubscriptions: () => dispatch(doFetchRecommendedSubscriptions()),
|
||||
doSetViewMode: (viewMode) => dispatch(doSetViewMode(viewMode)),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SUBSCRIPTIONS)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SubscriptionsPage);
|
||||
@@ -6,29 +6,45 @@ import {
|
||||
FlatList,
|
||||
NativeModules,
|
||||
SectionList,
|
||||
ScrollView,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { buildURI } from 'lbry-redux';
|
||||
import { buildURI, parseURI } from 'lbry-redux';
|
||||
import { uriFromFileInfo } from 'utils/helper';
|
||||
import moment from 'moment';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import FileItem from 'component/fileItem';
|
||||
import Link from 'component/link';
|
||||
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class SubscriptionsPage extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
const {
|
||||
doFetchMySubscriptions,
|
||||
doFetchRecommendedSubscriptions,
|
||||
pushDrawerStack,
|
||||
} = this.props;
|
||||
|
||||
pushDrawerStack();
|
||||
doFetchMySubscriptions();
|
||||
//doFetchRecommendedSubscriptions();
|
||||
doFetchRecommendedSubscriptions();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { doSetViewMode, subscriptionsViewMode } = this.props;
|
||||
doSetViewMode(subscriptionsViewMode ? subscriptionsViewMode : Constants.SUBSCRIPTIONS_VIEW_ALL);
|
||||
}
|
||||
|
||||
changeViewMode = (viewMode) => {
|
||||
const { setClientSetting, doSetViewMode } = this.props;
|
||||
setClientSetting(Constants.SETTING_SUBSCRIPTIONS_VIEW_MODE, viewMode);
|
||||
doSetViewMode(viewMode);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -44,7 +60,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
doShowSuggestedSubs,
|
||||
showSuggestedSubs,
|
||||
unreadSubscriptions,
|
||||
navigation
|
||||
navigation,
|
||||
} = this.props;
|
||||
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
||||
const hasSubscriptions = numberOfSubscriptions > 0;
|
||||
@@ -53,6 +69,24 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
<View style={subscriptionsStyle.container}>
|
||||
|
||||
{hasSubscriptions && !loading &&
|
||||
<View style={subscriptionsStyle.viewModeRow}>
|
||||
<Link
|
||||
text={'All Subscriptions'}
|
||||
style={[subscriptionsStyle.viewModeLink,
|
||||
((viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL) ? subscriptionsStyle.activeMode : subscriptionsStyle.inactiveMode)]}
|
||||
onPress={() => this.changeViewMode(Constants.SUBSCRIPTIONS_VIEW_ALL)}
|
||||
/>
|
||||
<Link
|
||||
text={'Latest Only'}
|
||||
style={[subscriptionsStyle.viewModeLink,
|
||||
((viewMode === Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST) ? subscriptionsStyle.activeMode : subscriptionsStyle.inactiveMode)]}
|
||||
onPress={() => this.changeViewMode(Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST)}
|
||||
/>
|
||||
</View>}
|
||||
|
||||
{(hasSubscriptions && !loading) &&
|
||||
<View style={subscriptionsStyle.container}>
|
||||
{(viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL) &&
|
||||
<FlatList
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.scrollPadding}
|
||||
@@ -62,7 +96,9 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={uriFromFileInfo(item)}
|
||||
navigation={navigation} />
|
||||
navigation={navigation}
|
||||
compactView={false}
|
||||
showDetails={true} />
|
||||
)
|
||||
}
|
||||
data={allSubscriptions.sort((a, b) => {
|
||||
@@ -70,17 +106,47 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
})}
|
||||
keyExtractor={(item, index) => uriFromFileInfo(item)} />}
|
||||
|
||||
{hasSubscriptions && loading &&
|
||||
{(viewMode === Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST) &&
|
||||
<View style={subscriptionsStyle.container}>
|
||||
{unreadSubscriptions.length ?
|
||||
(<ScrollView
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.scrollPadding}>
|
||||
{unreadSubscriptions.map(({ channel, uris }) => {
|
||||
const { claimName } = parseURI(channel);
|
||||
return uris.map(uri => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={uri}
|
||||
uri={uri}
|
||||
navigation={navigation}
|
||||
compactView={false}
|
||||
showDetails={true} />));
|
||||
})}
|
||||
</ScrollView>) :
|
||||
(<View style={subscriptionsStyle.contentContainer}>
|
||||
<Text style={subscriptionsStyle.contentText}>All caught up! You might like the channels below.</Text>
|
||||
<SuggestedSubscriptions navigation={navigation} />
|
||||
</View>)
|
||||
}
|
||||
</View>}
|
||||
|
||||
</View>}
|
||||
|
||||
{(hasSubscriptions && loading) &&
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={subscriptionsStyle.loading} />
|
||||
</View>
|
||||
}
|
||||
|
||||
{!hasSubscriptions &&
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
{(!hasSubscriptions && !loading) &&
|
||||
<View style={subscriptionsStyle.container}>
|
||||
<Text style={subscriptionsStyle.infoText}>
|
||||
You are not subscribed to any channels. Feel free to discover new channels that you can subscribe to.
|
||||
You are not subscribed to any channels at the moment. Here are some channels that we think you might enjoy.
|
||||
</Text>
|
||||
{loadingSuggested && <ActivityIndicator size="large" colors={Colors.LbryGreen} style={subscriptionsStyle.loading} />}
|
||||
{!loadingSuggested && <SuggestedSubscriptions navigation={navigation} />}
|
||||
</View>}
|
||||
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
} from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import moment from 'moment';
|
||||
import FileItem from '../../component/fileItem';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import Colors from '../../styles/colors';
|
||||
import FloatingWalletBalance from '../../component/floatingWalletBalance';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import FileItem from '/component/fileItem';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import Colors from 'styles/colors';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class TrendingPage extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
@@ -44,7 +44,9 @@ class TrendingPage extends React.PureComponent {
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation} />
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
compactView={false} />
|
||||
)
|
||||
}
|
||||
data={trendingUris.map(uri => uri.url)}
|
||||
|
||||
@@ -54,7 +54,13 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||
});
|
||||
|
||||
if (NativeModules.LbryDownloadManager) {
|
||||
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, 100, writtenBytes, totalBytes);
|
||||
NativeModules.LbryDownloadManager.updateDownload(
|
||||
uri,
|
||||
fileInfo.file_name ? fileInfo.file_name : '',
|
||||
100,
|
||||
writtenBytes ? writtenBytes : 0,
|
||||
totalBytes ? totalBytes : 0
|
||||
);
|
||||
}
|
||||
|
||||
// Once a download has been completed, delete the individual blob files to save space
|
||||
@@ -84,7 +90,13 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||
});
|
||||
|
||||
if (NativeModules.LbryDownloadManager) {
|
||||
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, progress, writtenBytes, totalBytes);
|
||||
NativeModules.LbryDownloadManager.updateDownload(
|
||||
uri,
|
||||
fileInfo.file_name ? fileInfo.file_name : '',
|
||||
progress ? progress : 0,
|
||||
writtenBytes ? writtenBytes : 0,
|
||||
totalBytes ? totalBytes: 0
|
||||
);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
@@ -118,7 +130,7 @@ export function doStartDownload(uri, outpoint) {
|
||||
});
|
||||
|
||||
if (NativeModules.LbryDownloadManager) {
|
||||
NativeModules.LbryDownloadManager.startDownload(uri, fileInfo.file_name);
|
||||
NativeModules.LbryDownloadManager.startDownload(uri, fileInfo.file_name ? fileInfo.file_name : '');
|
||||
}
|
||||
|
||||
dispatch(doUpdateLoadStatus(uri, outpoint));
|
||||
@@ -146,7 +158,7 @@ export function doStopDownloadingFile(uri, fileInfo) {
|
||||
dispatch(doDeleteFile(fileInfo.outpoint, uri));
|
||||
|
||||
if (NativeModules.LbryDownloadManager) {
|
||||
NativeModules.LbryDownloadManager.stopDownload(uri, fileInfo.file_name);
|
||||
NativeModules.LbryDownloadManager.stopDownload(uri, fileInfo.file_name ? fileInfo.file_name : '');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -10,9 +10,12 @@ const channelPageStyle = StyleSheet.create({
|
||||
flex: 1
|
||||
},
|
||||
fileList: {
|
||||
paddingTop: 30,
|
||||
flex: 1,
|
||||
marginBottom: 16
|
||||
paddingTop: 30,
|
||||
marginBottom: 60,
|
||||
},
|
||||
fileListContent: {
|
||||
paddingBottom: 16
|
||||
},
|
||||
title: {
|
||||
color: Colors.LbryGreen,
|
||||
@@ -33,11 +36,13 @@ const channelPageStyle = StyleSheet.create({
|
||||
marginLeft: 10
|
||||
},
|
||||
pageButtons: {
|
||||
width: '100%',
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
position: 'absolute',
|
||||
bottom: 76,
|
||||
paddingLeft: 16,
|
||||
paddingRight: 16,
|
||||
marginBottom: 76
|
||||
paddingRight: 16
|
||||
},
|
||||
button: {
|
||||
backgroundColor: Colors.LbryGreen,
|
||||
|
||||
@@ -2,15 +2,15 @@ import { Dimensions, PixelRatio, StyleSheet } from 'react-native';
|
||||
import Colors from './colors';
|
||||
|
||||
const screenDimension = Dimensions.get('window');
|
||||
const screenWidth = screenDimension.width;
|
||||
const screenHeight = screenDimension.height;
|
||||
export const screenWidth = screenDimension.width;
|
||||
export const screenHeight = screenDimension.height;
|
||||
const screenWidthPixels = PixelRatio.getPixelSizeForLayoutSize(screenWidth);
|
||||
const screenHeightPixels = PixelRatio.getPixelSizeForLayoutSize(screenHeight);
|
||||
// calculate thumbnail width and height based on device's aspect ratio
|
||||
const horizontalMargin = 48; // left and right margins (24 + 24)
|
||||
const verticalMargin = (screenWidthPixels > 720 && screenHeightPixels > 1920) ? 0 : ((screenWidthPixels <= 720) ? 20 : 16);
|
||||
const mediaWidth = screenWidth - horizontalMargin;
|
||||
const mediaHeight = ((screenWidth / screenHeight) * ((screenWidthPixels <= 720) ? screenWidth : mediaWidth)) - verticalMargin;
|
||||
// calculate thumbnail width and height based on device's aspect ratio
|
||||
export const horizontalMargin = 48; // left and right margins (24 + 24)
|
||||
export const verticalMargin = (screenWidthPixels > 720 && screenHeightPixels > 1920) ? 0 : ((screenWidthPixels <= 720) ? 20 : 16);
|
||||
export const mediaWidth = screenWidth - horizontalMargin;
|
||||
export const mediaHeight = ((screenWidth / screenHeight) * ((screenWidthPixels <= 720) ? screenWidth : mediaWidth)) - verticalMargin;
|
||||
|
||||
const discoverStyle = StyleSheet.create({
|
||||
container: {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import {
|
||||
screenWidth,
|
||||
horizontalMargin,
|
||||
mediaWidth,
|
||||
mediaHeight
|
||||
} from 'styles/discover';
|
||||
import Colors from 'styles/colors';
|
||||
|
||||
const subscriptionsStyle = StyleSheet.create({
|
||||
container: {
|
||||
@@ -19,14 +26,94 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
paddingTop: 24
|
||||
},
|
||||
infoText: {
|
||||
textAlign: 'center',
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
margin: 16
|
||||
},
|
||||
suggestedContainer: {
|
||||
flex: 1,
|
||||
},
|
||||
contentContainer: {
|
||||
flex: 1,
|
||||
marginTop: 16
|
||||
},
|
||||
contentText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
marginLeft: 24,
|
||||
marginRight: 24,
|
||||
marginBottom: 8
|
||||
},
|
||||
fileItem: {
|
||||
marginLeft: 24,
|
||||
marginRight: 24,
|
||||
marginBottom: 24
|
||||
},
|
||||
compactItems: {
|
||||
flex: 1,
|
||||
marginTop: 6,
|
||||
marginLeft: 20,
|
||||
marginRight: 24,
|
||||
marginBottom: 24,
|
||||
height: 80,
|
||||
},
|
||||
compactFileItem: {
|
||||
width: (screenWidth - horizontalMargin - (6 * 3)) / 3,
|
||||
marginLeft: 6,
|
||||
height: '100%'
|
||||
},
|
||||
compactFileItemMedia: {
|
||||
width: (screenWidth - horizontalMargin) / 3,
|
||||
height: '100%'
|
||||
},
|
||||
fileItemMedia: {
|
||||
width: mediaWidth,
|
||||
height: mediaHeight,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center'
|
||||
},
|
||||
fileItemName: {
|
||||
fontFamily: 'Inter-UI-Bold',
|
||||
marginTop: 8,
|
||||
fontSize: 18
|
||||
},
|
||||
channelTitle: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 20,
|
||||
marginLeft: 24,
|
||||
marginTop: 16,
|
||||
marginBottom: 16,
|
||||
color: Colors.LbryGreen
|
||||
},
|
||||
titleRow: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between'
|
||||
},
|
||||
subscribeButton: {
|
||||
alignSelf: 'flex-start',
|
||||
marginRight: 24,
|
||||
marginTop: 8,
|
||||
backgroundColor: Colors.White,
|
||||
paddingLeft: 16,
|
||||
paddingRight: 16,
|
||||
},
|
||||
viewModeRow: {
|
||||
flexDirection: 'row',
|
||||
marginLeft: 24,
|
||||
marginRight: 24,
|
||||
marginTop: 24
|
||||
},
|
||||
viewModeLink: {
|
||||
marginRight: 24,
|
||||
fontSize: 18,
|
||||
color: Colors.LbryGreen
|
||||
},
|
||||
inactiveMode: {
|
||||
fontFamily: 'Inter-UI-Regular'
|
||||
},
|
||||
activeMode: {
|
||||
fontFamily: 'Inter-UI-SemiBold'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[app]
|
||||
|
||||
# (str) Title of your application
|
||||
title = LBRY Browser
|
||||
title = LBRY
|
||||
|
||||
# (str) Package name
|
||||
package.name = browser
|
||||
@@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.30.4#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.32.3#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[app]
|
||||
|
||||
# (str) Title of your application
|
||||
title = LBRY Browser
|
||||
title = LBRY
|
||||
|
||||
# (str) Package name
|
||||
package.name = browser
|
||||
@@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.30.4#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.32.3#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[app]
|
||||
|
||||
# (str) Title of your application
|
||||
title = LBRY Browser
|
||||
title = LBRY
|
||||
|
||||
# (str) Package name
|
||||
package.name = browser
|
||||
@@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py
|
||||
|
||||
# (list) Application requirements
|
||||
# comma seperated e.g. requirements = sqlite3,kivy
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.30.4#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.6.1, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbry.git@v0.32.3#egg=lbrynet, git+https://github.com/lbryio/aioupnp.git#egg=aioupnp, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp==3.4.4, multidict==4.5.2, idna_ssl==1.1.0, typing_extensions==3.6.5, yarl, chardet==3.0.4, async_timeout==3.0.1, aiorpcX==0.9.0, git+https://github.com/lbryio/torba#egg=torba, coincurve
|
||||
|
||||
# (str) Custom source folders for requirements
|
||||
# Sets custom source for any requirements with recipes
|
||||
|
||||
@@ -32,6 +32,8 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||
|
||||
private HashMap<String, Integer> downloadIdNotificationIdMap = new HashMap<String, Integer>();
|
||||
|
||||
private HashMap<String, Boolean> stoppedDownloadsMap = new HashMap<String, Boolean>();
|
||||
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#");
|
||||
|
||||
private static final int MAX_FILENAME_LENGTH = 20;
|
||||
@@ -115,6 +117,10 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@ReactMethod
|
||||
public void startDownload(String id, String filename) {
|
||||
if (filename == null || filename.trim().length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createNotificationChannel();
|
||||
createNotificationGroup();
|
||||
|
||||
@@ -129,6 +135,7 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download);
|
||||
|
||||
int notificationId = getNotificationId(id);
|
||||
downloadIdNotificationIdMap.put(id, notificationId);
|
||||
builders.put(notificationId, builder);
|
||||
notificationManager.notify(notificationId, builder.build());
|
||||
|
||||
@@ -140,11 +147,23 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@ReactMethod
|
||||
public void updateDownload(String id, String filename, double progress, double writtenBytes, double totalBytes) {
|
||||
if (filename == null || filename.trim().length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int notificationId = getNotificationId(id);
|
||||
if (notificationId == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stoppedDownloadsMap.containsKey(id) && stoppedDownloadsMap.get(id)) {
|
||||
// if this happens, the download was canceled, so remove the notification
|
||||
// TODO: Figure out why updateDownload is called in the React Native code after stopDownload
|
||||
removeDownloadNotification(id);
|
||||
stoppedDownloadsMap.remove(id);
|
||||
return;
|
||||
}
|
||||
|
||||
createNotificationChannel();
|
||||
createNotificationGroup();
|
||||
|
||||
@@ -198,6 +217,12 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@ReactMethod
|
||||
public void stopDownload(String id, String filename) {
|
||||
android.util.Log.d("ReactNativeJS", "Stop download for id=" + id + "; filename=" + filename);
|
||||
stoppedDownloadsMap.put(id, true);
|
||||
removeDownloadNotification(id);
|
||||
}
|
||||
|
||||
private void removeDownloadNotification(String id) {
|
||||
if (!downloadIdNotificationIdMap.containsKey(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
protected Bitmap doInBackground(Void... params) {
|
||||
try {
|
||||
return Picasso.get().load(thumbnailUri).get();
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
import asyncio
|
||||
import keyring
|
||||
import logging
|
||||
import pathlib
|
||||
import platform
|
||||
import sys
|
||||
from jnius import autoclass
|
||||
from keyring.backend import KeyringBackend
|
||||
from lbrynet import build_type
|
||||
from lbrynet.extras.cli import conf, log_support, check_connection, Daemon, reactor
|
||||
from lbrynet import __version__ as lbrynet_version, build_type
|
||||
from lbrynet.conf import Config
|
||||
from lbrynet.extras.daemon.loggly_handler import get_loggly_handler
|
||||
from lbrynet.extras.daemon.Components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
|
||||
from lbrynet.extras.daemon.Components import REFLECTOR_COMPONENT
|
||||
from lbrynet.extras.daemon.Daemon import Daemon
|
||||
from lbrynet.extras.daemon.loggly_handler import get_loggly_handler
|
||||
from lbrynet.utils import check_connection
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
||||
lbrynet_android_utils = autoclass('io.lbry.browser.Utils')
|
||||
service = autoclass('io.lbry.browser.LbrynetService').serviceInstance
|
||||
platform.platform = lambda: 'Android %s (API %s)' % (lbrynet_android_utils.getAndroidRelease(), lbrynet_android_utils.getAndroidSdk())
|
||||
build_type.BUILD = 'dev' if lbrynet_android_utils.isDebug() else 'release'
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Keyring backend
|
||||
class LbryAndroidKeyring(KeyringBackend):
|
||||
@@ -34,38 +41,67 @@ class LbryAndroidKeyring(KeyringBackend):
|
||||
context = service.getApplicationContext()
|
||||
lbrynet_android_utils.deletePassword(servicename, username, context, self._keystore)
|
||||
|
||||
def ensure_directory_exists(path: str):
|
||||
if not os.path.isdir(path):
|
||||
pathlib.Path(path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def configure_logging(conf):
|
||||
default_formatter = logging.Formatter("%(asctime)s %(levelname)-8s %(name)s:%(lineno)d: %(message)s")
|
||||
|
||||
file_handler = logging.handlers.RotatingFileHandler(
|
||||
conf.log_file_path, maxBytes=2097152, backupCount=5
|
||||
)
|
||||
file_handler.setFormatter(default_formatter)
|
||||
logging.getLogger('lbrynet').addHandler(file_handler)
|
||||
logging.getLogger('torba').addHandler(file_handler)
|
||||
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(default_formatter)
|
||||
|
||||
log.addHandler(handler)
|
||||
logging.getLogger('lbrynet').addHandler(handler)
|
||||
logging.getLogger('torba').addHandler(handler)
|
||||
|
||||
logging.getLogger('aioupnp').setLevel(logging.WARNING)
|
||||
logging.getLogger('aiohttp').setLevel(logging.CRITICAL)
|
||||
logging.getLogger('lbrynet').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
|
||||
logging.getLogger('torba').setLevel(logging.INFO)
|
||||
|
||||
loggly_handler = get_loggly_handler()
|
||||
loggly_handler.setLevel(logging.ERROR)
|
||||
logging.getLogger('lbrynet').addHandler(loggly_handler)
|
||||
|
||||
def start():
|
||||
keyring.set_keyring(LbryAndroidKeyring())
|
||||
|
||||
private_storage_dir = lbrynet_android_utils.getAppInternalStorageDir(service.getApplicationContext())
|
||||
conf.initialize_settings(
|
||||
conf = Config(
|
||||
data_dir=f'{private_storage_dir}/lbrynet',
|
||||
wallet_dir=f'{private_storage_dir}/lbryum',
|
||||
download_dir=f'{lbrynet_android_utils.getInternalStorageDir(service.getApplicationContext())}/Download'
|
||||
download_dir=f'{lbrynet_android_utils.getInternalStorageDir(service.getApplicationContext())}/Download',
|
||||
components_to_skip=[DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT],
|
||||
use_upnp=False
|
||||
)
|
||||
conf.settings.update({
|
||||
'components_to_skip': [
|
||||
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
REFLECTOR_COMPONENT
|
||||
],
|
||||
'use_upnp': False,
|
||||
# 'use_https': True, # TODO: does this work on android?
|
||||
# 'use_auth_http': True
|
||||
})
|
||||
|
||||
log_support.configure_logging(conf.settings.get_log_filename(), True, [])
|
||||
log_support.configure_loggly_handler()
|
||||
for directory in (conf.data_dir, conf.download_dir, conf.wallet_dir):
|
||||
ensure_directory_exists(directory)
|
||||
|
||||
log.info('Final Settings: %s', conf.settings.get_current_settings_dict())
|
||||
log.info('Starting lbrynet-daemon');
|
||||
configure_logging(conf)
|
||||
|
||||
if check_connection():
|
||||
daemon = Daemon()
|
||||
daemon.start_listening()
|
||||
reactor.run()
|
||||
else:
|
||||
print("Not connected to internet, unable to start")
|
||||
log.info('Starting lbry sdk {}'.format(lbrynet_version));
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.set_debug(lbrynet_android_utils.isDebug())
|
||||
|
||||
daemon = Daemon(conf)
|
||||
try:
|
||||
loop.run_until_complete(daemon.start())
|
||||
loop.run_until_complete(daemon.stop_event.wait())
|
||||
except (GracefulExit):
|
||||
pass
|
||||
finally:
|
||||
loop.run_until_complete(daemon.stop())
|
||||
if hasattr(loop, 'shutdown_asyncgens'):
|
||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||
|
||||
if __name__ == '__main__':
|
||||
start()
|
||||
@@ -1,4 +1,4 @@
|
||||
__version__ = "0.4.0"
|
||||
__version__ = "0.5.0"
|
||||
|
||||
class ServiceApp(App):
|
||||
def build(self):
|
||||
|
||||
Reference in new issue
Block a user