Compare commits
118
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc2b3b845d | ||
|
|
b6df5ee97c | ||
|
|
ddd8d49a62 | ||
|
|
e6ee26f94c | ||
|
|
2bf67d31e8 | ||
|
|
9ec5ac5d60 | ||
|
|
9080913811 | ||
|
|
eca6af122b | ||
|
|
b258654d60 | ||
|
|
342e022594 | ||
|
|
d16e4b7f69 | ||
|
|
648206b6a5 | ||
|
|
14994d2a30 | ||
|
|
ab97be6a4d | ||
|
|
e39f5907a8 | ||
|
|
c203aa914c | ||
|
|
f0a3eec80b | ||
|
|
47bb996342 | ||
|
|
aba0b860e8 | ||
|
|
b135ca36a3 | ||
|
|
46b99e769f | ||
|
|
b5dad6b5fb | ||
|
|
31d4d46742 | ||
|
|
5d86b68a3e | ||
|
|
62ac844084 | ||
|
|
eebb25dba0 | ||
|
|
88e450eb08 | ||
|
|
ca8670e23c | ||
|
|
1b4c023c92 | ||
|
|
9aabad56a2 | ||
|
|
3051deb7c7 | ||
|
|
f2f5cd9ad5 | ||
|
|
f800f22277 | ||
|
|
2558f0c392 | ||
|
|
02d8107b50 | ||
|
|
5943a796e4 | ||
|
|
ffc4d828a7 | ||
|
|
23cf8b15bc | ||
|
|
76cc8eaea1 | ||
|
|
f372b33f42 | ||
|
|
a26fb3e06b | ||
|
|
8bd3bd21e8 | ||
|
|
0115025b86 | ||
|
|
34fa24ffd0 | ||
|
|
9e8ba95fec | ||
|
|
d63253cc30 | ||
|
|
6ce143b145 | ||
|
|
c7ce7ea284 | ||
|
|
076122def4 | ||
|
|
625559528d | ||
|
|
c88961002f | ||
|
|
decf0623fb | ||
|
|
c7f2b78b92 | ||
|
|
47cf15741c | ||
|
|
e74a419ffd | ||
|
|
0c06f478c8 | ||
|
|
9391c1b78c | ||
|
|
e902420269 | ||
|
|
dc0d3ad9b6 | ||
|
|
1c70fc878a | ||
|
|
47cdf2698f | ||
|
|
cf5045cce3 | ||
|
|
e6139d59d9 | ||
|
|
a45e9c5513 | ||
|
|
68d99ac639 | ||
|
|
10e92b2834 | ||
|
|
384550cc63 | ||
|
|
3f7408907a | ||
|
|
4ff2fb1def | ||
|
|
1e31d8d22b | ||
|
|
430fc1a661 | ||
|
|
7dd4f96e65 | ||
|
|
1e6505b664 | ||
|
|
3ed97ff3da | ||
|
|
3cb5d34511 | ||
|
|
8d5ce92f81 | ||
|
|
4c864c00dd | ||
|
|
bbdea90e0f | ||
|
|
719604e7da | ||
|
|
6ae8c32f72 | ||
|
|
4287793d3f | ||
|
|
a2ee73e23e | ||
|
|
6653225b61 | ||
|
|
41f511e233 | ||
|
|
2c6ac47d1a | ||
|
|
1bc2b47145 | ||
|
|
5c80e7f1cf | ||
|
|
0d06ce5844 | ||
|
|
33d525f5c7 | ||
|
|
84fe0f69d5 | ||
|
|
e443a0fdbb | ||
|
|
580f879d0e | ||
|
|
8fc179cbde | ||
|
|
df05825763 | ||
|
|
acf0095be9 | ||
|
|
1e72672b4b | ||
|
|
319cf3abad | ||
|
|
73ad23ef58 | ||
|
|
0041059465 | ||
|
|
47378d9191 | ||
|
|
2e7660250b | ||
|
|
8b67a9fab8 | ||
|
|
95285cf4dd | ||
|
|
60c617f334 | ||
|
|
1853558215 | ||
|
|
f05181898b | ||
|
|
4bd26d4e2e | ||
|
|
c57449abf7 | ||
|
|
38618080a1 | ||
|
|
89222bc9ee | ||
|
|
fc412e4282 | ||
|
|
ffccc124d0 | ||
|
|
e8704b1c92 | ||
|
|
86b4a825c8 | ||
|
|
95b6801450 | ||
|
|
1e0a636b4f | ||
|
|
4b7f3f140a | ||
|
|
18d654cc66 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-2018 LBRY Inc
|
||||
Copyright (c) 2017-2019 LBRY Inc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
Generated
+1596
-467
File diff suppressed because it is too large.
Load diff
+14
-9
@@ -4,6 +4,7 @@
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"devtools": "react-devtools",
|
||||
"format": "prettier 'src/**/*.{js,json}' --write",
|
||||
"precommit": "lint-staged"
|
||||
},
|
||||
@@ -11,29 +12,31 @@
|
||||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"gfycat-style-urls": "^1.0.3",
|
||||
"lbry-redux": "lbryio/lbry-redux#multi-claim-search",
|
||||
"lbryinc": "lbryio/lbryinc",
|
||||
"lbry-redux": "lbryio/lbry-redux#9919a8150998822ca997cd23418f023d64d4a3da",
|
||||
"lbryinc": "lbryio/lbryinc#aebad10a9c5d725c3fedae4236d56f239a0bc1de",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
"moment": "^2.22.1",
|
||||
"react": "16.8.6",
|
||||
"react-native": "0.59.10",
|
||||
"@react-native-community/async-storage": "^1.5.1",
|
||||
"react-native-camera": "^2.11.0",
|
||||
"react-native-camera": "^2.11.1",
|
||||
"react-native-country-picker-modal": "^0.6.2",
|
||||
"react-native-document-picker": "^2.3.0",
|
||||
"react-native-exception-handler": "2.9.0",
|
||||
"react-native-fast-image": "^5.0.3",
|
||||
"react-native-fast-image": "^6.1.1",
|
||||
"react-native-fs": "^2.13.3",
|
||||
"react-native-gesture-handler": "^1.1.0",
|
||||
"react-native-gesture-handler": "1.3.0",
|
||||
"react-native-image-zoom-viewer": "^2.2.5",
|
||||
"react-native-password-strength-meter": "^0.0.2",
|
||||
"react-native-phone-input": "lbryio/react-native-phone-input",
|
||||
"react-native-reanimated": "1.2.0",
|
||||
"react-native-super-grid": "^3.0.4",
|
||||
"react-native-vector-icons": "^6.4.2",
|
||||
"react-native-vector-icons": "^6.6.0",
|
||||
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
|
||||
"react-navigation": "^3.11.0",
|
||||
"react-navigation-drawer": "^2.2.2",
|
||||
"react-navigation-redux-helpers": "^3.0.2",
|
||||
"react-navigation-stack": "^1.8.1",
|
||||
"react-redux": "^5.0.3",
|
||||
"redux": "^4.0.4",
|
||||
"redux-persist": "^5.10.0",
|
||||
@@ -41,7 +44,8 @@
|
||||
"redux-persist-transform-compress": "^4.2.0",
|
||||
"redux-persist-transform-filter": "0.0.18",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"rn-fetch-blob": "0.10.15"
|
||||
"rn-fetch-blob": "0.10.15",
|
||||
"seedrandom": "3.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.5.4",
|
||||
@@ -63,6 +67,7 @@
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.0.4",
|
||||
"metro-react-native-babel-preset": "^0.55.0",
|
||||
"prettier": "^1.11.1"
|
||||
"prettier": "^1.11.1",
|
||||
"react-devtools": "^3.6.3"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 265 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 278 KiB |
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import AboutPage from 'page/about';
|
||||
import ChannelCreatorPage from 'page/channelCreator';
|
||||
import DiscoverPage from 'page/discover';
|
||||
import DownloadsPage from 'page/downloads';
|
||||
import DrawerContent from 'component/drawerContent';
|
||||
@@ -17,7 +18,9 @@ import SubscriptionsPage from 'page/subscriptions';
|
||||
import TransactionHistoryPage from 'page/transactionHistory';
|
||||
import VerificationScreen from 'page/verification';
|
||||
import WalletPage from 'page/wallet';
|
||||
import { createDrawerNavigator, createStackNavigator, NavigationActions } from 'react-navigation';
|
||||
import { NavigationActions } from 'react-navigation';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createReduxContainer,
|
||||
createReactNavigationReduxMiddleware,
|
||||
@@ -26,8 +29,9 @@ import {
|
||||
import { connect } from 'react-redux';
|
||||
import { AppState, BackHandler, Linking, NativeModules, TextInput, ToastAndroid } from 'react-native';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { SETTINGS, doDismissToast, doToast, selectToast } from 'lbry-redux';
|
||||
import { SETTINGS, doDismissToast, doPopulateSharedUserState, doPreferenceGet, doToast, selectToast } from 'lbry-redux';
|
||||
import {
|
||||
Lbryio,
|
||||
doGetSync,
|
||||
doUserCheckEmailVerified,
|
||||
doUserEmailVerify,
|
||||
@@ -35,11 +39,12 @@ import {
|
||||
selectEmailToVerify,
|
||||
selectEmailVerifyIsPending,
|
||||
selectEmailVerifyErrorMessage,
|
||||
selectHashChanged,
|
||||
selectUser,
|
||||
} from 'lbryinc';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { decode as atob } from 'base-64';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
@@ -49,6 +54,8 @@ import discoverStyle from 'styles/discover';
|
||||
import searchStyle from 'styles/search';
|
||||
import SearchRightHeaderIcon from 'component/searchRightHeaderIcon';
|
||||
|
||||
const SYNC_GET_INTERVAL = 1000 * 60 * 5; // every 5 minutes
|
||||
|
||||
const menuNavigationButton = navigation => (
|
||||
<NavigationButton
|
||||
name="bars"
|
||||
@@ -127,79 +134,91 @@ const walletStack = createStackNavigator(
|
||||
}
|
||||
);
|
||||
|
||||
const drawerIconSize = 18;
|
||||
const drawer = createDrawerNavigator(
|
||||
{
|
||||
DiscoverStack: {
|
||||
screen: discoverStack,
|
||||
navigationOptions: {
|
||||
title: 'Explore',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="home" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="home" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
TrendingStack: {
|
||||
Trending: {
|
||||
screen: TrendingPage,
|
||||
navigationOptions: {
|
||||
title: 'Trending',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="fire" size={20} style={{ color: tintColor }} />,
|
||||
title: 'All Content',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="fire" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
MySubscriptionsStack: {
|
||||
Subscriptions: {
|
||||
screen: SubscriptionsPage,
|
||||
navigationOptions: {
|
||||
title: 'Subscriptions',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="heart" solid size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="heart" solid size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
WalletStack: {
|
||||
screen: walletStack,
|
||||
navigationOptions: {
|
||||
title: 'Wallet',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
ChannelCreator: {
|
||||
screen: ChannelCreatorPage,
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="at" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
Publish: {
|
||||
screen: PublishPage,
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="upload" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="upload" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
Publishes: {
|
||||
screen: PublishesPage,
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="cloud-upload-alt" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<Icon name="cloud-upload-alt" size={drawerIconSize} style={{ color: tintColor }} />
|
||||
),
|
||||
},
|
||||
},
|
||||
Rewards: {
|
||||
screen: RewardsPage,
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="award" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="award" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
MyLBRYStack: {
|
||||
Downloads: {
|
||||
screen: DownloadsPage,
|
||||
navigationOptions: {
|
||||
title: 'Library',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="download" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="download" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
Settings: {
|
||||
screen: SettingsPage,
|
||||
navigationOptions: {
|
||||
drawerLockMode: 'locked-closed',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="cog" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="cog" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
About: {
|
||||
screen: AboutPage,
|
||||
navigationOptions: {
|
||||
drawerLockMode: 'locked-closed',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="info" size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="info" size={drawerIconSize} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
drawerWidth: 300,
|
||||
drawerBackgroundColor: 'transparent',
|
||||
headerMode: 'none',
|
||||
backBehavior: 'none',
|
||||
unmountInactiveRoutes: true,
|
||||
contentComponent: DrawerContent,
|
||||
contentOptions: {
|
||||
activeTintColor: Colors.LbryGreen,
|
||||
@@ -253,9 +272,11 @@ class AppWithNavigationState extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.emailVerifyCheckInterval = null;
|
||||
this.syncGetInterval = null;
|
||||
this.state = {
|
||||
emailVerifyDone: false,
|
||||
verifyPending: false,
|
||||
syncHashChanged: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -265,29 +286,28 @@ class AppWithNavigationState extends React.Component {
|
||||
'hardwareBackPress',
|
||||
function() {
|
||||
const { dispatch, nav, drawerStack } = this.props;
|
||||
// There should be a better way to check this
|
||||
if (nav.routes.length > 0) {
|
||||
if (nav.routes[0].routeName === 'Main') {
|
||||
const mainRoute = nav.routes[0];
|
||||
if (
|
||||
mainRoute.index > 0 ||
|
||||
mainRoute.routes[0].index > 0 /* Discover stack index */ ||
|
||||
mainRoute.routes[4].index > 0 /* Wallet stack index */ ||
|
||||
mainRoute.index >= 5 /* Settings and About screens */
|
||||
) {
|
||||
dispatchNavigateBack(dispatch, nav, drawerStack);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (drawerStack.length > 1) {
|
||||
dispatchNavigateBack(dispatch, nav, drawerStack);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { dispatch } = this.props;
|
||||
this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000);
|
||||
Linking.addEventListener('url', this._handleUrl);
|
||||
|
||||
// call /sync/get with interval
|
||||
this.syncGetInterval = setInterval(() => {
|
||||
this.setState({ syncHashChanged: false }); // reset local state
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
|
||||
dispatch(doGetSync(walletPassword, () => this.getUserSettings()));
|
||||
});
|
||||
}, SYNC_GET_INTERVAL);
|
||||
}
|
||||
|
||||
checkEmailVerification = () => {
|
||||
@@ -300,27 +320,48 @@ class AppWithNavigationState extends React.Component {
|
||||
});
|
||||
};
|
||||
|
||||
getUserSettings = () => {
|
||||
const { dispatch } = this.props;
|
||||
doPreferenceGet(
|
||||
'shared',
|
||||
preference => {
|
||||
dispatch(doPopulateSharedUserState(preference));
|
||||
},
|
||||
error => {
|
||||
/* failed */
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.removeEventListener('hardwareBackPress');
|
||||
Linking.removeEventListener('url', this._handleUrl);
|
||||
if (this.emailVerifyCheckInterval > -1) {
|
||||
clearInterval(this.emailVerifyCheckInterval);
|
||||
}
|
||||
if (this.syncGetInterval > -1) {
|
||||
clearInterval(this.syncGetInterval);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const { dispatch, user } = this.props;
|
||||
const { dispatch, user, hashChanged } = 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 });
|
||||
|
||||
NativeModules.Firebase.track('email_verified', { email: user.primary_email });
|
||||
ToastAndroid.show('Your email address was successfully verified.', ToastAndroid.LONG);
|
||||
|
||||
// upon successful email verification, do wallet sync (if password has been set)
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
|
||||
if (walletPassword && walletPassword.trim().length > 0) {
|
||||
dispatch(doGetSync(walletPassword));
|
||||
}
|
||||
});
|
||||
// get user settings after email verification
|
||||
this.getUserSettings();
|
||||
}
|
||||
|
||||
if (hashChanged && !this.state.syncHashChanged) {
|
||||
this.setState({ syncHashChanged: true });
|
||||
this.getUserSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +457,7 @@ class AppWithNavigationState extends React.Component {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
dispatchNavigateToUri(dispatch, nav, evt.url);
|
||||
dispatchNavigateToUri(dispatch, nav, transformUrl(evt.url));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -428,6 +469,7 @@ class AppWithNavigationState extends React.Component {
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
||||
hashChanged: selectHashChanged(state),
|
||||
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
|
||||
nav: state.nav,
|
||||
toast: selectToast(state),
|
||||
|
||||
@@ -34,16 +34,11 @@ export default class Button extends React.PureComponent {
|
||||
}
|
||||
|
||||
let renderIcon = (
|
||||
<Icon name={icon} size={18} color={iconColor ? iconColor : 'light' === theme ? Colors.DarkGrey : Colors.White} />
|
||||
<Icon name={icon} size={16} color={iconColor || (theme === 'light' ? Colors.DarkGrey : Colors.White)} />
|
||||
);
|
||||
if (solid) {
|
||||
renderIcon = (
|
||||
<Icon
|
||||
name={icon}
|
||||
size={18}
|
||||
color={iconColor ? iconColor : 'light' === theme ? Colors.DarkGrey : Colors.White}
|
||||
solid
|
||||
/>
|
||||
<Icon name={icon} size={16} color={iconColor || (theme === 'light' ? Colors.DarkGrey : Colors.White)} solid />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doResolveUri, makeSelectClaimForUri, makeSelectThumbnailForUri, makeSelectIsUriResolving } from 'lbry-redux';
|
||||
import {
|
||||
doResolveUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectIsUriResolving,
|
||||
} from 'lbry-redux';
|
||||
import ChannelIconItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,40 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Image, Text, TouchableOpacity, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import autothumbStyle from 'styles/autothumb';
|
||||
import channelIconStyle from 'styles/channelIcon';
|
||||
|
||||
export default class ChannelIconItem extends React.PureComponent {
|
||||
static AUTO_THUMB_STYLES = [
|
||||
autothumbStyle.autothumbPurple,
|
||||
autothumbStyle.autothumbRed,
|
||||
autothumbStyle.autothumbPink,
|
||||
autothumbStyle.autothumbIndigo,
|
||||
autothumbStyle.autothumbBlue,
|
||||
autothumbStyle.autothumbLightBlue,
|
||||
autothumbStyle.autothumbCyan,
|
||||
autothumbStyle.autothumbGreen,
|
||||
autothumbStyle.autothumbYellow,
|
||||
autothumbStyle.autothumbOrange,
|
||||
autothumbStyle.autothumbDeepPurple,
|
||||
autothumbStyle.autothumbAmber,
|
||||
autothumbStyle.autothumbLime,
|
||||
autothumbStyle.autothumbLightGreen,
|
||||
autothumbStyle.autothumbDeepOrange,
|
||||
autothumbStyle.autothumbBrown,
|
||||
];
|
||||
|
||||
state = {
|
||||
autoStyle: null,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
this.setState({
|
||||
autoStyle:
|
||||
ChannelIconItem.AUTO_THUMB_STYLES[Math.floor(Math.random() * ChannelIconItem.AUTO_THUMB_STYLES.length)],
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { claim, isPlaceholder, uri, resolveUri } = this.props;
|
||||
if (!claim && !isPlaceholder) {
|
||||
@@ -13,6 +44,8 @@ export default class ChannelIconItem extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const { claim, isPlaceholder, isResolvingUri, onPress, thumbnail, title } = this.props;
|
||||
const displayName = title || (claim ? claim.name : '');
|
||||
const substrIndex = displayName.startsWith('@') ? 1 : 0;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={channelIconStyle.container} onPress={onPress}>
|
||||
@@ -25,6 +58,7 @@ export default class ChannelIconItem extends React.PureComponent {
|
||||
style={[
|
||||
channelIconStyle.thumbnailContainer,
|
||||
isPlaceholder ? channelIconStyle.borderedThumbnailContainer : null,
|
||||
isPlaceholder ? null : this.state.autoStyle,
|
||||
]}
|
||||
>
|
||||
{isPlaceholder && (
|
||||
@@ -32,17 +66,18 @@ export default class ChannelIconItem extends React.PureComponent {
|
||||
<Text style={channelIconStyle.placeholderText}>ALL</Text>
|
||||
</View>
|
||||
)}
|
||||
{!isPlaceholder && (
|
||||
<Image
|
||||
style={channelIconStyle.thumbnail}
|
||||
resizeMode={'cover'}
|
||||
source={thumbnail ? { uri: thumbnail } : require('../../assets/default_avatar.jpg')}
|
||||
/>
|
||||
{!isPlaceholder && thumbnail && (
|
||||
<Image style={channelIconStyle.thumbnail} resizeMode={'cover'} source={{ uri: thumbnail }} />
|
||||
)}
|
||||
{!isPlaceholder && !thumbnail && (
|
||||
<Text style={channelIconStyle.autothumbCharacter}>
|
||||
{displayName.substring(substrIndex, substrIndex + 1).toUpperCase()}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
{!isPlaceholder && (
|
||||
<Text style={channelIconStyle.title} numberOfLines={1}>
|
||||
{title || (claim ? claim.name : '')}
|
||||
{displayName}
|
||||
</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ChannelRewardsDriver from './view';
|
||||
|
||||
export default connect()(ChannelRewardsDriver);
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import publishStyle from 'styles/publish';
|
||||
|
||||
class ChannelRewardsDriver extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={publishStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
|
||||
<Icon name="award" size={16} style={publishStyle.rewardIcon} />
|
||||
<Text style={publishStyle.rewardDriverText}>Earn some credits to be able to create your channel.</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ChannelRewardsDriver;
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
doCreateChannel,
|
||||
doToast,
|
||||
} from 'lbry-redux';
|
||||
import { doGetSync } from 'lbryinc';
|
||||
import ChannelSelector from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -19,6 +20,7 @@ const perform = dispatch => ({
|
||||
notify: data => dispatch(doToast(data)),
|
||||
createChannel: (name, amount) => dispatch(doCreateChannel(name, amount)),
|
||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
import { CLAIM_VALUES, isNameValid } from 'lbry-redux';
|
||||
import { ActivityIndicator, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { ActivityIndicator, NativeModules, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { logPublish } from 'utils/helper';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import channelSelectorStyle from 'styles/channelSelector';
|
||||
@@ -26,10 +27,20 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { channels, fetchChannelListMine, fetchingChannels } = this.props;
|
||||
if (!channels.length && !fetchingChannels) {
|
||||
const { channels = [], channelName, fetchChannelListMine, fetchingChannels } = this.props;
|
||||
if ((!channels || channels.length === 0) && !fetchingChannels) {
|
||||
fetchChannelListMine();
|
||||
}
|
||||
this.setState({ currentSelectedValue: channelName });
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { channels: prevChannels = [], channelName } = this.props;
|
||||
const { channels = [] } = nextProps;
|
||||
|
||||
if (channels && channels.length !== prevChannels.length && channelName !== this.state.currentSelectedValue) {
|
||||
this.setState({ currentSelectedValue: channelName });
|
||||
}
|
||||
}
|
||||
|
||||
handleCreateCancel = () => {
|
||||
@@ -54,13 +65,13 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
if (channel === CLAIM_VALUES.CHANNEL_NEW) {
|
||||
this.setState({ addingChannel: true });
|
||||
if (onChannelChange) {
|
||||
onChannelChange(channel);
|
||||
onChannelChange(value);
|
||||
}
|
||||
this.handleNewChannelBidChange(newChannelBid);
|
||||
} else {
|
||||
this.setState({ addingChannel: false });
|
||||
if (onChannelChange) {
|
||||
onChannelChange(channel);
|
||||
onChannelChange(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -68,14 +79,22 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
handleNewChannelNameChange = value => {
|
||||
const { notify } = this.props;
|
||||
|
||||
let newChannelName = value;
|
||||
let newChannelName = value,
|
||||
newChannelNameError = '';
|
||||
|
||||
if (newChannelName.startsWith('@')) {
|
||||
newChannelName = newChannelName.slice(1);
|
||||
}
|
||||
|
||||
if (newChannelName.trim().length > 0 && !isNameValid(newChannelName)) {
|
||||
newChannelNameError = 'Your channel name contains invalid characters.';
|
||||
} else if (this.channelExists(newChannelName)) {
|
||||
newChannelNameError = 'You have already created a channel with the same name.';
|
||||
}
|
||||
|
||||
this.setState({
|
||||
newChannelName,
|
||||
newChannelNameError,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -99,7 +118,7 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
};
|
||||
|
||||
handleCreateChannelClick = () => {
|
||||
const { balance, createChannel, onChannelChange, notify } = this.props;
|
||||
const { balance, createChannel, getSync, onChannelChange, notify } = this.props;
|
||||
const { newChannelBid, newChannelName } = this.state;
|
||||
|
||||
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
|
||||
@@ -124,17 +143,21 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
createChannelError: undefined,
|
||||
});
|
||||
|
||||
const success = () => {
|
||||
const success = channelClaim => {
|
||||
this.setState({
|
||||
creatingChannel: false,
|
||||
addingChannel: false,
|
||||
currentSelectedValue: channelName,
|
||||
showCreateChannel: false,
|
||||
});
|
||||
logPublish(channelClaim);
|
||||
|
||||
if (onChannelChange) {
|
||||
onChannelChange(channelName);
|
||||
}
|
||||
|
||||
// sync wallet
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(password => getSync(password));
|
||||
};
|
||||
|
||||
const failure = () => {
|
||||
@@ -149,12 +172,14 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
|
||||
channelExists = name => {
|
||||
const { channels = [] } = this.props;
|
||||
for (let channel of channels) {
|
||||
if (
|
||||
name.toLowerCase() === channel.name.toLowerCase() ||
|
||||
`@${name}`.toLowerCase() === channel.name.toLowerCase()
|
||||
) {
|
||||
return true;
|
||||
if (channels) {
|
||||
for (let channel of channels) {
|
||||
if (
|
||||
name.toLowerCase() === channel.name.toLowerCase() ||
|
||||
`@${name}`.toLowerCase() === channel.name.toLowerCase()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,10 +188,11 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const channel = this.state.addingChannel ? 'new' : this.props.channel;
|
||||
const { fetchingChannels, channels = [] } = this.props;
|
||||
const pickerItems = [{ name: Constants.ITEM_ANONYMOUS }, { name: Constants.ITEM_CREATE_A_CHANNEL }].concat(
|
||||
channels
|
||||
const { enabled, fetchingChannels, channels = [] } = this.props;
|
||||
const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(
|
||||
channels ? channels.map(ch => ch.name) : []
|
||||
);
|
||||
|
||||
const {
|
||||
newChannelName,
|
||||
newChannelNameError,
|
||||
@@ -175,22 +201,24 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
creatingChannel,
|
||||
createChannelError,
|
||||
addingChannel,
|
||||
showCreateChannel,
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
<View style={channelSelectorStyle.container}>
|
||||
<Picker
|
||||
enabled={enabled}
|
||||
selectedValue={this.state.currentSelectedValue}
|
||||
style={channelSelectorStyle.channelPicker}
|
||||
itemStyle={channelSelectorStyle.channelPickerItem}
|
||||
onValueChange={this.handlePickerValueChange}
|
||||
>
|
||||
{pickerItems.map(item => (
|
||||
<Picker.Item label={item.name} value={item.name} key={item.name} />
|
||||
<Picker.Item label={item} value={item} key={item} />
|
||||
))}
|
||||
</Picker>
|
||||
|
||||
{this.state.showCreateChannel && (
|
||||
{showCreateChannel && (
|
||||
<View style={channelSelectorStyle.createChannelContainer}>
|
||||
<View style={channelSelectorStyle.channelInputContainer}>
|
||||
<Text style={channelSelectorStyle.channelAt}>@</Text>
|
||||
@@ -203,11 +231,14 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
underlineColorAndroid={Colors.NextLbryGreen}
|
||||
/>
|
||||
</View>
|
||||
{newChannelNameError.length > 0 && (
|
||||
<Text style={channelSelectorStyle.inlineError}>{newChannelNameError}</Text>
|
||||
)}
|
||||
<View style={channelSelectorStyle.bidRow}>
|
||||
<Text style={channelSelectorStyle.label}>Deposit</Text>
|
||||
<TextInput
|
||||
style={channelSelectorStyle.bidAmountInput}
|
||||
value={String(this.state.newChannelBid)}
|
||||
value={String(newChannelBid)}
|
||||
onChangeText={this.handleNewChannelBidChange}
|
||||
placeholder={'0.00'}
|
||||
keyboardType={'number-pad'}
|
||||
@@ -226,7 +257,7 @@ export default class ChannelSelector extends React.PureComponent {
|
||||
<Link style={channelSelectorStyle.cancelLink} text="Cancel" onPress={this.handleCreateCancel} />
|
||||
<Button
|
||||
style={channelSelectorStyle.createButton}
|
||||
disabled={!(this.state.newChannelName.trim().length > 0 && this.state.newChannelBid > 0)}
|
||||
disabled={!(newChannelName.trim().length > 0 && newChannelBid > 0)}
|
||||
text="Create"
|
||||
onPress={this.handleCreateChannelClick}
|
||||
/>
|
||||
|
||||
@@ -2,44 +2,25 @@ import { connect } from 'react-redux';
|
||||
import {
|
||||
MATURE_TAGS,
|
||||
doClaimSearch,
|
||||
doClaimSearchByTags,
|
||||
makeSelectClaimSearchUrisForTags,
|
||||
makeSelectFetchingClaimSearchForTags,
|
||||
selectClaimSearchByQuery,
|
||||
selectClaimSearchByQueryLastPageReached,
|
||||
selectFetchingClaimSearchByQuery,
|
||||
selectFetchingClaimSearch,
|
||||
selectLastClaimSearchUris,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import ClaimList from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
return {
|
||||
loading: makeSelectFetchingClaimSearchForTags(props.tags)(state),
|
||||
uris: makeSelectClaimSearchUrisForTags(props.tags)(state),
|
||||
// for subscriptions
|
||||
claimSearchLoading: selectFetchingClaimSearch(state),
|
||||
claimSearchUris: selectLastClaimSearchUris(state),
|
||||
};
|
||||
};
|
||||
const select = state => ({
|
||||
showNsfwContent: selectShowNsfw(state),
|
||||
claimSearchByQuery: selectClaimSearchByQuery(state),
|
||||
lastPageReached: selectClaimSearchByQueryLastPageReached(state),
|
||||
loadingByQuery: selectFetchingClaimSearchByQuery(state),
|
||||
loading: selectFetchingClaimSearch(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
claimSearch: options => dispatch(doClaimSearch(Constants.DEFAULT_PAGE_SIZE, options)),
|
||||
searchByTags: (tags, orderBy = Constants.DEFAULT_ORDER_BY, page = 1, additionalOptions = {}) =>
|
||||
dispatch(
|
||||
doClaimSearchByTags(
|
||||
tags,
|
||||
Constants.DEFAULT_PAGE_SIZE,
|
||||
Object.assign(
|
||||
{},
|
||||
{
|
||||
no_totals: true,
|
||||
order_by: orderBy,
|
||||
page,
|
||||
not_tags: MATURE_TAGS,
|
||||
},
|
||||
additionalOptions
|
||||
)
|
||||
)
|
||||
),
|
||||
claimSearch: options => dispatch(doClaimSearch(options)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
+119
-113
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { MATURE_TAGS, normalizeURI } from 'lbry-redux';
|
||||
import { MATURE_TAGS, normalizeURI, createNormalizedClaimSearchKey } from 'lbry-redux';
|
||||
import _ from 'lodash';
|
||||
import FileItem from 'component/fileItem';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
@@ -21,94 +21,82 @@ class ClaimList extends React.PureComponent {
|
||||
state = {
|
||||
currentPage: 1, // initial page load is page 1
|
||||
subscriptionsView: false, // whether or not this claim list is for subscriptions
|
||||
trendingForAllView: false,
|
||||
lastPageReached: false,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const {
|
||||
channelIds,
|
||||
trendingForAll,
|
||||
claimSearch,
|
||||
orderBy = Constants.DEFAULT_ORDER_BY,
|
||||
searchByTags,
|
||||
tags,
|
||||
time,
|
||||
} = this.props;
|
||||
if (channelIds || trendingForAll) {
|
||||
const options = {
|
||||
order_by: orderBy,
|
||||
no_totals: true,
|
||||
not_tags: MATURE_TAGS,
|
||||
page: this.state.currentPage,
|
||||
};
|
||||
if (channelIds) {
|
||||
this.setState({ subscriptionsView: true });
|
||||
options.channel_ids = channelIds;
|
||||
} else if (trendingForAll) {
|
||||
this.setState({ trendingForAllView: true });
|
||||
}
|
||||
const { channelIds } = this.props;
|
||||
|
||||
claimSearch(options);
|
||||
} else if (tags && tags.length > 0) {
|
||||
const additionalOptions = {};
|
||||
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
|
||||
additionalOptions.release_time = this.getReleaseTimeOption(time);
|
||||
}
|
||||
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
|
||||
if (channelIds) {
|
||||
this.setState({ subscriptionsView: true });
|
||||
}
|
||||
|
||||
this.doClaimSearch();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentDidUpdate(prevProps) {
|
||||
const {
|
||||
claimSearch,
|
||||
claimSearchByQuery: prevClaimSearchByQuery,
|
||||
orderBy: prevOrderBy,
|
||||
searchByTags,
|
||||
tags: prevTags,
|
||||
channelIds: prevChannelIds,
|
||||
trendingForAll: prevTrendingForAll,
|
||||
time: prevTime,
|
||||
} = this.props;
|
||||
const { orderBy, tags, channelIds, trendingForAll, time } = nextProps;
|
||||
} = prevProps;
|
||||
const { claimSearchByQuery, orderBy, tags, channelIds, time } = this.props;
|
||||
|
||||
if (
|
||||
!_.isEqual(orderBy, prevOrderBy) ||
|
||||
!_.isEqual(tags, prevTags) ||
|
||||
!_.isEqual(channelIds, prevChannelIds) ||
|
||||
time !== prevTime ||
|
||||
trendingForAll !== prevTrendingForAll
|
||||
time !== prevTime
|
||||
) {
|
||||
// reset to page 1 because the order, tags or channelIds changed
|
||||
this.setState({ currentPage: 1 }, () => {
|
||||
if (this.scrollView) {
|
||||
this.scrollView.scrollToOffset({ animated: true, offset: 0 });
|
||||
}
|
||||
if (trendingForAll || (prevChannelIds && channelIds)) {
|
||||
const options = {
|
||||
order_by: orderBy,
|
||||
no_totals: true,
|
||||
not_tags: MATURE_TAGS,
|
||||
page: this.state.currentPage,
|
||||
};
|
||||
|
||||
if (prevChannelIds && channelIds) {
|
||||
if (channelIds) {
|
||||
this.setState({ subscriptionsView: true });
|
||||
options.channel_ids = channelIds;
|
||||
}
|
||||
if (trendingForAll) {
|
||||
this.setState({ trendingForAllView: true });
|
||||
}
|
||||
|
||||
claimSearch(options);
|
||||
} else if (tags && tags.length > 0) {
|
||||
this.setState({ subscriptionsView: false, trendingForAllView: false });
|
||||
const additionalOptions = {};
|
||||
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
|
||||
additionalOptions.release_time = this.getReleaseTimeOption(time);
|
||||
}
|
||||
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
|
||||
this.setState({ subscriptionsView: false });
|
||||
}
|
||||
|
||||
this.doClaimSearch();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
buildClaimSearchOptions() {
|
||||
const { orderBy, channelIds, showNsfwContent, tags, time } = this.props;
|
||||
const { currentPage, subscriptionsView } = this.state;
|
||||
|
||||
const options = {
|
||||
order_by: orderBy,
|
||||
no_totals: true,
|
||||
page: currentPage,
|
||||
page_size: Constants.DEFAULT_PAGE_SIZE,
|
||||
};
|
||||
|
||||
if (channelIds) {
|
||||
options.channel_ids = channelIds;
|
||||
} else if (tags && tags.length > 0) {
|
||||
options.any_tags = tags;
|
||||
}
|
||||
if (!showNsfwContent) {
|
||||
options.not_tags = MATURE_TAGS;
|
||||
}
|
||||
|
||||
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
|
||||
options.release_time = this.getReleaseTimeOption(time);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
getReleaseTimeOption = time => {
|
||||
return `>${Math.floor(
|
||||
moment()
|
||||
@@ -117,36 +105,27 @@ class ClaimList extends React.PureComponent {
|
||||
)}`;
|
||||
};
|
||||
|
||||
doClaimSearch() {
|
||||
const { claimSearch } = this.props;
|
||||
const options = this.buildClaimSearchOptions();
|
||||
claimSearch(options);
|
||||
}
|
||||
|
||||
handleVerticalEndReached = () => {
|
||||
// fetch more content
|
||||
const { channelIds, claimSearch, claimSearchUris, orderBy, searchByTags, tags, time, uris } = this.props;
|
||||
const { subscriptionsView, trendingForAllView } = this.state;
|
||||
if ((claimSearchUris && claimSearchUris.length >= softLimit) || (uris && uris.length >= softLimit)) {
|
||||
// don't fetch more than the specified limit to be displayed
|
||||
const { claimSearchByQuery, lastPageReached } = this.props;
|
||||
|
||||
const options = this.buildClaimSearchOptions();
|
||||
const claimSearchKey = createNormalizedClaimSearchKey(options);
|
||||
const uris = claimSearchByQuery[claimSearchKey];
|
||||
if (
|
||||
lastPageReached[claimSearchKey] ||
|
||||
((uris.length > 0 && uris.length < Constants.DEFAULT_PAGE_SIZE) || uris.length >= softLimit)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({ currentPage: this.state.currentPage + 1 }, () => {
|
||||
if (subscriptionsView || trendingForAllView) {
|
||||
const options = {
|
||||
order_by: orderBy,
|
||||
no_totals: true,
|
||||
not_tags: MATURE_TAGS,
|
||||
page: this.state.currentPage,
|
||||
};
|
||||
if (subscriptionsView) {
|
||||
options.channel_ids = channelIds;
|
||||
}
|
||||
|
||||
claimSearch(options);
|
||||
} else {
|
||||
const additionalOptions = {};
|
||||
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
|
||||
additionalOptions.release_time = this.getReleaseTimeOption(time);
|
||||
}
|
||||
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
|
||||
}
|
||||
});
|
||||
this.setState({ currentPage: this.state.currentPage + 1 }, () => this.doClaimSearch());
|
||||
};
|
||||
|
||||
appendMorePlaceholder = items => {
|
||||
@@ -161,7 +140,7 @@ class ClaimList extends React.PureComponent {
|
||||
if (tags.length === 1) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: 'tagPage', params: { tag: tags[0] } });
|
||||
} else {
|
||||
navigation.navigate({ routeName: Constants.FULL_ROUTE_NAME_TRENDING });
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TRENDING, params: { filterForTags: true } });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,22 +153,64 @@ class ClaimList extends React.PureComponent {
|
||||
);
|
||||
};
|
||||
|
||||
verticalListEmptyComponent = () => {
|
||||
return (
|
||||
<Text style={claimListStyle.noContentText}>No content to display at this time. Please check back later.</Text>
|
||||
);
|
||||
};
|
||||
|
||||
renderVerticalItem = ({ item }) => {
|
||||
const { hideChannel, navigation } = this.props;
|
||||
return (
|
||||
<FileListItem
|
||||
key={item}
|
||||
uri={item}
|
||||
hideChannel={hideChannel}
|
||||
style={claimListStyle.verticalListItem}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
renderHorizontalItem = ({ item }) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return item === Constants.MORE_PLACEHOLDER ? (
|
||||
this.renderMorePlaceholder()
|
||||
) : (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
showDetails
|
||||
compactView={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
ListHeaderComponent,
|
||||
loading,
|
||||
claimSearchLoading,
|
||||
claimSearchUris,
|
||||
morePlaceholder,
|
||||
navigation,
|
||||
orientation = Constants.ORIENTATION_VERTICAL,
|
||||
style,
|
||||
uris,
|
||||
claimSearchByQuery,
|
||||
} = this.props;
|
||||
const { subscriptionsView, trendingForAllView } = this.state;
|
||||
const { subscriptionsView } = this.state;
|
||||
|
||||
const options = this.buildClaimSearchOptions();
|
||||
const claimSearchKey = createNormalizedClaimSearchKey(options);
|
||||
let uris = claimSearchByQuery[claimSearchKey];
|
||||
|
||||
if (uris) {
|
||||
uris = uris.filter(uri => uri && uri.length > 0);
|
||||
}
|
||||
|
||||
if (Constants.ORIENTATION_VERTICAL === orientation) {
|
||||
const data = subscriptionsView || trendingForAllView ? claimSearchUris : uris;
|
||||
return (
|
||||
<View style={style}>
|
||||
<FlatList
|
||||
@@ -197,22 +218,21 @@ class ClaimList extends React.PureComponent {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
ListHeaderComponent={ListHeaderComponent}
|
||||
ListEmptyComponent={loading ? null : this.verticalListEmptyComponent}
|
||||
style={claimListStyle.verticalScrollContainer}
|
||||
contentContainerStyle={claimListStyle.verticalScrollPadding}
|
||||
initialNumToRender={8}
|
||||
maxToRenderPerBatch={24}
|
||||
initialNumToRender={10}
|
||||
maxToRenderPerBatch={20}
|
||||
removeClippedSubviews
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem key={item} uri={item} style={claimListStyle.verticalListItem} navigation={navigation} />
|
||||
)}
|
||||
data={data}
|
||||
renderItem={this.renderVerticalItem}
|
||||
data={uris}
|
||||
keyExtractor={(item, index) => item}
|
||||
onEndReached={this.handleVerticalEndReached}
|
||||
onEndReachedThreshold={0.9}
|
||||
onEndReachedThreshold={0.2}
|
||||
/>
|
||||
{(((subscriptionsView || trendingForAllView) && claimSearchLoading) || loading) && (
|
||||
{loading && (
|
||||
<View style={claimListStyle.verticalLoading}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
@@ -223,7 +243,7 @@ class ClaimList extends React.PureComponent {
|
||||
if (loading) {
|
||||
return (
|
||||
<View style={discoverStyle.listLoading}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -235,21 +255,7 @@ class ClaimList extends React.PureComponent {
|
||||
initialNumToRender={3}
|
||||
maxToRenderPerBatch={3}
|
||||
removeClippedSubviews
|
||||
renderItem={({ item }) => {
|
||||
return item === Constants.MORE_PLACEHOLDER ? (
|
||||
this.renderMorePlaceholder()
|
||||
) : (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
showDetails
|
||||
compactView={false}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
renderItem={this.renderHorizontalItem}
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
data={uris ? this.appendMorePlaceholder(uris.slice(0, horizontalLimit)) : []}
|
||||
|
||||
@@ -57,7 +57,7 @@ class CustomRewardCard extends React.PureComponent<Props> {
|
||||
return (
|
||||
<View style={[rewardStyle.rewardCard, rewardStyle.row]}>
|
||||
<View style={rewardStyle.leftCol}>
|
||||
{rewardIsPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
{rewardIsPending && <ActivityIndicator size="small" color={Colors.NextLbryGreen} />}
|
||||
</View>
|
||||
<View style={rewardStyle.midCol}>
|
||||
<Text style={rewardStyle.rewardTitle}>Custom Code</Text>
|
||||
|
||||
@@ -1,36 +1,97 @@
|
||||
import React from 'react';
|
||||
import { DrawerItems, SafeAreaView } from 'react-navigation';
|
||||
import { ScrollView } from 'react-native';
|
||||
import Constants from 'constants';
|
||||
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
const groupedMenuItems = {
|
||||
'Find content': [
|
||||
{ icon: 'hashtag', label: 'Your tags', route: Constants.DRAWER_ROUTE_DISCOVER },
|
||||
{ icon: 'heart', solid: true, label: 'Subscriptions', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
|
||||
{ icon: 'globe-americas', label: 'All content', route: Constants.DRAWER_ROUTE_TRENDING },
|
||||
],
|
||||
'Your content': [
|
||||
{ icon: 'at', label: 'Channels', route: Constants.DRAWER_ROUTE_CHANNEL_CREATOR },
|
||||
{ icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY },
|
||||
{ icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES },
|
||||
{ icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH },
|
||||
],
|
||||
Wallet: [
|
||||
{ icon: 'wallet', label: 'Wallet', route: Constants.DRAWER_ROUTE_WALLET },
|
||||
{ icon: 'award', label: 'Rewards', route: Constants.DRAWER_ROUTE_REWARDS },
|
||||
],
|
||||
Settings: [
|
||||
{ icon: 'cog', label: 'Settings', route: Constants.DRAWER_ROUTE_SETTINGS },
|
||||
{ icon: 'info', label: 'About', route: Constants.DRAWER_ROUTE_ABOUT },
|
||||
],
|
||||
};
|
||||
|
||||
const groupNames = Object.keys(groupedMenuItems);
|
||||
|
||||
class DrawerContent extends React.PureComponent {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const { navigation, onItemPress } = props;
|
||||
const { activeTintColor, navigation, onItemPress } = this.props;
|
||||
const { state } = navigation;
|
||||
|
||||
const activeItemKey = state.routes[state.index] ? state.routes[state.index].key : null;
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<SafeAreaView style={discoverStyle.drawerContentContainer} forceInset={{ top: 'always', horizontal: 'never' }}>
|
||||
<DrawerItems
|
||||
{...props}
|
||||
onItemPress={route => {
|
||||
const { routeName } = route.route;
|
||||
if (Constants.FULL_ROUTE_NAME_DISCOVER === routeName) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_DISCOVER });
|
||||
return;
|
||||
}
|
||||
<View style={discoverStyle.drawerContentArea}>
|
||||
<ScrollView contentContainerStyle={discoverStyle.menuScrollContent}>
|
||||
<SafeAreaView
|
||||
style={discoverStyle.drawerContentContainer}
|
||||
forceInset={{ top: 'always', horizontal: 'never' }}
|
||||
>
|
||||
{groupNames.map(groupName => {
|
||||
const menuItems = groupedMenuItems[groupName];
|
||||
|
||||
if (Constants.FULL_ROUTE_NAME_WALLET === routeName) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_WALLET });
|
||||
return;
|
||||
}
|
||||
|
||||
onItemPress(route);
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
</ScrollView>
|
||||
return (
|
||||
<View key={groupName} style={discoverStyle.menuGroup}>
|
||||
{groupNames[3] !== groupName && (
|
||||
<Text key={`${groupName}-title`} style={discoverStyle.menuGroupName}>
|
||||
{groupName}
|
||||
</Text>
|
||||
)}
|
||||
{menuItems.map(item => {
|
||||
const focused =
|
||||
activeItemKey === item.route ||
|
||||
(activeItemKey === Constants.FULL_ROUTE_NAME_DISCOVER &&
|
||||
item.route === Constants.DRAWER_ROUTE_DISCOVER) ||
|
||||
(activeItemKey === Constants.FULL_ROUTE_NAME_WALLET &&
|
||||
item.route === Constants.DRAWER_ROUTE_WALLET);
|
||||
return (
|
||||
<TouchableOpacity
|
||||
accessible
|
||||
accessibilityLabel={item.label}
|
||||
style={[
|
||||
discoverStyle.menuItemTouchArea,
|
||||
focused ? discoverStyle.menuItemTouchAreaFocused : null,
|
||||
]}
|
||||
key={item.label}
|
||||
onPress={() => navigation.navigate({ routeName: item.route })}
|
||||
delayPressIn={0}
|
||||
>
|
||||
<View style={discoverStyle.menuItemIcon}>
|
||||
<Icon
|
||||
name={item.icon}
|
||||
size={16}
|
||||
solid={item.solid}
|
||||
color={focused ? activeTintColor : null}
|
||||
/>
|
||||
</View>
|
||||
<Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}>
|
||||
{item.label}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</SafeAreaView>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import EmptyStateView from './view';
|
||||
|
||||
export default connect()(EmptyStateView);
|
||||
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { NativeModules, Text, View, Image, TouchableOpacity } from 'react-native';
|
||||
import Button from '../button';
|
||||
import emptyStateStyle from 'styles/emptyState';
|
||||
|
||||
class EmptyStateView extends React.PureComponent {
|
||||
render() {
|
||||
const { message, buttonText, inner, onButtonPress } = this.props;
|
||||
|
||||
return (
|
||||
<View
|
||||
style={[emptyStateStyle.container, inner ? emptyStateStyle.innerContainer : emptyStateStyle.outerContainer]}
|
||||
>
|
||||
<Image style={emptyStateStyle.image} resizeMode={'stretch'} source={require('../../assets/gerbil-happy.png')} />
|
||||
<Text style={emptyStateStyle.message}>{message}</Text>
|
||||
{buttonText && (
|
||||
<View style={emptyStateStyle.buttonContainer}>
|
||||
<Button style={emptyStateStyle.button} text={buttonText} onPress={onButtonPress} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default EmptyStateView;
|
||||
@@ -8,18 +8,22 @@ import {
|
||||
makeSelectTitleForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectClaimIsNsfw,
|
||||
makeSelectShortUrlForUri,
|
||||
} from 'lbry-redux';
|
||||
import { selectRewardContentClaimIds } from 'lbryinc';
|
||||
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
filteredOutpoints: selectFilteredOutpoints(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
|
||||
|
||||
@@ -30,39 +30,60 @@ class FileItem extends React.PureComponent {
|
||||
}
|
||||
|
||||
navigateToFileUri = () => {
|
||||
const { navigation, uri } = this.props;
|
||||
const { navigation, uri, shortUrl } = this.props;
|
||||
const normalizedUri = normalizeURI(uri);
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('explore_click', { uri: normalizedUri });
|
||||
NativeModules.Firebase.track('explore_click', { uri: normalizedUri, short_url: shortUrl });
|
||||
}
|
||||
navigateToUri(navigation, normalizedUri);
|
||||
navigateToUri(navigation, shortUrl || uri);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
blackListedOutpoints,
|
||||
claim,
|
||||
title,
|
||||
thumbnail,
|
||||
fileInfo,
|
||||
filteredOutpoints,
|
||||
metadata,
|
||||
isResolvingUri,
|
||||
rewardedContentClaimIds,
|
||||
style,
|
||||
mediaStyle,
|
||||
navigation,
|
||||
nsfw,
|
||||
obscureNsfw,
|
||||
showDetails,
|
||||
compactView,
|
||||
titleBeforeThumbnail,
|
||||
} = this.props;
|
||||
|
||||
if (claim && claim.value_type === 'channel') {
|
||||
// don't display channels in the lists on the Your tags page
|
||||
return null;
|
||||
}
|
||||
|
||||
let shouldHide = false;
|
||||
if (blackListedOutpoints || filteredOutpoints) {
|
||||
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
|
||||
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
|
||||
}
|
||||
if (shouldHide) {
|
||||
// don't display blacklisted or filtered outpoints on the Your tags page
|
||||
return null;
|
||||
}
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const obscure = obscureNsfw && nsfw;
|
||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const signingChannel = claim ? claim.signing_channel : null;
|
||||
const channelName = signingChannel ? signingChannel.name : null;
|
||||
const channelClaimId = signingChannel ? signingChannel.claim_id : null;
|
||||
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
|
||||
const shortChannelUri = signingChannel ? signingChannel.short_url : null;
|
||||
const height = claim ? claim.height : null;
|
||||
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
@@ -73,14 +94,13 @@ class FileItem extends React.PureComponent {
|
||||
</Text>
|
||||
)}
|
||||
<FileItemMedia
|
||||
duration={duration}
|
||||
title={title}
|
||||
thumbnail={thumbnail}
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
resizeMode="cover"
|
||||
isResolvingUri={isResolvingUri}
|
||||
style={mediaStyle}
|
||||
/>
|
||||
|
||||
{!compactView && fileInfo && fileInfo.completed && fileInfo.download_path && (
|
||||
<Icon style={discoverStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
|
||||
)}
|
||||
@@ -102,17 +122,16 @@ class FileItem extends React.PureComponent {
|
||||
style={discoverStyle.channelName}
|
||||
text={channelName}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!channelName && !isResolvingUri && <Text style={discoverStyle.anonChannelName}>Anonymous</Text>}
|
||||
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo uri={uri} />
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
{obscureNsfw && (
|
||||
<NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />
|
||||
)}
|
||||
{obscure && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,24 +2,26 @@ import React from 'react';
|
||||
import { ActivityIndicator, Image, Text, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import FastImage from 'react-native-fast-image';
|
||||
import VideoDuration from 'component/videoDuration';
|
||||
import autothumbStyle from 'styles/autothumb';
|
||||
import fileItemMediaStyle from 'styles/fileItemMedia';
|
||||
|
||||
class FileItemMedia extends React.PureComponent {
|
||||
static AUTO_THUMB_STYLES = [
|
||||
fileItemMediaStyle.autothumbPurple,
|
||||
fileItemMediaStyle.autothumbRed,
|
||||
fileItemMediaStyle.autothumbPink,
|
||||
fileItemMediaStyle.autothumbIndigo,
|
||||
fileItemMediaStyle.autothumbBlue,
|
||||
fileItemMediaStyle.autothumbLightBlue,
|
||||
fileItemMediaStyle.autothumbCyan,
|
||||
fileItemMediaStyle.autothumbTeal,
|
||||
fileItemMediaStyle.autothumbGreen,
|
||||
fileItemMediaStyle.autothumbYellow,
|
||||
fileItemMediaStyle.autothumbOrange,
|
||||
autothumbStyle.autothumbPurple,
|
||||
autothumbStyle.autothumbRed,
|
||||
autothumbStyle.autothumbPink,
|
||||
autothumbStyle.autothumbIndigo,
|
||||
autothumbStyle.autothumbBlue,
|
||||
autothumbStyle.autothumbLightBlue,
|
||||
autothumbStyle.autothumbCyan,
|
||||
autothumbStyle.autothumbTeal,
|
||||
autothumbStyle.autothumbGreen,
|
||||
autothumbStyle.autothumbYellow,
|
||||
autothumbStyle.autothumbOrange,
|
||||
];
|
||||
|
||||
state: {
|
||||
state = {
|
||||
imageLoadFailed: false,
|
||||
};
|
||||
|
||||
@@ -48,7 +50,7 @@ class FileItemMedia extends React.PureComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (thumbnail.substring(0, 7) != 'http://' && thumbnail.substring(0, 8) != 'https://') {
|
||||
if (thumbnail.substring(0, 7) !== 'http://' && thumbnail.substring(0, 8) !== 'https://') {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,37 +59,34 @@ class FileItemMedia extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
let style = this.props.style;
|
||||
const { blurRadius, isResolvingUri, thumbnail, title, resizeMode } = this.props;
|
||||
const { duration, isResolvingUri, thumbnail, title, resizeMode } = this.props;
|
||||
const atStyle = this.state.autoThumbStyle;
|
||||
if (this.isThumbnailValid(thumbnail) && !this.state.imageLoadFailed) {
|
||||
if (style == null) {
|
||||
style = fileItemMediaStyle.thumbnail;
|
||||
}
|
||||
|
||||
if (blurRadius > 0) {
|
||||
// No blur radius support in FastImage yet
|
||||
return (
|
||||
<Image
|
||||
source={{ uri: thumbnail }}
|
||||
blurRadius={blurRadius}
|
||||
resizeMode={resizeMode ? resizeMode : 'cover'}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FastImage
|
||||
source={{ uri: thumbnail }}
|
||||
onError={() => this.setState({ imageLoadFailed: true })}
|
||||
resizeMode={this.getFastImageResizeMode(resizeMode)}
|
||||
style={style}
|
||||
/>
|
||||
<View style={style}>
|
||||
<FastImage
|
||||
source={{ uri: thumbnail }}
|
||||
onError={() => this.setState({ imageLoadFailed: true })}
|
||||
resizeMode={this.getFastImageResizeMode(resizeMode)}
|
||||
style={fileItemMediaStyle.image}
|
||||
/>
|
||||
{duration && (
|
||||
<VideoDuration
|
||||
duration={duration}
|
||||
style={fileItemMediaStyle.duration}
|
||||
textStyle={fileItemMediaStyle.durationText}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[style ? style : fileItemMediaStyle.autothumb, atStyle]}>
|
||||
<View style={[style || fileItemMediaStyle.autothumb, atStyle]}>
|
||||
{isResolvingUri && (
|
||||
<View style={fileItemMediaStyle.resolving}>
|
||||
<ActivityIndicator color={Colors.White} size={'large'} />
|
||||
@@ -104,6 +103,13 @@ class FileItemMedia extends React.PureComponent {
|
||||
.toUpperCase()}
|
||||
</Text>
|
||||
)}
|
||||
{duration && (
|
||||
<VideoDuration
|
||||
duration={duration}
|
||||
style={fileItemMediaStyle.duration}
|
||||
textStyle={fileItemMediaStyle.durationText}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,39 +53,39 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
dateNew: fileInfos =>
|
||||
this.props.sortByHeight
|
||||
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||
if (fileInfo1.pending) {
|
||||
return -1;
|
||||
}
|
||||
const height1 = this.props.claimsById[fileInfo1.claim_id]
|
||||
? this.props.claimsById[fileInfo1.claim_id].height
|
||||
: 0;
|
||||
const height2 = this.props.claimsById[fileInfo2.claim_id]
|
||||
? this.props.claimsById[fileInfo2.claim_id].height
|
||||
: 0;
|
||||
if (height1 > height2) {
|
||||
return -1;
|
||||
} else if (height1 < height2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
if (fileInfo1.pending) {
|
||||
return -1;
|
||||
}
|
||||
const height1 = this.props.claimsById[fileInfo1.claim_id]
|
||||
? this.props.claimsById[fileInfo1.claim_id].height
|
||||
: 0;
|
||||
const height2 = this.props.claimsById[fileInfo2.claim_id]
|
||||
? this.props.claimsById[fileInfo2.claim_id].height
|
||||
: 0;
|
||||
if (height1 > height2) {
|
||||
return -1;
|
||||
} else if (height1 < height2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
: [...fileInfos].reverse(),
|
||||
dateOld: fileInfos =>
|
||||
this.props.sortByHeight
|
||||
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||
const height1 = this.props.claimsById[fileInfo1.claim_id]
|
||||
? this.props.claimsById[fileInfo1.claim_id].height
|
||||
: 999999;
|
||||
const height2 = this.props.claimsById[fileInfo2.claim_id]
|
||||
? this.props.claimsById[fileInfo2.claim_id].height
|
||||
: 999999;
|
||||
if (height1 < height2) {
|
||||
return -1;
|
||||
} else if (height1 > height2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
const height1 = this.props.claimsById[fileInfo1.claim_id]
|
||||
? this.props.claimsById[fileInfo1.claim_id].height
|
||||
: 999999;
|
||||
const height2 = this.props.claimsById[fileInfo2.claim_id]
|
||||
? this.props.claimsById[fileInfo2.claim_id].height
|
||||
: 999999;
|
||||
if (height1 < height2) {
|
||||
return -1;
|
||||
} else if (height1 > height2) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
: fileInfos,
|
||||
title: fileInfos =>
|
||||
fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||
@@ -160,7 +160,7 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
// This is unfortunate
|
||||
// https://github.com/lbryio/lbry/issues/1159
|
||||
const name = claimName || claimNameDownloaded;
|
||||
uriParams.contentName = name;
|
||||
uriParams.claimName = name;
|
||||
uriParams.claimId = claimId;
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
@@ -179,7 +179,7 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
style={fileListStyle.fileItem}
|
||||
uri={item}
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
showDetails
|
||||
compactView={false}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -5,19 +5,27 @@ import {
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectClaimIsNsfw,
|
||||
makeSelectShortUrlForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
} from 'lbry-redux';
|
||||
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileListItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
filteredOutpoints: selectFilteredOutpoints(state),
|
||||
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state),
|
||||
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { navigateToUri, formatBytes } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import DateTime from 'component/dateTime';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
@@ -12,6 +13,10 @@ import ProgressBar from 'component/progressBar';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
|
||||
class FileListItem extends React.PureComponent {
|
||||
state = {
|
||||
url: null,
|
||||
};
|
||||
|
||||
getStorageForFileInfo = fileInfo => {
|
||||
if (!fileInfo.completed) {
|
||||
const written = formatBytes(fileInfo.written_bytes);
|
||||
@@ -41,55 +46,115 @@ class FileListItem extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const { claim, resolveUri, uri } = this.props;
|
||||
if (!claim && uri !== this.state.url) {
|
||||
this.setState({ url: uri }, () => resolveUri(uri));
|
||||
}
|
||||
}
|
||||
|
||||
defaultOnPress = () => {
|
||||
const { navigation, uri } = this.props;
|
||||
navigateToUri(navigation, uri);
|
||||
const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
|
||||
|
||||
if (featuredResult && !claim) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
|
||||
} else {
|
||||
navigateToUri(navigation, shortUrl || uri, { autoplay });
|
||||
}
|
||||
};
|
||||
|
||||
onPressHandler = () => {
|
||||
const { claim, onPress } = this.props;
|
||||
if (onPress) {
|
||||
onPress(claim);
|
||||
} else {
|
||||
this.defaultOnPress();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
blackListedOutpoints,
|
||||
claim,
|
||||
fileInfo,
|
||||
filteredOutpoints,
|
||||
metadata,
|
||||
nsfw,
|
||||
featuredResult,
|
||||
isResolvingUri,
|
||||
isDownloaded,
|
||||
style,
|
||||
obscureNsfw,
|
||||
onPress,
|
||||
navigation,
|
||||
rewardedContentClaimIds,
|
||||
thumbnail,
|
||||
hideChannel,
|
||||
onLongPress,
|
||||
selected,
|
||||
title,
|
||||
} = this.props;
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const obscure = obscureNsfw && nsfw;
|
||||
const isResolving = !fileInfo && isResolvingUri;
|
||||
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
|
||||
|
||||
let name, channel, height, channelClaimId, fullChannelUri, signingChannel;
|
||||
let name,
|
||||
channel,
|
||||
height,
|
||||
isRewardContent,
|
||||
channelClaimId,
|
||||
fullChannelUri,
|
||||
shortChannelUri,
|
||||
shouldHide,
|
||||
signingChannel;
|
||||
if (claim) {
|
||||
name = claim.name;
|
||||
signingChannel = claim.signing_channel;
|
||||
channel = signingChannel ? signingChannel.name : null;
|
||||
height = claim.height;
|
||||
isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
channelClaimId = signingChannel ? signingChannel.claim_id : null;
|
||||
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
|
||||
shortChannelUri = signingChannel ? signingChannel.short_url : null;
|
||||
|
||||
if (blackListedOutpoints || filteredOutpoints) {
|
||||
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
|
||||
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
|
||||
}
|
||||
|
||||
// TODO: hide channels on tag pages?
|
||||
// shouldHide = 'channel' === claim.value_type;
|
||||
}
|
||||
|
||||
if (featuredResult && !isResolvingUri && !claim && !title && !name) {
|
||||
if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<TouchableOpacity style={style} onPress={onPress || this.defaultOnPress}>
|
||||
<TouchableOpacity
|
||||
style={style}
|
||||
onPress={this.onPressHandler}
|
||||
onLongPress={() => {
|
||||
if (onLongPress) {
|
||||
onLongPress(claim);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<FileItemMedia
|
||||
style={fileListStyle.thumbnail}
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
duration={duration}
|
||||
resizeMode="cover"
|
||||
title={title || name}
|
||||
title={title || name || normalizeURI(uri).substring(7)}
|
||||
thumbnail={thumbnail}
|
||||
/>
|
||||
{selected && (
|
||||
<View style={fileListStyle.selectedOverlay}>
|
||||
<Icon name={'check-circle'} solid color={Colors.NextLbryGreen} size={32} />
|
||||
</View>
|
||||
)}
|
||||
{fileInfo && fileInfo.completed && fileInfo.download_path && (
|
||||
<Icon style={fileListStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
|
||||
)}
|
||||
@@ -112,16 +177,26 @@ class FileListItem extends React.PureComponent {
|
||||
)}
|
||||
|
||||
{(title || name) && (
|
||||
<Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>
|
||||
{this.formatTitle(title) || this.formatTitle(name)}
|
||||
</Text>
|
||||
<View style={fileListStyle.titleContainer}>
|
||||
<Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>
|
||||
{this.formatTitle(title) || this.formatTitle(name)}
|
||||
</Text>
|
||||
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{featuredResult && !isResolving && !claim && (
|
||||
<View style={fileListStyle.titleContainer}>
|
||||
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{channel && !hideChannel && (
|
||||
<Link
|
||||
style={fileListStyle.publisher}
|
||||
text={channel}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@@ -148,9 +223,7 @@ class FileListItem extends React.PureComponent {
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
{obscureNsfw && (
|
||||
<NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />
|
||||
)}
|
||||
{obscure && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class FileRewardsDriver extends React.PureComponent<Props> {
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={filePageStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
|
||||
<Icon name="award" size={16} style={filePageStyle.rewardIcon} />
|
||||
<Icon name="award" size={16} style={filePageStyle.rewardDriverIcon} />
|
||||
<Text style={filePageStyle.rewardDriverText}>Earn some credits to access this content.</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
@@ -23,7 +23,7 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
|
||||
style={floatingButtonStyle.pendingContainer}
|
||||
onPress={() => navigation && navigation.navigate({ routeName: 'Rewards' })}
|
||||
>
|
||||
<Icon name="award" size={18} style={floatingButtonStyle.rewardIcon} />
|
||||
<Icon name="award" size={14} style={floatingButtonStyle.rewardIcon} />
|
||||
<Text style={floatingButtonStyle.text}>{unclaimedRewardAmount}</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
@@ -31,9 +31,10 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
|
||||
style={floatingButtonStyle.container}
|
||||
onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}
|
||||
>
|
||||
<Icon name="coins" size={12} style={floatingButtonStyle.balanceIcon} />
|
||||
{isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />}
|
||||
{(!isNaN(balance) || balance === 0) && (
|
||||
<Text style={floatingButtonStyle.text}>{formatCredits(parseFloat(balance), 2) + ' LBC'}</Text>
|
||||
<Text style={floatingButtonStyle.text}>{formatCredits(parseFloat(balance), 1, true)}</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
@@ -418,6 +418,13 @@ class MediaPlayer extends React.PureComponent {
|
||||
: mediaPlayerStyle.containedTrackingControls,
|
||||
];
|
||||
|
||||
const seekerCircleStyle = [this.state.seeking ? mediaPlayerStyle.bigSeekerCircle : mediaPlayerStyle.seekerCircle];
|
||||
if (!this.state.seeking) {
|
||||
seekerCircleStyle.push(
|
||||
this.state.fullscreenMode ? mediaPlayerStyle.seekerCircleTopFs : mediaPlayerStyle.seekerCircleTop
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles} onLayout={onLayout}>
|
||||
<Video
|
||||
@@ -468,7 +475,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
|
||||
{this.state.buffering && (
|
||||
<View style={mediaPlayerStyle.loadingContainer}>
|
||||
<ActivityIndicator color={Colors.LbryGreen} size="large" />
|
||||
<ActivityIndicator color={Colors.NextLbryGreen} size="large" />
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -482,7 +489,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
]}
|
||||
{...this.seekResponder.panHandlers}
|
||||
>
|
||||
<View style={this.state.seeking ? mediaPlayerStyle.bigSeekerCircle : mediaPlayerStyle.seekerCircle} />
|
||||
<View style={seekerCircleStyle} />
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ModalSuggestedSubscriptions from './view';
|
||||
|
||||
export default connect()(ModalSuggestedSubscriptions);
|
||||
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||
import modalStyle from 'styles/modal';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
||||
export default class ModalSuggestedSubcriptions extends React.PureComponent {
|
||||
render() {
|
||||
const { navigation, onDonePress, onOverlayPress } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={modalStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
|
||||
<TouchableOpacity style={[modalStyle.container, subscriptionsStyle.modalContainer]} activeOpacity={1}>
|
||||
<SuggestedSubscriptions inModal navigation={navigation} />
|
||||
<View style={modalStyle.buttons}>
|
||||
<Button style={modalStyle.doneButton} text={'Done'} onPress={onDonePress} />
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import TagSearch from 'component/tagSearch';
|
||||
import modalTagSelectorStyle from 'styles/modalTagSelector';
|
||||
import { __ } from 'utils/helper';
|
||||
|
||||
const minimumTags = 2;
|
||||
|
||||
export default class ModalTagSelector extends React.PureComponent {
|
||||
handleAddTag = tag => {
|
||||
if (!tag) {
|
||||
@@ -23,6 +25,9 @@ export default class ModalTagSelector extends React.PureComponent {
|
||||
}
|
||||
|
||||
this.props.doToggleTagFollow(tag);
|
||||
if (window.persistor) {
|
||||
window.persistor.flush();
|
||||
}
|
||||
NativeModules.Firebase.track('tag_follow', { tag });
|
||||
};
|
||||
|
||||
@@ -31,7 +36,16 @@ export default class ModalTagSelector extends React.PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const { followedTags, doToast } = this.props;
|
||||
if (followedTags.length <= minimumTags) {
|
||||
doToast({ message: __(`You can follow a minimum of ${minimumTags} tags.`) });
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.doToggleTagFollow(tag);
|
||||
if (window.persistor) {
|
||||
window.persistor.flush();
|
||||
}
|
||||
NativeModules.Firebase.track('tag_unfollow', { tag });
|
||||
};
|
||||
|
||||
@@ -41,7 +55,7 @@ export default class ModalTagSelector extends React.PureComponent {
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={modalTagSelectorStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
|
||||
<View style={modalTagSelectorStyle.container}>
|
||||
<TouchableOpacity style={modalTagSelectorStyle.container} activeOpacity={1}>
|
||||
<View style={modalTagSelectorStyle.titleRow}>
|
||||
<Text style={modalTagSelectorStyle.title}>Customize your tags</Text>
|
||||
</View>
|
||||
@@ -61,7 +75,7 @@ export default class ModalTagSelector extends React.PureComponent {
|
||||
<View style={modalTagSelectorStyle.buttons}>
|
||||
<Button style={modalTagSelectorStyle.doneButton} text={'Done'} onPress={onDonePress} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import discoverStyle from '../../styles/discover';
|
||||
class NsfwOverlay extends React.PureComponent {
|
||||
render() {
|
||||
return (
|
||||
<TouchableOpacity style={discoverStyle.overlay} activeOpacity={0.95} onPress={this.props.onPress}>
|
||||
<TouchableOpacity style={discoverStyle.overlay} activeOpacity={1} onPress={this.props.onPress}>
|
||||
<Text style={discoverStyle.overlayText}>
|
||||
This content is Not Safe For Work. To view adult content, please change your Settings.
|
||||
</Text>
|
||||
|
||||
@@ -4,7 +4,7 @@ import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import publishStyle from 'styles/publish';
|
||||
|
||||
class PublishRewadsDriver extends React.PureComponent<Props> {
|
||||
class PublishRewardsDriver extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
@@ -17,4 +17,4 @@ class PublishRewadsDriver extends React.PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default PublishRewadsDriver;
|
||||
export default PublishRewardsDriver;
|
||||
@@ -1,11 +1,11 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
doSearch,
|
||||
makeSelectRecommendedContentForUri,
|
||||
makeSelectTitleForUri,
|
||||
selectIsSearching,
|
||||
} from 'lbry-redux';
|
||||
import { doNativeSearch } from 'redux/actions/performance';
|
||||
import RelatedContent from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -16,7 +16,7 @@ const select = (state, props) => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: query => dispatch(doSearch(query, 20, undefined, true)),
|
||||
search: query => dispatch(doNativeSearch(query, 20, undefined, true)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import relatedContentStyle from 'styles/relatedContent';
|
||||
|
||||
export default class RelatedContent extends React.PureComponent<Props> {
|
||||
export default class RelatedContent extends React.PureComponent {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -17,7 +18,7 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
this.getRecommendedContent();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
componentDidUpdate(prevProps) {
|
||||
const { claim, uri } = this.props;
|
||||
|
||||
if (uri !== prevProps.uri) {
|
||||
@@ -38,10 +39,10 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
didSearch: ?boolean;
|
||||
didSearch;
|
||||
|
||||
render() {
|
||||
const { recommendedContent, isSearching, navigation } = this.props;
|
||||
const { recommendedContent, isSearching, navigation, uri, fullUri } = this.props;
|
||||
|
||||
if (!isSearching && (!recommendedContent || recommendedContent.length === 0)) {
|
||||
return null;
|
||||
@@ -51,16 +52,20 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
<View style={relatedContentStyle.container}>
|
||||
<Text style={relatedContentStyle.title}>Related Content</Text>
|
||||
{recommendedContent &&
|
||||
recommendedContent.map(recommendedUri => (
|
||||
<FileListItem
|
||||
style={fileListStyle.item}
|
||||
key={recommendedUri}
|
||||
uri={recommendedUri}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, recommendedUri, { autoplay: true })}
|
||||
/>
|
||||
))}
|
||||
{isSearching && <ActivityIndicator size="small" color={Colors.LbryGreen} style={relatedContentStyle.loading} />}
|
||||
recommendedContent
|
||||
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
|
||||
.map(recommendedUri => (
|
||||
<FileListItem
|
||||
style={fileListStyle.item}
|
||||
key={recommendedUri}
|
||||
uri={recommendedUri}
|
||||
navigation={navigation}
|
||||
autoplay
|
||||
/>
|
||||
))}
|
||||
{isSearching && (
|
||||
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={relatedContentStyle.loading} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ type Props = {
|
||||
id: string,
|
||||
reward_title: string,
|
||||
reward_amount: number,
|
||||
reward_range?: string,
|
||||
transaction_id: string,
|
||||
created_at: string,
|
||||
reward_description: string,
|
||||
@@ -55,6 +56,21 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
});
|
||||
};
|
||||
|
||||
getDisplayAmount = () => {
|
||||
const { reward } = this.props;
|
||||
if (reward) {
|
||||
const claimed = !!reward.transaction_id;
|
||||
if (!claimed && reward.reward_range && reward.reward_range.includes('-')) {
|
||||
return reward.reward_range.split('-')[0] + '+'; // ex: 5+
|
||||
} else if (reward.reward_amount > 0) {
|
||||
return reward.reward_amount;
|
||||
}
|
||||
}
|
||||
|
||||
// unknown amount which normally shouldn't happen
|
||||
return '?';
|
||||
};
|
||||
|
||||
render() {
|
||||
const { canClaim, isPending, onClaimPress, reward } = this.props;
|
||||
const claimed = !!reward.transaction_id;
|
||||
@@ -86,7 +102,7 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{isPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
{isPending && <ActivityIndicator size="small" color={Colors.NextLbryGreen} />}
|
||||
</View>
|
||||
<View style={rewardStyle.midCol}>
|
||||
<Text style={rewardStyle.rewardTitle}>{reward.reward_title}</Text>
|
||||
@@ -101,7 +117,7 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
)}
|
||||
</View>
|
||||
<View style={rewardStyle.rightCol}>
|
||||
<Text style={rewardStyle.rewardAmount}>{reward.reward_amount}</Text>
|
||||
<Text style={rewardStyle.rewardAmount}>{this.getDisplayAmount()}</Text>
|
||||
<Text style={rewardStyle.rewardCurrency}>LBC</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -65,7 +65,8 @@ class StorageStatsCard extends React.PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.totalBytes == 0) {
|
||||
const { fileInfos } = this.props;
|
||||
if (fileInfos.length === 0 || this.state.totalBytes === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class SubscribeButton extends React.PureComponent {
|
||||
|
||||
const iconColor = isSubscribed ? null : Colors.Red;
|
||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||
const subscriptionLabel = isSubscribed ? null : __('Subscribe');
|
||||
const subscriptionLabel = isSubscribed ? null : __('Follow');
|
||||
const { claimName } = parseURI(uri);
|
||||
|
||||
return (
|
||||
@@ -28,7 +28,7 @@ class SubscribeButton extends React.PureComponent {
|
||||
theme={'light'}
|
||||
icon={isSubscribed ? 'heart-broken' : 'heart'}
|
||||
iconColor={iconColor}
|
||||
solid={isSubscribed ? false : true}
|
||||
solid={!isSubscribed}
|
||||
text={hideText ? null : subscriptionLabel}
|
||||
onPress={() => {
|
||||
subscriptionHandler({
|
||||
|
||||
@@ -5,17 +5,27 @@ import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
|
||||
class SubscribeNotificationButton extends React.PureComponent {
|
||||
render() {
|
||||
handlePress = () => {
|
||||
const {
|
||||
uri,
|
||||
name,
|
||||
doChannelSubscriptionEnableNotifications,
|
||||
doChannelSubscriptionDisableNotifications,
|
||||
doToast,
|
||||
enabledChannelNotifications,
|
||||
isSubscribed,
|
||||
style,
|
||||
} = this.props;
|
||||
const shouldNotify = enabledChannelNotifications.indexOf(name) > -1;
|
||||
|
||||
if (shouldNotify) {
|
||||
doChannelSubscriptionDisableNotifications(name);
|
||||
doToast({ message: 'You will not receive notifications for new content.' });
|
||||
} else {
|
||||
doChannelSubscriptionEnableNotifications(name);
|
||||
doToast({ message: 'You will receive all notifications for new content.' });
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { enabledChannelNotifications, name, uri, isSubscribed, style } = this.props;
|
||||
|
||||
if (!isSubscribed) {
|
||||
return null;
|
||||
@@ -31,23 +41,14 @@ class SubscribeNotificationButton extends React.PureComponent {
|
||||
}
|
||||
|
||||
const shouldNotify = enabledChannelNotifications.indexOf(name) > -1;
|
||||
const { claimName } = parseURI(uri);
|
||||
|
||||
return (
|
||||
<Button
|
||||
style={styles}
|
||||
theme={'light'}
|
||||
icon={shouldNotify ? 'bell-slash' : 'bell'}
|
||||
solid={true}
|
||||
onPress={() => {
|
||||
if (shouldNotify) {
|
||||
doChannelSubscriptionDisableNotifications(name);
|
||||
doToast({ message: 'You will not receive notifications for new content.' });
|
||||
} else {
|
||||
doChannelSubscriptionEnableNotifications(name);
|
||||
doToast({ message: 'You will receive all notifications for new content.' });
|
||||
}
|
||||
}}
|
||||
solid
|
||||
onPress={this.handlePress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import React from 'react';
|
||||
import { buildURI, normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, FlatList, Image, Text, View } from 'react-native';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FileItem from 'component/fileItem';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import Link from 'component/link';
|
||||
import Tag from 'component/tag';
|
||||
|
||||
class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
@@ -18,9 +20,12 @@ class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const { claim, isResolvingUri, navigation, thumbnail, title, uri } = this.props;
|
||||
let tags;
|
||||
if (claim && claim.value) {
|
||||
tags = claim.value.tags;
|
||||
let shortUrl, tags;
|
||||
if (claim) {
|
||||
shortUrl = claim.short_url;
|
||||
if (claim.value) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
}
|
||||
|
||||
if (isResolvingUri) {
|
||||
@@ -42,24 +47,29 @@ class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
</View>
|
||||
|
||||
<View style={subscriptionsStyle.suggestedItemDetails}>
|
||||
<View style={subscriptionsStyle.suggestedItemInfo}>
|
||||
{title && (
|
||||
<Text style={subscriptionsStyle.suggestedItemTitle} numberOfLines={1}>
|
||||
{title}
|
||||
</Text>
|
||||
)}
|
||||
<Text style={subscriptionsStyle.suggestedItemName} numberOfLines={1}>
|
||||
{claim && claim.name}
|
||||
{title && (
|
||||
<Text style={subscriptionsStyle.suggestedItemTitle} numberOfLines={1}>
|
||||
{title}
|
||||
</Text>
|
||||
{tags && (
|
||||
<View style={subscriptionsStyle.suggestedItemTagList}>
|
||||
{tags &&
|
||||
tags
|
||||
.slice(0, 3)
|
||||
.map(tag => <Tag style={subscriptionsStyle.tag} key={tag} name={tag} navigation={navigation} />)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{claim && (
|
||||
<Link
|
||||
style={subscriptionsStyle.suggestedItemName}
|
||||
numberOfLines={1}
|
||||
text={claim.name}
|
||||
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri))}
|
||||
/>
|
||||
)}
|
||||
{tags && (
|
||||
<View style={subscriptionsStyle.suggestedItemTagList}>
|
||||
{tags &&
|
||||
tags
|
||||
.slice(0, 3)
|
||||
.map(tag => (
|
||||
<Tag style={subscriptionsStyle.tag} key={tag} name={tag} navigation={navigation} truncate />
|
||||
))}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<SubscribeButton style={subscriptionsStyle.suggestedItemSubscribe} uri={normalizeURI(uri)} />
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doClaimSearch, selectFetchingClaimSearch, selectLastClaimSearchUris, selectFollowedTags } from 'lbry-redux';
|
||||
import { doClaimSearch, selectFetchingClaimSearch, selectClaimSearchByQuery, selectFollowedTags } from 'lbry-redux';
|
||||
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'lbryinc';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import SuggestedSubscriptions from './view';
|
||||
|
||||
const select = state => ({
|
||||
followedTags: selectFollowedTags(state),
|
||||
suggested: selectSuggestedChannels(state),
|
||||
loading: selectIsFetchingSuggested(state) || selectFetchingClaimSearch(state),
|
||||
claimSearchUris: selectLastClaimSearchUris(state),
|
||||
claimSearchByQuery: selectClaimSearchByQuery(state),
|
||||
showNsfwContent: selectShowNsfw(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
claimSearch: options => dispatch(doClaimSearch(10, options)),
|
||||
claimSearch: options => dispatch(doClaimSearch(options)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, FlatList, SectionList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
|
||||
import { MATURE_TAGS, createNormalizedClaimSearchKey, normalizeURI } from 'lbry-redux';
|
||||
import { __, navigateToUri } from 'utils/helper';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
|
||||
@@ -11,47 +11,60 @@ import Link from 'component/link';
|
||||
import _ from 'lodash';
|
||||
|
||||
class SuggestedSubscriptions extends React.PureComponent {
|
||||
state = {
|
||||
options: {},
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { claimSearch, followedTags } = this.props;
|
||||
const { claimSearch, followedTags, showNsfwContent } = this.props;
|
||||
const options = {
|
||||
any_tags: _.shuffle(followedTags.map(tag => tag.name)).slice(0, 2),
|
||||
any_tags: _.shuffle(followedTags.map(tag => tag.name)).slice(0, 3),
|
||||
page: 1,
|
||||
no_totals: true,
|
||||
claim_type: 'channel',
|
||||
};
|
||||
if (!showNsfwContent) {
|
||||
options.not_tags = MATURE_TAGS;
|
||||
}
|
||||
this.setState({ options });
|
||||
claimSearch(options);
|
||||
}
|
||||
|
||||
buildSections = () => {
|
||||
const { suggested, claimSearchUris } = this.props;
|
||||
const { suggested, claimSearchByQuery } = this.props;
|
||||
const claimSearchKey = createNormalizedClaimSearchKey(this.state.options);
|
||||
const claimSearchUris = claimSearchByQuery[claimSearchKey];
|
||||
|
||||
const suggestedUris = suggested ? suggested.map(suggested => suggested.uri) : [];
|
||||
return [
|
||||
{
|
||||
title: __('You might like'),
|
||||
data: suggestedUris,
|
||||
title: __('Suggested channels'),
|
||||
data: claimSearchUris ? claimSearchUris.filter(uri => !suggestedUris.includes(uri)) : [],
|
||||
},
|
||||
{
|
||||
title: __('Tags you follow'),
|
||||
data: claimSearchUris ? claimSearchUris.filter(uri => !suggestedUris.includes(uri)) : [],
|
||||
title: __('You might also like'),
|
||||
data: _.shuffle(suggestedUris),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
render() {
|
||||
const { suggested, loading, navigation } = this.props;
|
||||
const { suggested, inModal, loading, navigation } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.centered}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<SectionList
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.suggestedScrollPadding}
|
||||
style={inModal ? subscriptionsStyle.modalScrollContainer : subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={
|
||||
inModal ? subscriptionsStyle.modalSuggestedScrollContent : subscriptionsStyle.suggestedScrollContent
|
||||
}
|
||||
renderItem={({ item, index, section }) => (
|
||||
<SuggestedSubscriptionItem key={item} uri={normalizeURI(item)} navigation={navigation} />
|
||||
)}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
import { MATURE_TAGS } from 'lbry-redux';
|
||||
import { formatTagName } from 'utils/helper';
|
||||
import tagStyle from 'styles/tag';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
||||
export default class Tag extends React.PureComponent {
|
||||
onPressDefault = () => {
|
||||
const { name, navigation, type, onAddPress, onRemovePress } = this.props;
|
||||
if ('add' === type) {
|
||||
if (type === 'add') {
|
||||
if (onAddPress) {
|
||||
onAddPress(name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ('remove' === type) {
|
||||
if (type === 'remove') {
|
||||
if (onRemovePress) {
|
||||
onRemovePress(name);
|
||||
}
|
||||
@@ -28,7 +30,7 @@ export default class Tag extends React.PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { name, onPress, style, type } = this.props;
|
||||
const { name, onPress, style, type, truncate } = this.props;
|
||||
|
||||
let styles = [];
|
||||
if (style) {
|
||||
@@ -40,7 +42,7 @@ export default class Tag extends React.PureComponent {
|
||||
}
|
||||
|
||||
styles.push({
|
||||
backgroundColor: Colors.TagGreen,
|
||||
backgroundColor: MATURE_TAGS.includes(name) ? Colors.TagGrape : Colors.TagGreen,
|
||||
borderRadius: 8,
|
||||
marginBottom: 4,
|
||||
});
|
||||
@@ -48,7 +50,7 @@ export default class Tag extends React.PureComponent {
|
||||
return (
|
||||
<TouchableOpacity style={styles} onPress={onPress || this.onPressDefault}>
|
||||
<View style={tagStyle.content}>
|
||||
<Text style={tagStyle.text}>{name}</Text>
|
||||
<Text style={tagStyle.text}>{truncate ? formatTagName(name) : name}</Text>
|
||||
{type && <Icon style={tagStyle.icon} name={type === 'add' ? 'plus' : 'times'} size={8} />}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { KeyboardAvoidingView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { MATURE_TAGS } from 'lbry-redux';
|
||||
import Tag from 'component/tag';
|
||||
import tagStyle from 'styles/tag';
|
||||
import Colors from 'styles/colors';
|
||||
@@ -66,11 +67,12 @@ export default class TagSearch extends React.PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { name, style, type, selectedTags = [] } = this.props;
|
||||
const { editable, name, style, type, selectedTags = [], showNsfwTags } = this.props;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<TextInput
|
||||
editable={editable}
|
||||
style={tagStyle.searchInput}
|
||||
placeholder={'Search for more tags'}
|
||||
underlineColorAndroid={Colors.NextLbryGreen}
|
||||
@@ -85,6 +87,22 @@ export default class TagSearch extends React.PureComponent {
|
||||
))}
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
{showNsfwTags && (
|
||||
<View style={tagStyle.nsfwTagsContainer}>
|
||||
<Text style={tagStyle.nsfwTagsTitle}>Mature tags</Text>
|
||||
<View style={tagStyle.tagResultsList}>
|
||||
{MATURE_TAGS.map(tag => (
|
||||
<Tag
|
||||
key={tag}
|
||||
name={tag}
|
||||
style={tagStyle.tag}
|
||||
type="add"
|
||||
onAddPress={name => this.onAddTagPress(name)}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@ class TransactionListItem extends React.PureComponent {
|
||||
return (
|
||||
<View style={transactionListStyle.listItem}>
|
||||
<View style={[transactionListStyle.row, transactionListStyle.topRow]}>
|
||||
<View style={transactionListStyle.col}>
|
||||
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
|
||||
<Text style={transactionListStyle.text}>{this.capitalize(type)}</Text>
|
||||
{name && claimId && (
|
||||
<Link
|
||||
style={transactionListStyle.link}
|
||||
numberOfLines={1}
|
||||
onPress={() => navigateToUri(navigation, buildURI({ claimName: name, claimId }))}
|
||||
text={name}
|
||||
/>
|
||||
@@ -37,7 +38,7 @@ class TransactionListItem extends React.PureComponent {
|
||||
</View>
|
||||
</View>
|
||||
<View style={transactionListStyle.row}>
|
||||
<View style={transactionListStyle.col}>
|
||||
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
|
||||
<Link
|
||||
style={transactionListStyle.smallLink}
|
||||
text={txid.substring(0, 8)}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
//import BusyIndicator from 'component/common/busy-indicator';
|
||||
// import BusyIndicator from 'component/common/busy-indicator';
|
||||
import { Text, View } from 'react-native';
|
||||
import Button from '../button';
|
||||
import Link from '../link';
|
||||
@@ -33,7 +33,7 @@ class TransactionListRecent extends React.PureComponent<Props> {
|
||||
{!fetchingTransactions && (
|
||||
<TransactionList
|
||||
navigation={navigation}
|
||||
transactions={transactions}
|
||||
transactions={transactions.slice(0, 5)}
|
||||
emptyMessage={"Looks like you don't have any recent transactions."}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -4,8 +4,10 @@ import {
|
||||
selectSearchState as selectSearch,
|
||||
selectSearchValue,
|
||||
selectSearchSuggestions,
|
||||
SETTINGS,
|
||||
} from 'lbry-redux';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import UriBar from './view';
|
||||
|
||||
const select = state => {
|
||||
@@ -16,6 +18,7 @@ const select = state => {
|
||||
query: selectSearchValue(state),
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
suggestions: selectSearchSuggestions(state),
|
||||
showUriBarSuggestions: makeSelectClientSetting(SETTINGS.SHOW_URI_BAR_SUGGESTIONS)(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ class UriBarItem extends React.PureComponent {
|
||||
icon = <Icon name="search" size={18} />;
|
||||
break;
|
||||
|
||||
case SEARCH_TYPES.TAG:
|
||||
icon = <Icon name="hashtag" size={18} />;
|
||||
break;
|
||||
|
||||
case SEARCH_TYPES.FILE:
|
||||
default:
|
||||
icon = <Icon name="file" size={18} />;
|
||||
@@ -37,6 +41,7 @@ class UriBarItem extends React.PureComponent {
|
||||
{type === SEARCH_TYPES.SEARCH && `Search for '${value}'`}
|
||||
{type === SEARCH_TYPES.CHANNEL && `View the @${shorthand} channel`}
|
||||
{type === SEARCH_TYPES.FILE && `View content at ${value}`}
|
||||
{type === SEARCH_TYPES.TAG && `Explore the '${value}' tag`}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
+180
-87
@@ -1,12 +1,12 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
|
||||
import { FlatList, Keyboard, TextInput, View } from 'react-native';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Constants from 'constants';
|
||||
import { Dimensions, FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { navigateToUri, transformUrl } from 'utils/helper';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import UriBarItem from './internal/uri-bar-item';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import uriBarStyle from 'styles/uriBar';
|
||||
|
||||
class UriBar extends React.PureComponent {
|
||||
@@ -14,14 +14,28 @@ class UriBar extends React.PureComponent {
|
||||
|
||||
textInput = null;
|
||||
|
||||
keyboardDidShowListener = null;
|
||||
|
||||
keyboardDidHideListener = null;
|
||||
|
||||
state = {
|
||||
changeTextTimeout: null,
|
||||
currentValue: null,
|
||||
inputText: null,
|
||||
focused: false,
|
||||
keyboardHeight: 0,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
|
||||
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
|
||||
this.setSelection();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.keyboardDidShowListener) {
|
||||
this.keyboardDidShowListener.remove();
|
||||
}
|
||||
if (this.keyboardDidHideListener) {
|
||||
this.keyboardDidHideListener.remove();
|
||||
}
|
||||
@@ -36,40 +50,31 @@ class UriBar extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
changeTextTimeout: null,
|
||||
currentValue: null,
|
||||
inputText: null,
|
||||
focused: false,
|
||||
// TODO: Add a setting to enable / disable direct search?
|
||||
directSearch: true,
|
||||
};
|
||||
}
|
||||
|
||||
handleChangeText = text => {
|
||||
const newValue = text ? text : '';
|
||||
const newValue = text || '';
|
||||
clearTimeout(this.state.changeTextTimeout);
|
||||
const { updateSearchQuery, onSearchSubmitted, navigation } = this.props;
|
||||
const { updateSearchQuery, onSearchSubmitted, showUriBarSuggestions, navigation } = this.props;
|
||||
|
||||
let timeout = setTimeout(() => {
|
||||
if (text.trim().length === 0) {
|
||||
// don't do anything if the text is empty
|
||||
return;
|
||||
}
|
||||
updateSearchQuery(text);
|
||||
|
||||
updateSearchQuery(text);
|
||||
|
||||
if (!text.startsWith('lbry://')) {
|
||||
// not a URI input, so this is a search, perform a direct search
|
||||
if (onSearchSubmitted) {
|
||||
onSearchSubmitted(text);
|
||||
} else {
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: text } });
|
||||
let timeout = -1;
|
||||
if (!showUriBarSuggestions) {
|
||||
timeout = setTimeout(() => {
|
||||
if (text.trim().length === 0) {
|
||||
// don't do anything if the text is empty
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, UriBar.INPUT_TIMEOUT);
|
||||
|
||||
if (!text.startsWith('lbry://')) {
|
||||
// not a URI input, so this is a search, perform a direct search
|
||||
if (onSearchSubmitted) {
|
||||
onSearchSubmitted(text);
|
||||
} else {
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: text } });
|
||||
}
|
||||
}
|
||||
}, UriBar.INPUT_TIMEOUT);
|
||||
}
|
||||
this.setState({ inputText: newValue, currentValue: newValue, changeTextTimeout: timeout });
|
||||
};
|
||||
|
||||
@@ -88,18 +93,34 @@ class UriBar extends React.PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: value } });
|
||||
navigation.navigate({
|
||||
routeName: Constants.DRAWER_ROUTE_SEARCH,
|
||||
key: 'searchPage',
|
||||
params: { searchQuery: value },
|
||||
});
|
||||
} else if (SEARCH_TYPES.TAG === type) {
|
||||
navigation.navigate({
|
||||
routeName: Constants.DRAWER_ROUTE_TAG,
|
||||
key: 'tagPage',
|
||||
params: {
|
||||
tag: value.toLowerCase(),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const uri = normalizeURI(value);
|
||||
navigateToUri(navigation, uri);
|
||||
}
|
||||
};
|
||||
|
||||
_keyboardDidShow = evt => {
|
||||
this.setState({ keyboardHeight: evt.endCoordinates.height });
|
||||
};
|
||||
|
||||
_keyboardDidHide = () => {
|
||||
if (this.textInput) {
|
||||
this.textInput.blur();
|
||||
}
|
||||
this.setState({ focused: false });
|
||||
this.setState({ focused: false, keyboardHeight: 0 });
|
||||
};
|
||||
|
||||
setSelection() {
|
||||
@@ -111,12 +132,19 @@ class UriBar extends React.PureComponent {
|
||||
handleSubmitEditing = () => {
|
||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
||||
if (this.state.inputText) {
|
||||
let inputText = this.state.inputText;
|
||||
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
|
||||
let inputText = this.state.inputText,
|
||||
inputTextIsUrl = false;
|
||||
if (inputText.startsWith('lbry://')) {
|
||||
const transformedUrl = transformUrl(inputText);
|
||||
// if it's a URI (lbry://...), open the file page
|
||||
const uri = normalizeURI(inputText);
|
||||
navigateToUri(navigation, uri);
|
||||
} else {
|
||||
if (transformedUrl && isURIValid(transformedUrl)) {
|
||||
inputTextIsUrl = true;
|
||||
navigateToUri(navigation, transformedUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// couldn't parse the inputText as a URL for some reason, so do a search instead
|
||||
if (!inputTextIsUrl) {
|
||||
updateSearchQuery(inputText);
|
||||
// Not a URI, default to a search request
|
||||
if (onSearchSubmitted) {
|
||||
@@ -136,65 +164,130 @@ class UriBar extends React.PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigation, suggestions, query, value, belowOverlay } = this.props;
|
||||
const {
|
||||
allowEdit,
|
||||
belowOverlay,
|
||||
navigation,
|
||||
onExitSelectionMode,
|
||||
onEditActionPressed,
|
||||
onDeleteActionPressed,
|
||||
query,
|
||||
selectedItemCount,
|
||||
selectionMode,
|
||||
suggestions,
|
||||
showUriBarSuggestions,
|
||||
value,
|
||||
} = this.props;
|
||||
if (this.state.currentValue === null) {
|
||||
this.setState({ currentValue: value });
|
||||
}
|
||||
|
||||
let style = [uriBarStyle.overlay, belowOverlay ? null : uriBarStyle.overlayElevated];
|
||||
|
||||
// TODO: Add optional setting to enable URI / search bar suggestions
|
||||
/*if (this.state.focused) { style.push(uriBarStyle.inFocus); }*/
|
||||
let style = [
|
||||
uriBarStyle.overlay,
|
||||
belowOverlay ? null : uriBarStyle.overlayElevated,
|
||||
this.state.focused && showUriBarSuggestions ? uriBarStyle.inFocus : null,
|
||||
];
|
||||
|
||||
// TODO: selectionModeActions should be dynamically created / specified
|
||||
return (
|
||||
<View style={style}>
|
||||
<View style={[uriBarStyle.uriContainer, belowOverlay ? null : uriBarStyle.containerElevated]}>
|
||||
<NavigationButton
|
||||
name="bars"
|
||||
size={24}
|
||||
style={uriBarStyle.drawerMenuButton}
|
||||
iconStyle={discoverStyle.drawerHamburger}
|
||||
onPress={() => navigation.openDrawer()}
|
||||
/>
|
||||
<TextInput
|
||||
ref={ref => {
|
||||
this.textInput = ref;
|
||||
}}
|
||||
style={uriBarStyle.uriText}
|
||||
onLayout={() => {
|
||||
this.setSelection();
|
||||
}}
|
||||
selectTextOnFocus={true}
|
||||
placeholder={'Search movies, music, and more'}
|
||||
underlineColorAndroid={'transparent'}
|
||||
numberOfLines={1}
|
||||
clearButtonMode={'while-editing'}
|
||||
value={this.state.currentValue}
|
||||
returnKeyType={'go'}
|
||||
inlineImageLeft={'baseline_search_black_24'}
|
||||
inlineImagePadding={16}
|
||||
onFocus={() => this.setState({ focused: true })}
|
||||
onBlur={() => {
|
||||
this.setState({ focused: false });
|
||||
this.setSelection();
|
||||
}}
|
||||
onChangeText={this.handleChangeText}
|
||||
onSubmitEditing={this.handleSubmitEditing}
|
||||
/>
|
||||
{this.state.focused && !this.state.directSearch && (
|
||||
<View style={uriBarStyle.suggestions}>
|
||||
<FlatList
|
||||
style={uriBarStyle.suggestionList}
|
||||
data={suggestions}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
keyExtractor={(item, value) => item.value}
|
||||
renderItem={({ item }) => (
|
||||
<UriBarItem item={item} navigation={navigation} onPress={() => this.handleItemPress(item)} />
|
||||
{selectionMode && (
|
||||
<View style={uriBarStyle.selectionModeBar}>
|
||||
<View style={uriBarStyle.selectionModeLeftBar}>
|
||||
<TouchableOpacity
|
||||
style={uriBarStyle.backTouchArea}
|
||||
onPress={() => {
|
||||
if (onExitSelectionMode) {
|
||||
onExitSelectionMode();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name="arrow-left" size={20} />
|
||||
</TouchableOpacity>
|
||||
{selectedItemCount > 0 && <Text style={uriBarStyle.itemCount}>{selectedItemCount}</Text>}
|
||||
</View>
|
||||
|
||||
<View style={uriBarStyle.selectionModeActions}>
|
||||
{allowEdit && selectedItemCount === 1 && (
|
||||
<TouchableOpacity
|
||||
style={[uriBarStyle.actionTouchArea, uriBarStyle.leftAction]}
|
||||
onPress={() => {
|
||||
if (onEditActionPressed) {
|
||||
onEditActionPressed();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name="edit" size={20} style={uriBarStyle.actionIcon} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
/>
|
||||
|
||||
<TouchableOpacity
|
||||
style={uriBarStyle.actionTouchArea}
|
||||
onPress={() => {
|
||||
if (onDeleteActionPressed) {
|
||||
onDeleteActionPressed();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name="trash-alt" solid={false} size={20} style={uriBarStyle.actionIcon} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!selectionMode && (
|
||||
<NavigationButton
|
||||
name="bars"
|
||||
size={24}
|
||||
style={uriBarStyle.drawerMenuButton}
|
||||
iconStyle={uriBarStyle.drawerHamburger}
|
||||
onPress={() => navigation.openDrawer()}
|
||||
/>
|
||||
)}
|
||||
{!selectionMode && (
|
||||
<TextInput
|
||||
ref={ref => {
|
||||
this.textInput = ref;
|
||||
}}
|
||||
autoCorrect={false}
|
||||
style={uriBarStyle.uriText}
|
||||
onLayout={() => {
|
||||
this.setSelection();
|
||||
}}
|
||||
selectTextOnFocus
|
||||
placeholder={'Search movies, music, and more'}
|
||||
underlineColorAndroid={'transparent'}
|
||||
numberOfLines={1}
|
||||
clearButtonMode={'while-editing'}
|
||||
value={this.state.currentValue}
|
||||
returnKeyType={'go'}
|
||||
inlineImageLeft={'baseline_search_black_24'}
|
||||
inlineImagePadding={16}
|
||||
onFocus={() => this.setState({ focused: true })}
|
||||
onBlur={() => {
|
||||
this.setState({ focused: false });
|
||||
this.setSelection();
|
||||
}}
|
||||
onChangeText={this.handleChangeText}
|
||||
onSubmitEditing={this.handleSubmitEditing}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{this.state.focused && showUriBarSuggestions && (
|
||||
<FlatList
|
||||
style={[
|
||||
uriBarStyle.suggestions,
|
||||
{ height: Dimensions.get('window').height - this.state.keyboardHeight - 60 },
|
||||
]}
|
||||
data={suggestions}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
keyExtractor={(item, value) => `${item.value}-${item.type}`}
|
||||
renderItem={({ item }) => (
|
||||
<UriBarItem item={item} navigation={navigation} onPress={() => this.handleItemPress(item)} />
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import VideoDuration from './view';
|
||||
|
||||
export default connect()(VideoDuration);
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default class VideoDuration extends React.PureComponent {
|
||||
getDurationString = duration => {
|
||||
let seconds = duration;
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
seconds = duration - hours * 3600;
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
|
||||
let durationString = '';
|
||||
if (hours > 0) {
|
||||
durationString += hours + ':';
|
||||
}
|
||||
durationString += _.padStart(minutes, hours > 0 ? 2 : 0, '0') + ':';
|
||||
durationString += _.padStart(seconds, 2, '0');
|
||||
|
||||
return durationString;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { duration, style, textStyle } = this.props;
|
||||
if (!duration || isNaN(parseFloat(duration))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<Text style={textStyle}>{this.getDurationString(duration)}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
+22
-5
@@ -25,11 +25,14 @@ const Constants = {
|
||||
PHASE_DETAILS: 'details',
|
||||
PHASE_PUBLISH: 'publish',
|
||||
|
||||
PHASE_LIST: 'list',
|
||||
PHASE_NEW: 'create',
|
||||
|
||||
CONTENT_TAB: 'content',
|
||||
ABOUT_TAB: 'about',
|
||||
|
||||
KEY_FIRST_RUN_EMAIL: 'firstRunEmail',
|
||||
KEY_FIRST_RUN_PASSWORD: 'firstRunPassword',
|
||||
KEY_WALLET_PASSWORD: 'firstRunPassword',
|
||||
KEY_FIRST_USER_AUTH: 'firstUserAuth',
|
||||
KEY_SHOULD_VERIFY_EMAIL: 'shouldVerifyEmail',
|
||||
KEY_EMAIL_VERIFY_PENDING: 'emailVerifyPending',
|
||||
@@ -53,6 +56,14 @@ const Constants = {
|
||||
ACTION_REACT_NAVIGATION_NAVIGATE: 'Navigation/NAVIGATE',
|
||||
ACTION_REACT_NAVIGATION_REPLACE: 'Navigation/REPLACE',
|
||||
|
||||
ACTION_SORT_BY_ITEM_CHANGED: 'SORT_BY_ITEM_CHANGED',
|
||||
ACTION_TIME_ITEM_CHANGED: 'TIME_ITEM_CHANGED',
|
||||
|
||||
ACTION_UPDATE_PUBLISH_FORM_STATE: 'UPDATE_PUBLISH_FORM_STATE',
|
||||
ACTION_UPDATE_CHANNEL_FORM_STATE: 'UPDATE_CHANNEL_FORM_STATE',
|
||||
ACTION_CLEAR_PUBLISH_FORM_STATE: 'CLEAR_PUBLISH_FORM_STATE',
|
||||
ACTION_CLEAR_CHANNEL_FORM_STATE: 'CLEAR_CHANNEL_FORM_STATE',
|
||||
|
||||
ORIENTATION_HORIZONTAL: 'horizontal',
|
||||
ORIENTATION_VERTICAL: 'vertical',
|
||||
|
||||
@@ -66,6 +77,7 @@ const Constants = {
|
||||
DRAWER_ROUTE_SUBSCRIPTIONS: 'Subscriptions',
|
||||
DRAWER_ROUTE_MY_LBRY: 'Downloads',
|
||||
DRAWER_ROUTE_PUBLISH: 'Publish',
|
||||
DRAWER_ROUTE_PUBLISH_FORM: 'PublishForm',
|
||||
DRAWER_ROUTE_PUBLISHES: 'Publishes',
|
||||
DRAWER_ROUTE_REWARDS: 'Rewards',
|
||||
DRAWER_ROUTE_WALLET: 'Wallet',
|
||||
@@ -74,12 +86,11 @@ const Constants = {
|
||||
DRAWER_ROUTE_SEARCH: 'Search',
|
||||
DRAWER_ROUTE_TRANSACTION_HISTORY: 'TransactionHistory',
|
||||
DRAWER_ROUTE_TAG: 'Tag',
|
||||
DRAWER_ROUTE_CHANNEL_CREATOR: 'ChannelCreator',
|
||||
DRAWER_ROUTE_CHANNEL_CREATOR_FORM: 'ChannnelCreatorForm',
|
||||
|
||||
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
|
||||
FULL_ROUTE_NAME_TRENDING: 'TrendingStack',
|
||||
FULL_ROUTE_NAME_MY_SUBSCRIPTIONS: 'MySubscriptionsStack',
|
||||
FULL_ROUTE_NAME_WALLET: 'WalletStack',
|
||||
FULL_ROUTE_NAME_MY_LBRY: 'MyLBRYStack',
|
||||
|
||||
ROUTE_FILE: 'File',
|
||||
|
||||
@@ -103,7 +114,7 @@ const Constants = {
|
||||
TIME_ALL,
|
||||
|
||||
CLAIM_SEARCH_SORT_BY_ITEMS: [
|
||||
{ icon: 'fire-alt', name: SORT_BY_HOT, label: 'Hot content' },
|
||||
{ icon: 'fire-alt', name: SORT_BY_HOT, label: 'Trending content' },
|
||||
{ icon: 'certificate', name: SORT_BY_NEW, label: 'New content' },
|
||||
{ icon: 'chart-line', name: SORT_BY_TOP, label: 'Top content' },
|
||||
],
|
||||
@@ -127,6 +138,8 @@ const Constants = {
|
||||
MORE_PLACEHOLDER: '_more',
|
||||
|
||||
TRUE_STRING: 'true',
|
||||
|
||||
MINIMUM_TRANSACTION_BALANCE: 0.1,
|
||||
};
|
||||
|
||||
export default Constants;
|
||||
@@ -146,4 +159,8 @@ export const DrawerRoutes = [
|
||||
Constants.DRAWER_ROUTE_ABOUT,
|
||||
Constants.DRAWER_ROUTE_SEARCH,
|
||||
Constants.DRAWER_ROUTE_TRANSACTION_HISTORY,
|
||||
Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
|
||||
];
|
||||
|
||||
// sub-pages for main routes
|
||||
export const InnerDrawerRoutes = [Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM, Constants.DRAWER_ROUTE_PUBLISH_FORM];
|
||||
+67
-8
@@ -4,6 +4,8 @@ import { Provider, connect } from 'react-redux';
|
||||
import { AppRegistry, Text, View, NativeModules } from 'react-native';
|
||||
import {
|
||||
Lbry,
|
||||
buildSharedStateMiddleware,
|
||||
blockedReducer,
|
||||
claimsReducer,
|
||||
contentReducer,
|
||||
fileReducer,
|
||||
@@ -13,17 +15,24 @@ import {
|
||||
searchReducer,
|
||||
tagsReducer,
|
||||
walletReducer,
|
||||
ACTIONS as LBRY_REDUX_ACTIONS,
|
||||
} from 'lbry-redux';
|
||||
import {
|
||||
Lbryio,
|
||||
authReducer,
|
||||
blacklistReducer,
|
||||
costInfoReducer,
|
||||
doGetSync,
|
||||
filteredReducer,
|
||||
homepageReducer,
|
||||
rewardsReducer,
|
||||
selectUserVerifiedEmail,
|
||||
subscriptionsReducer,
|
||||
syncReducer,
|
||||
userReducer,
|
||||
LBRYINC_ACTIONS,
|
||||
} from 'lbryinc';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import AppWithNavigationState, {
|
||||
AppNavigator,
|
||||
@@ -31,19 +40,19 @@ import AppWithNavigationState, {
|
||||
reactNavigationMiddleware,
|
||||
} from 'component/AppNavigator';
|
||||
import { REHYDRATE, PURGE, persistCombineReducers, persistStore } from 'redux-persist';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import getStoredStateMigrateV4 from 'redux-persist/lib/integration/getStoredStateMigrateV4';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import FilesystemStorage from 'redux-persist-filesystem-storage';
|
||||
import createCompressor from 'redux-persist-transform-compress';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
import moment from 'moment';
|
||||
import formReducer from 'redux/reducers/form';
|
||||
import drawerReducer from 'redux/reducers/drawer';
|
||||
import settingsReducer from 'redux/reducers/settings';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
const globalExceptionHandler = (error, isFatal) => {
|
||||
if (error && NativeModules.Firebase) {
|
||||
console.log(error);
|
||||
NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
|
||||
}
|
||||
};
|
||||
@@ -79,18 +88,27 @@ function enableBatching(reducer) {
|
||||
|
||||
const compressor = createCompressor();
|
||||
const authFilter = createFilter('auth', ['authToken']);
|
||||
const blockedFilter = createFilter('blocked', ['blockedChannels']);
|
||||
const contentFilter = createFilter('content', ['positions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions', 'latest']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
const tagsFilter = createFilter('tags', ['followedTags']);
|
||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||
|
||||
const v4PersistOptions = {
|
||||
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'tags', 'wallet'],
|
||||
whitelist: ['auth', 'blocked', 'claims', 'content', 'subscriptions', 'settings', 'tags', 'wallet'],
|
||||
// Order is important. Needs to be compressed last or other transforms can't
|
||||
// read the data
|
||||
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
||||
transforms: [
|
||||
authFilter,
|
||||
blockedFilter,
|
||||
saveClaimsFilter,
|
||||
subscriptionsFilter,
|
||||
settingsFilter,
|
||||
walletFilter,
|
||||
compressor,
|
||||
],
|
||||
debounce: 10000,
|
||||
storage: FilesystemStorage,
|
||||
};
|
||||
@@ -103,12 +121,15 @@ const persistOptions = Object.assign({}, v4PersistOptions, {
|
||||
const reducers = persistCombineReducers(persistOptions, {
|
||||
auth: authReducer,
|
||||
blacklist: blacklistReducer,
|
||||
blocked: blockedReducer,
|
||||
claims: claimsReducer,
|
||||
content: contentReducer,
|
||||
costInfo: costInfoReducer,
|
||||
drawer: drawerReducer,
|
||||
file: fileReducer,
|
||||
fileInfo: fileInfoReducer,
|
||||
filtered: filteredReducer,
|
||||
form: formReducer,
|
||||
homepage: homepageReducer,
|
||||
nav: navigatorReducer,
|
||||
notifications: notificationsReducer,
|
||||
@@ -123,8 +144,45 @@ const reducers = persistCombineReducers(persistOptions, {
|
||||
wallet: walletReducer,
|
||||
});
|
||||
|
||||
/**
|
||||
* source: the reducer name
|
||||
* property: the property in the reducer-specific state
|
||||
* transform: optional method to modify the value to be stored
|
||||
*/
|
||||
const sharedStateActions = [
|
||||
LBRYINC_ACTIONS.CHANNEL_SUBSCRIBE,
|
||||
LBRYINC_ACTIONS.CHANNEL_UNSUBSCRIBE,
|
||||
LBRY_REDUX_ACTIONS.CREATE_CHANNEL_COMPLETED,
|
||||
LBRY_REDUX_ACTIONS.TOGGLE_TAG_FOLLOW,
|
||||
LBRY_REDUX_ACTIONS.TOGGLE_BLOCK_CHANNEL,
|
||||
];
|
||||
const sharedStateFilters = {
|
||||
tags: { source: 'tags', property: 'followedTags' },
|
||||
subscriptions: {
|
||||
source: 'subscriptions',
|
||||
property: 'subscriptions',
|
||||
transform: function(value) {
|
||||
return value.map(({ uri }) => uri);
|
||||
},
|
||||
},
|
||||
blocked: { source: 'blocked', property: 'blockedChannels' },
|
||||
};
|
||||
|
||||
const sharedStateCallback = ({ dispatch, getState }) => {
|
||||
const state = getState();
|
||||
const syncEnabled = makeSelectClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED)(state);
|
||||
const emailVerified = selectUserVerifiedEmail(state);
|
||||
if (syncEnabled && emailVerified) {
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(password =>
|
||||
dispatch(doGetSync(password))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const sharedStateMiddleware = buildSharedStateMiddleware(sharedStateActions, sharedStateFilters, sharedStateCallback);
|
||||
|
||||
const bulkThunk = createBulkThunkMiddleware();
|
||||
const middleware = [thunk, bulkThunk, reactNavigationMiddleware];
|
||||
const middleware = [sharedStateMiddleware, thunk, bulkThunk, reactNavigationMiddleware];
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
const composeEnhancers = compose;
|
||||
@@ -136,11 +194,12 @@ const store = createStore(
|
||||
);
|
||||
window.store = store;
|
||||
|
||||
persistStore(store, persistOptions, err => {
|
||||
const persistor = persistStore(store, persistOptions, err => {
|
||||
if (err) {
|
||||
console.log('Unable to load saved SETTINGS');
|
||||
}
|
||||
});
|
||||
window.persistor = persistor;
|
||||
|
||||
// TODO: Find i18n module that is compatible with react-native
|
||||
global.__ = str => str;
|
||||
|
||||
+22
-20
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { NativeModules, Text, View, ScrollView } from 'react-native';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Link from 'component/link';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import aboutStyle from 'styles/about';
|
||||
@@ -18,7 +18,7 @@ class AboutPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -44,19 +44,21 @@ class AboutPage extends React.PureComponent {
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
|
||||
if (NativeModules.VersionInfo) {
|
||||
NativeModules.VersionInfo.getAppVersion().then(version => {
|
||||
this.setState({ appVersion: version });
|
||||
NativeModules.Firebase.setCurrentScreen('About').then(result => {
|
||||
if (NativeModules.VersionInfo) {
|
||||
NativeModules.VersionInfo.getAppVersion().then(version => {
|
||||
this.setState({ appVersion: version });
|
||||
});
|
||||
}
|
||||
Lbry.version().then(info => {
|
||||
this.setState({
|
||||
versionInfo: info,
|
||||
});
|
||||
});
|
||||
}
|
||||
Lbry.version().then(info => {
|
||||
this.setState({
|
||||
versionInfo: info,
|
||||
});
|
||||
});
|
||||
Lbry.status().then(info => {
|
||||
this.setState({
|
||||
lbryId: info.installation_id,
|
||||
Lbry.status().then(info => {
|
||||
this.setState({
|
||||
lbryId: info.installation_id,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,7 +107,7 @@ class AboutPage extends React.PureComponent {
|
||||
<Text style={aboutStyle.text}>Connected email</Text>
|
||||
</View>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text selectable={true} style={aboutStyle.valueText}>
|
||||
<Text selectable style={aboutStyle.valueText}>
|
||||
{userEmail}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -125,7 +127,7 @@ class AboutPage extends React.PureComponent {
|
||||
<Text style={aboutStyle.text}>App version</Text>
|
||||
</View>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text selectable={true} style={aboutStyle.valueText}>
|
||||
<Text selectable style={aboutStyle.valueText}>
|
||||
{this.state.appVersion}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -133,10 +135,10 @@ class AboutPage extends React.PureComponent {
|
||||
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text style={aboutStyle.text}>Daemon (lbrynet)</Text>
|
||||
<Text style={aboutStyle.text}>LBRY SDK</Text>
|
||||
</View>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text selectable={true} style={aboutStyle.valueText}>
|
||||
<Text selectable style={aboutStyle.valueText}>
|
||||
{ver ? ver.lbrynet_version : loading}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -147,7 +149,7 @@ class AboutPage extends React.PureComponent {
|
||||
<Text style={aboutStyle.text}>Platform</Text>
|
||||
</View>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text selectable={true} style={aboutStyle.valueText}>
|
||||
<Text selectable style={aboutStyle.valueText}>
|
||||
{ver ? ver.platform : loading}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -156,7 +158,7 @@ class AboutPage extends React.PureComponent {
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}>
|
||||
<Text style={aboutStyle.text}>Installation ID</Text>
|
||||
<Text selectable={true} style={aboutStyle.lineValueText}>
|
||||
<Text selectable style={aboutStyle.lineValueText}>
|
||||
{this.state.lbryId ? this.state.lbryId : loading}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
+10
-11
@@ -1,26 +1,25 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchClaimsByChannel,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimsInChannelForCurrentPageState,
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectTotalPagesForChannel,
|
||||
} from 'lbry-redux';
|
||||
import { doAbandonClaim, doFetchChannelListMine, makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
|
||||
import { doPopDrawerStack } from 'redux/actions/drawer';
|
||||
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
||||
import ChannelPage from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
channels: selectMyChannelClaims(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimsInChannel: makeSelectClaimsInChannelForCurrentPageState(props.uri)(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
|
||||
totalPages: makeSelectTotalPagesForChannel(props.uri, 10)(state), // Update to use a default PAGE_SIZE constant
|
||||
sortByItem: selectSortByItem(state),
|
||||
timeItem: selectTimeItem(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
|
||||
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
+205
-110
@@ -1,111 +1,115 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Dimensions, Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
Dimensions,
|
||||
Image,
|
||||
NativeModules,
|
||||
ScrollView,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { TabView, SceneMap } from 'react-native-tab-view';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { navigateBack, getOrderBy } from 'utils/helper';
|
||||
import ChannelIconItem from 'component/channelIconItem';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Button from 'component/button';
|
||||
import EmptyStateView from 'component/emptyStateView';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import FileList from 'component/fileList';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SubscribeNotificationButton from 'component/subscribeNotificationButton';
|
||||
import UriBar from 'component/uriBar';
|
||||
import channelIconStyle from 'styles/channelIcon';
|
||||
import channelPageStyle from 'styles/channelPage';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
class ChannelPage extends React.PureComponent {
|
||||
state = {
|
||||
page: 1,
|
||||
showPageButtons: false,
|
||||
autoStyle: null,
|
||||
showSortPicker: false,
|
||||
showTimePicker: false,
|
||||
orderBy: Constants.DEFAULT_ORDER_BY,
|
||||
activeTab: Constants.CONTENT_TAB,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { uri, page, claimsInChannel, fetchClaims, fetchClaimCount } = this.props;
|
||||
|
||||
if (!claimsInChannel || !claimsInChannel.length) {
|
||||
fetchClaims(uri, page || this.state.page);
|
||||
}
|
||||
componentWillMount() {
|
||||
this.setState({
|
||||
autoStyle:
|
||||
ChannelIconItem.AUTO_THUMB_STYLES[Math.floor(Math.random() * ChannelIconItem.AUTO_THUMB_STYLES.length)],
|
||||
});
|
||||
}
|
||||
|
||||
handlePreviousPage = () => {
|
||||
const { uri, fetchClaims } = this.props;
|
||||
if (this.state.page > 1) {
|
||||
this.setState({ page: this.state.page - 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
componentDidMount() {
|
||||
const { fetchChannelListMine } = this.props;
|
||||
NativeModules.Firebase.setCurrentScreen('Channel');
|
||||
fetchChannelListMine();
|
||||
}
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
const { setSortByItem } = this.props;
|
||||
setSortByItem(item);
|
||||
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
|
||||
};
|
||||
|
||||
handleNextPage = () => {
|
||||
const { uri, fetchClaims, totalPages } = this.props;
|
||||
if (this.state.page < totalPages) {
|
||||
this.setState({ page: this.state.page + 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
handleTimeItemSelected = item => {
|
||||
const { setTimeItem } = this.props;
|
||||
setTimeItem(item);
|
||||
this.setState({ showTimePicker: false });
|
||||
};
|
||||
|
||||
listHeader = () => {
|
||||
const { sortByItem, timeItem } = this.props;
|
||||
|
||||
return (
|
||||
<View style={channelPageStyle.listHeader}>
|
||||
<View style={discoverStyle.pickerRow}>
|
||||
<View style={discoverStyle.leftPickerRow}>
|
||||
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
{Constants.SORT_BY_TOP === sortByItem.name && (
|
||||
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
renderContent = () => {
|
||||
const { fetching, claimsInChannel, totalPages, navigation } = this.props;
|
||||
const { claim, navigation, timeItem } = this.props;
|
||||
|
||||
let contentList;
|
||||
if (fetching) {
|
||||
contentList = (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<Text style={channelPageStyle.infoText}>Fetching content...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
contentList =
|
||||
claimsInChannel && claimsInChannel.length ? (
|
||||
<FileList
|
||||
sortByHeight
|
||||
hideFilter
|
||||
fileInfos={claimsInChannel}
|
||||
navigation={navigation}
|
||||
style={channelPageStyle.fileList}
|
||||
contentContainerStyle={channelPageStyle.fileListContent}
|
||||
onEndReached={() => this.setState({ showPageButtons: true })}
|
||||
/>
|
||||
) : (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>No content found.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
let pageButtons;
|
||||
if (totalPages > 1 && this.state.showPageButtons) {
|
||||
pageButtons = (
|
||||
<View style={channelPageStyle.pageButtons}>
|
||||
<View>
|
||||
{this.state.page > 1 && (
|
||||
<Button
|
||||
style={channelPageStyle.button}
|
||||
text={'Previous'}
|
||||
disabled={!!fetching}
|
||||
onPress={this.handlePreviousPage}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{this.state.page < totalPages && (
|
||||
<Button
|
||||
style={[channelPageStyle.button, channelPageStyle.nextButton]}
|
||||
text={'Next'}
|
||||
disabled={!!fetching}
|
||||
onPress={this.handleNextPage}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
let channelId;
|
||||
if (claim) {
|
||||
channelId = claim.claim_id;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={channelPageStyle.contentTab}>
|
||||
{contentList}
|
||||
{pageButtons}
|
||||
{channelId && (
|
||||
<ClaimList
|
||||
ListHeaderComponent={this.listHeader}
|
||||
hideChannel
|
||||
orderBy={this.state.orderBy}
|
||||
time={timeItem.name}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
channelIds={[channelId]}
|
||||
style={channelPageStyle.claimList}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
@@ -123,21 +127,19 @@ class ChannelPage extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
const { cover, description, thumbnail, email, website_url, title } = claim.value;
|
||||
const { cover, description, thumbnail, email, website_url: websiteUrl, title } = claim.value;
|
||||
return (
|
||||
<View style={channelPageStyle.aboutTab}>
|
||||
{!website_url && !email && !description && (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>Nothing here yet. Please check back later.</Text>
|
||||
</View>
|
||||
{!websiteUrl && !email && !description && (
|
||||
<EmptyStateView message={"There's nothing here yet.\nPlease check back later."} />
|
||||
)}
|
||||
|
||||
{(website_url || email || description) && (
|
||||
{(websiteUrl || email || description) && (
|
||||
<ScrollView style={channelPageStyle.aboutScroll} contentContainerStyle={channelPageStyle.aboutScrollContent}>
|
||||
{website_url && website_url.trim().length > 0 && (
|
||||
{websiteUrl && websiteUrl.trim().length > 0 && (
|
||||
<View style={channelPageStyle.aboutItem}>
|
||||
<Text style={channelPageStyle.aboutTitle}>Website</Text>
|
||||
<Link style={channelPageStyle.aboutText} text={website_url} href={website_url} />
|
||||
<Link style={channelPageStyle.aboutText} text={websiteUrl} href={websiteUrl} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -159,19 +161,67 @@ class ChannelPage extends React.PureComponent {
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { fetching, claimsInChannel, claim, navigation, totalPages, uri, drawerStack, popDrawerStack } = this.props;
|
||||
const { name, permanent_url: permanentUrl } = claim;
|
||||
onEditPressed = () => {
|
||||
const { claim, navigation } = this.props;
|
||||
if (claim) {
|
||||
const { permanent_url: permanentUrl } = claim;
|
||||
navigation.navigate({
|
||||
routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
|
||||
params: { editChannelUrl: permanentUrl },
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let thumbnailUrl, coverUrl, title;
|
||||
if (claim && claim.value) {
|
||||
title = claim.value.title;
|
||||
if (claim.value.cover) {
|
||||
coverUrl = claim.value.cover.url;
|
||||
}
|
||||
if (claim.value.thumbnail) {
|
||||
thumbnailUrl = claim.value.thumbnail.url;
|
||||
onDeletePressed = () => {
|
||||
const { abandonClaim, claim, navigation } = this.props;
|
||||
if (claim) {
|
||||
const { txid, nout } = claim;
|
||||
|
||||
// show confirm alert
|
||||
Alert.alert(
|
||||
__('Delete channel'),
|
||||
__('Are you sure you want to delete this channel?'),
|
||||
[
|
||||
{ text: __('No') },
|
||||
{
|
||||
text: __('Yes'),
|
||||
onPress: () => {
|
||||
abandonClaim(txid, nout);
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR });
|
||||
},
|
||||
},
|
||||
],
|
||||
{ cancelable: true }
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { channels, claim, navigation, uri, drawerStack, popDrawerStack, sortByItem, timeItem } = this.props;
|
||||
const { name, permanent_url: permanentUrl } = claim;
|
||||
const { autoStyle, showSortPicker, showTimePicker } = this.state;
|
||||
const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false;
|
||||
|
||||
let thumbnailUrl,
|
||||
coverUrl,
|
||||
title,
|
||||
fullUri,
|
||||
displayName = null,
|
||||
substrIndex = 0;
|
||||
if (claim) {
|
||||
if (claim.value) {
|
||||
title = claim.value.title;
|
||||
if (claim.value.cover) {
|
||||
coverUrl = claim.value.cover.url;
|
||||
}
|
||||
if (claim.value.thumbnail) {
|
||||
thumbnailUrl = claim.value.thumbnail.url;
|
||||
}
|
||||
}
|
||||
|
||||
displayName = title || claim.name;
|
||||
substrIndex = displayName.startsWith('@') ? 1 : 0;
|
||||
fullUri = normalizeURI(`${claim.name}#${claim.claim_id}`);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -194,19 +244,45 @@ class ChannelPage extends React.PureComponent {
|
||||
<Text style={channelPageStyle.channelName}>{title && title.trim().length > 0 ? title : name}</Text>
|
||||
</View>
|
||||
|
||||
<View style={channelPageStyle.avatarImageContainer}>
|
||||
<Image
|
||||
style={channelPageStyle.avatarImage}
|
||||
resizeMode={'cover'}
|
||||
source={
|
||||
thumbnailUrl && thumbnailUrl.trim().length > 0
|
||||
? { uri: thumbnailUrl }
|
||||
: require('../../assets/default_avatar.jpg')
|
||||
}
|
||||
/>
|
||||
<View style={[channelPageStyle.avatarImageContainer, autoStyle]}>
|
||||
{thumbnailUrl && (
|
||||
<Image style={channelPageStyle.avatarImage} resizeMode={'cover'} source={{ uri: thumbnailUrl }} />
|
||||
)}
|
||||
{(!thumbnailUrl || thumbnailUrl.trim().length === 0) && (
|
||||
<Text style={channelIconStyle.autothumbCharacter}>
|
||||
{displayName.substring(substrIndex, substrIndex + 1).toUpperCase()}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<SubscribeButton style={channelPageStyle.subscribeButton} uri={uri} name={name} />
|
||||
<View style={channelPageStyle.subscribeButtonContainer}>
|
||||
{ownedChannel && (
|
||||
<Button
|
||||
style={channelPageStyle.actionButton}
|
||||
theme={'light'}
|
||||
icon={'edit'}
|
||||
text={'Edit'}
|
||||
onPress={this.onEditPressed}
|
||||
/>
|
||||
)}
|
||||
{ownedChannel && (
|
||||
<Button
|
||||
style={[channelPageStyle.actionButton, channelPageStyle.deleteButton]}
|
||||
theme={'light'}
|
||||
icon={'trash-alt'}
|
||||
text={'Delete'}
|
||||
onPress={this.onDeletePressed}
|
||||
/>
|
||||
)}
|
||||
{!ownedChannel && <SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} />}
|
||||
{!ownedChannel && (
|
||||
<SubscribeNotificationButton
|
||||
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]}
|
||||
uri={fullUri}
|
||||
name={name}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={channelPageStyle.tabBar}>
|
||||
@@ -229,6 +305,25 @@ class ChannelPage extends React.PureComponent {
|
||||
{Constants.CONTENT_TAB === this.state.activeTab && this.renderContent()}
|
||||
{Constants.ABOUT_TAB === this.state.activeTab && this.renderAbout()}
|
||||
</View>
|
||||
|
||||
{showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={sortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showTimePicker && (
|
||||
<ModalPicker
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={timeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectAbandoningIds,
|
||||
selectBalance,
|
||||
selectMyChannelClaims,
|
||||
selectFetchingMyChannels,
|
||||
selectUpdatingChannel,
|
||||
selectUpdateChannelError,
|
||||
doAbandonClaim,
|
||||
doFetchChannelListMine,
|
||||
doCreateChannel,
|
||||
doUpdateChannel,
|
||||
doToast,
|
||||
} from 'lbry-redux';
|
||||
import { doGetSync } from 'lbryinc';
|
||||
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doUpdateChannelFormState, doClearChannelFormState } from 'redux/actions/form';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { selectChannelFormState, selectHasChannelFormState } from 'redux/selectors/form';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import ChannelCreator from './view';
|
||||
|
||||
const select = state => ({
|
||||
abandoningClaimIds: selectAbandoningIds(state),
|
||||
channels: selectMyChannelClaims(state),
|
||||
channelFormState: selectChannelFormState(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
fetchingChannels: selectFetchingMyChannels(state),
|
||||
balance: selectBalance(state),
|
||||
hasFormState: selectHasChannelFormState(state),
|
||||
updatingChannel: selectUpdatingChannel(state),
|
||||
updateChannelError: selectUpdateChannelError(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
clearChannelFormState: () => dispatch(doClearChannelFormState()),
|
||||
createChannel: (name, amount, optionalParams) => dispatch(doCreateChannel(name, amount, optionalParams)),
|
||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
updateChannel: params => dispatch(doUpdateChannel(params)),
|
||||
updateChannelFormState: data => dispatch(doUpdateChannelFormState(data)),
|
||||
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(ChannelCreator);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,12 +1,5 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doClaimSearch,
|
||||
doFileList,
|
||||
selectBalance,
|
||||
selectFileInfosDownloaded,
|
||||
selectLastClaimSearchUris,
|
||||
selectFollowedTags,
|
||||
} from 'lbry-redux';
|
||||
import { doClaimSearch, doFileList, selectBalance, selectFileInfosDownloaded, selectFollowedTags } from 'lbry-redux';
|
||||
import {
|
||||
doFetchFeaturedUris,
|
||||
doFetchRewardedContent,
|
||||
@@ -18,9 +11,9 @@ import {
|
||||
selectSubscriptionClaims,
|
||||
selectUnreadSubscriptions,
|
||||
} from 'lbryinc';
|
||||
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doPushDrawerStack } from 'redux/actions/drawer';
|
||||
import { doSetClientSetting, doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import DiscoverPage from './view';
|
||||
|
||||
@@ -34,8 +27,9 @@ const select = state => ({
|
||||
followedTags: selectFollowedTags(state),
|
||||
ratingReminderDisabled: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED)(state),
|
||||
ratingReminderLastShown: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN)(state),
|
||||
sortByItem: selectSortByItem(state),
|
||||
timeItem: selectTimeItem(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
uris: selectLastClaimSearchUris(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
@@ -44,8 +38,11 @@ const perform = dispatch => ({
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||
fileList: () => dispatch(doFileList()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_DISCOVER)),
|
||||
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
+182
-110
@@ -11,7 +11,7 @@ import {
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS, Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { __, formatTagTitle } from 'utils/helper';
|
||||
import { __, formatTagTitle, getOrderBy } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import CategoryList from 'component/categoryList';
|
||||
@@ -30,10 +30,11 @@ import _ from 'lodash';
|
||||
class DiscoverPage extends React.PureComponent {
|
||||
state = {
|
||||
tagCollection: [],
|
||||
remainingTags: [],
|
||||
showModalTagSelector: false,
|
||||
showSortPicker: false,
|
||||
showTimePicker: false,
|
||||
orderBy: Constants.DEFAULT_ORDER_BY,
|
||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[0],
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -60,33 +61,50 @@ class DiscoverPage extends React.PureComponent {
|
||||
}
|
||||
});
|
||||
|
||||
const { fetchRewardedContent, fetchSubscriptions, fileList, followedTags } = this.props;
|
||||
const { sortByItem, fetchRewardedContent, fileList, followedTags } = this.props;
|
||||
|
||||
this.buildTagCollection(followedTags);
|
||||
fetchRewardedContent();
|
||||
fetchSubscriptions();
|
||||
fileList();
|
||||
|
||||
this.handleSortByItemSelected(sortByItem);
|
||||
this.showRatingReminder();
|
||||
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
let orderBy = [];
|
||||
switch (item.name) {
|
||||
case Constants.SORT_BY_HOT:
|
||||
orderBy = Constants.DEFAULT_ORDER_BY;
|
||||
break;
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute: prevRoute, followedTags: prevFollowedTags } = this.props;
|
||||
const { currentRoute, followedTags } = nextProps;
|
||||
|
||||
case Constants.SORT_BY_NEW:
|
||||
orderBy = ['release_time'];
|
||||
break;
|
||||
|
||||
case Constants.SORT_BY_TOP:
|
||||
orderBy = ['effective_amount'];
|
||||
break;
|
||||
if (Constants.DRAWER_ROUTE_DISCOVER === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
if (!_.isEqual(followedTags, prevFollowedTags)) {
|
||||
this.buildTagCollection(followedTags);
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { fetchSubscriptions, pushDrawerStack } = this.props;
|
||||
// pushDrawerStack();
|
||||
NativeModules.Firebase.setCurrentScreen('Your tags').then(result => {
|
||||
fetchSubscriptions();
|
||||
});
|
||||
};
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
const { setSortByItem } = this.props;
|
||||
setSortByItem(item);
|
||||
const orderBy = getOrderBy(item);
|
||||
this.setState({ orderBy, showSortPicker: false });
|
||||
};
|
||||
|
||||
handleTimeItemSelected = item => {
|
||||
const { setTimeItem } = this.props;
|
||||
setTimeItem(item);
|
||||
this.setState({ showTimePicker: false });
|
||||
};
|
||||
|
||||
subscriptionForUri = (uri, channelName) => {
|
||||
@@ -106,56 +124,43 @@ class DiscoverPage extends React.PureComponent {
|
||||
return null;
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { followedTags: prevFollowedTags } = this.props;
|
||||
const { followedTags } = nextProps;
|
||||
if (!_.isEqual(followedTags, prevFollowedTags)) {
|
||||
this.buildTagCollection(followedTags);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||
|
||||
const utility = NativeModules.UtilityModule;
|
||||
if (utility) {
|
||||
const hasUnread =
|
||||
prevProps.unreadSubscriptions &&
|
||||
prevProps.unreadSubscriptions.length !== unreadSubscriptions.length &&
|
||||
unreadSubscriptions.length > 0;
|
||||
const hasUnread =
|
||||
prevProps.unreadSubscriptions &&
|
||||
prevProps.unreadSubscriptions.length !== unreadSubscriptions.length &&
|
||||
unreadSubscriptions.length > 0;
|
||||
|
||||
if (hasUnread) {
|
||||
unreadSubscriptions.map(({ channel, uris }) => {
|
||||
const { claimName: channelName } = parseURI(channel);
|
||||
if (hasUnread) {
|
||||
unreadSubscriptions.map(({ channel, uris }) => {
|
||||
const { claimName: channelName } = parseURI(channel);
|
||||
|
||||
// check if notifications are enabled for the channel
|
||||
if (enabledChannelNotifications.indexOf(channelName) > -1) {
|
||||
uris.forEach(uri => {
|
||||
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
|
||||
);
|
||||
}
|
||||
// check if notifications are enabled for the channel
|
||||
if (enabledChannelNotifications.includes(channelName)) {
|
||||
uris.forEach(uri => {
|
||||
Lbry.resolve({ urls: uri }).then(result => {
|
||||
const sub = result[uri];
|
||||
|
||||
if (sub && sub.value) {
|
||||
const { source, title, thumbnail } = sub.value;
|
||||
const isPlayable =
|
||||
source && source.media_type && ['audio', 'video'].includes(source.media_type.substring(0, 5));
|
||||
if (title) {
|
||||
utility.showNotificationForContent(
|
||||
uri,
|
||||
title,
|
||||
channelName,
|
||||
thumbnail ? thumbnail.url : null,
|
||||
isPlayable
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +212,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
|
||||
buildSections = () => {
|
||||
return this.state.tagCollection.map(tags => ({
|
||||
title: tags.length === 1 ? tags[0] : 'Trending',
|
||||
title: tags.length === 1 ? tags[0] : 'All tags you follow',
|
||||
data: [tags],
|
||||
}));
|
||||
};
|
||||
@@ -216,79 +221,137 @@ class DiscoverPage extends React.PureComponent {
|
||||
const tags = followedTags.map(tag => tag.name);
|
||||
|
||||
// each of the followed tags
|
||||
const tagCollection = tags.map(tag => [tag]);
|
||||
const tagCollection = _.shuffle(tags)
|
||||
.slice(0, 5)
|
||||
.map(tag => [tag]);
|
||||
|
||||
const usedTags = tagCollection.map(tagList => tagList[0]);
|
||||
const remainingTags = tags.filter(tag => !usedTags.includes(tag));
|
||||
|
||||
// everything
|
||||
tagCollection.unshift(tags);
|
||||
|
||||
this.setState({ tagCollection });
|
||||
this.setState({ remainingTags, tagCollection });
|
||||
};
|
||||
|
||||
handleTagPress = name => {
|
||||
const { navigation } = this.props;
|
||||
if (name.toLowerCase() !== 'trending') {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: `tagPage`, params: { tag: name } });
|
||||
const { navigation, sortByItem } = this.props;
|
||||
if (name.toLowerCase() !== 'all tags you follow') {
|
||||
navigation.navigate({
|
||||
routeName: Constants.DRAWER_ROUTE_TAG,
|
||||
key: `tagPage`,
|
||||
params: {
|
||||
tag: name,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// navigate to the trending page
|
||||
navigation.navigate({ routeName: Constants.FULL_ROUTE_NAME_TRENDING });
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TRENDING, params: { filterForTags: true } });
|
||||
}
|
||||
};
|
||||
|
||||
sectionListHeader = () => {
|
||||
const { sortByItem, timeItem } = this.props;
|
||||
return (
|
||||
<View style={discoverStyle.listHeader}>
|
||||
<View style={discoverStyle.titleRow}>
|
||||
<Text style={discoverStyle.pageTitle}>Your tags</Text>
|
||||
</View>
|
||||
<View style={discoverStyle.pickerRow}>
|
||||
<View style={discoverStyle.leftPickerRow}>
|
||||
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
|
||||
{Constants.SORT_BY_TOP === sortByItem.name && (
|
||||
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Link
|
||||
style={discoverStyle.customizeLink}
|
||||
text={'Customize'}
|
||||
onPress={() => this.setState({ showModalTagSelector: true })}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
sectionListFooter = () => {
|
||||
const { remainingTags } = this.state;
|
||||
if (remainingTags.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.footer}>
|
||||
<Text style={discoverStyle.footerTitle}>More tags you follow</Text>
|
||||
<View style={discoverStyle.footerTags}>
|
||||
{remainingTags.map(tag => (
|
||||
<Text
|
||||
key={tag}
|
||||
style={[discoverStyle.categoryName, discoverStyle.footerTag]}
|
||||
onPress={() => this.handleTagPress(tag)}
|
||||
>
|
||||
{formatTagTitle(tag)}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
renderSectionListItem = ({ item, index, section }) => (
|
||||
<ClaimList
|
||||
key={item.sort().join(',')}
|
||||
orderBy={this.state.orderBy}
|
||||
time={this.props.timeItem.name}
|
||||
tags={item}
|
||||
morePlaceholder
|
||||
navigation={this.props.navigation}
|
||||
orientation={Constants.ORIENTATION_HORIZONTAL}
|
||||
/>
|
||||
);
|
||||
|
||||
renderSectionHeader = ({ section: { title } }) => (
|
||||
<View style={discoverStyle.categoryTitleRow}>
|
||||
<Text style={discoverStyle.categoryName} onPress={() => this.handleTagPress(title)}>
|
||||
{formatTagTitle(title)}
|
||||
</Text>
|
||||
<TouchableOpacity onPress={() => this.handleTagPress(title)}>
|
||||
<Icon name={'angle-double-down'} size={16} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { currentSortByItem, orderBy, showModalTagSelector, showSortPicker } = this.state;
|
||||
const { navigation, sortByItem, timeItem } = this.props;
|
||||
const { orderBy, showModalTagSelector, showSortPicker, showTimePicker } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} belowOverlay={showModalTagSelector} />
|
||||
<SectionList
|
||||
ListHeaderComponent={
|
||||
<View style={discoverStyle.titleRow}>
|
||||
<Text style={discoverStyle.pageTitle}>Explore</Text>
|
||||
<View style={discoverStyle.rightTitleRow}>
|
||||
<Link
|
||||
style={discoverStyle.customizeLink}
|
||||
text={'Customize'}
|
||||
onPress={() => this.setState({ showModalTagSelector: true })}
|
||||
/>
|
||||
<TouchableOpacity
|
||||
style={discoverStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showSortPicker: true })}
|
||||
>
|
||||
<Text style={discoverStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
ListHeaderComponent={this.sectionListHeader}
|
||||
ListFooterComponent={this.sectionListFooter}
|
||||
style={discoverStyle.scrollContainer}
|
||||
contentContainerStyle={discoverStyle.scrollPadding}
|
||||
initialNumToRender={4}
|
||||
maxToRenderPerBatch={4}
|
||||
removeClippedSubviews
|
||||
renderItem={({ item, index, section }) => (
|
||||
<ClaimList
|
||||
key={item.sort().join(',')}
|
||||
orderBy={item.length > 1 ? Constants.DEFAULT_ORDER_BY : orderBy}
|
||||
tags={item}
|
||||
morePlaceholder
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_HORIZONTAL}
|
||||
/>
|
||||
)}
|
||||
renderSectionHeader={({ section: { title } }) => (
|
||||
<View style={discoverStyle.categoryTitleRow}>
|
||||
<Text style={discoverStyle.categoryName} onPress={() => this.handleTagPress(title)}>
|
||||
{formatTagTitle(title)}
|
||||
</Text>
|
||||
<TouchableOpacity onPress={() => this.handleTagPress(title)}>
|
||||
<Icon name={'angle-double-down'} size={16} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)}
|
||||
renderItem={this.renderSectionListItem}
|
||||
renderSectionHeader={this.renderSectionHeader}
|
||||
sections={this.buildSections()}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
{!showModalTagSelector && !showSortPicker && <FloatingWalletBalance navigation={navigation} />}
|
||||
{!showModalTagSelector && !showSortPicker && !showTimePicker && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
{showModalTagSelector && (
|
||||
<ModalTagSelector
|
||||
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
|
||||
@@ -300,10 +363,19 @@ class DiscoverPage extends React.PureComponent {
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={currentSortByItem}
|
||||
selectedItem={sortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showTimePicker && (
|
||||
<ModalPicker
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={timeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFileList,
|
||||
doFetchClaimListMine,
|
||||
selectFileInfosDownloaded,
|
||||
selectDownloadedUris,
|
||||
selectMyClaimsWithoutChannels,
|
||||
selectIsFetchingClaimListMine,
|
||||
selectIsFetchingFileList,
|
||||
} from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doDeleteFile } from 'redux/actions/file';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import DownloadsPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
claims: selectMyClaimsWithoutChannels(state),
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
fileInfos: selectFileInfosDownloaded(state),
|
||||
fetching: selectIsFetchingFileList(state),
|
||||
downloadedUris: selectDownloadedUris(state),
|
||||
fetching: selectIsFetchingFileList(state) || selectIsFetchingClaimListMine(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
|
||||
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
|
||||
},
|
||||
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
|
||||
fileList: () => dispatch(doFileList()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_MY_LBRY)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
|
||||
+138
-29
@@ -1,10 +1,21 @@
|
||||
import React from 'react';
|
||||
import { Lbry, buildURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, Button, FlatList, Text, TextInput, View, ScrollView } from 'react-native';
|
||||
import { navigateToUri, uriFromFileInfo } from 'utils/helper';
|
||||
import { Lbry, buildURI, normalizeURI } from 'lbry-redux';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
Button,
|
||||
FlatList,
|
||||
NativeModules,
|
||||
Text,
|
||||
TextInput,
|
||||
View,
|
||||
ScrollView,
|
||||
} from 'react-native';
|
||||
import { __, navigateToUri, uriFromFileInfo } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import EmptyStateView from 'component/emptyStateView';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import StorageStatsCard from 'component/storageStatsCard';
|
||||
@@ -17,11 +28,17 @@ class DownloadsPage extends React.PureComponent {
|
||||
title: 'Downloads',
|
||||
};
|
||||
|
||||
state = {
|
||||
selectionMode: false,
|
||||
selectedUris: [],
|
||||
selectedClaimsMap: {},
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -31,9 +48,12 @@ class DownloadsPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { fileList, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
const { fetchMyClaims, fileList, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Library');
|
||||
|
||||
fetchMyClaims();
|
||||
fileList();
|
||||
};
|
||||
|
||||
@@ -44,49 +64,138 @@ class DownloadsPage extends React.PureComponent {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.FULL_ROUTE_NAME_MY_LBRY === currentRoute && currentRoute !== prevRoute) {
|
||||
if (Constants.DRAWER_ROUTE_MY_LBRY === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
getFilteredUris = () => {
|
||||
const { claims, downloadedUris } = this.props;
|
||||
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
|
||||
return downloadedUris.filter(uri => !claimUris.includes(uri));
|
||||
};
|
||||
|
||||
getFilteredFileInfos = () => {
|
||||
const { claims, fileInfos } = this.props;
|
||||
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
|
||||
return fileInfos.filter(
|
||||
fileInfo => !claimUris.includes(normalizeURI(`${fileInfo.claim_name}#${fileInfo.claim_id}`))
|
||||
);
|
||||
};
|
||||
|
||||
addOrRemoveItem = (uri, claim) => {
|
||||
const { selectedClaimsMap } = this.state;
|
||||
let selectedUris = [...this.state.selectedUris];
|
||||
|
||||
if (selectedUris.includes(uri)) {
|
||||
delete selectedClaimsMap[uri];
|
||||
selectedUris.splice(selectedUris.indexOf(uri), 1);
|
||||
} else {
|
||||
selectedClaimsMap[uri] = claim;
|
||||
selectedUris.push(uri);
|
||||
}
|
||||
|
||||
this.setState({ selectionMode: selectedUris.length > 0, selectedUris, selectedClaimsMap });
|
||||
};
|
||||
|
||||
handleSelectItem = (uri, claim) => {
|
||||
this.addOrRemoveItem(uri, claim);
|
||||
};
|
||||
|
||||
handleItemLongPress = (uri, claim) => {
|
||||
this.addOrRemoveItem(uri, claim);
|
||||
};
|
||||
|
||||
onExitSelectionMode = () => {
|
||||
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} });
|
||||
};
|
||||
|
||||
onDeleteActionPressed = () => {
|
||||
const { deleteFile, fileList } = this.props;
|
||||
const { selectedClaimsMap } = this.state;
|
||||
|
||||
// show confirm alert
|
||||
Alert.alert(
|
||||
__('Delete files'),
|
||||
__('Are you sure you want to delete the selected content?'),
|
||||
[
|
||||
{ text: __('No') },
|
||||
{
|
||||
text: __('Yes'),
|
||||
onPress: () => {
|
||||
const uris = Object.keys(selectedClaimsMap);
|
||||
uris.forEach(uri => {
|
||||
const { txid, nout } = selectedClaimsMap[uri];
|
||||
deleteFile(`${txid}:${nout}`, true);
|
||||
});
|
||||
this.onExitSelectionMode();
|
||||
fileList();
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
cancelable: true,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { fetching, fileInfos, navigation } = this.props;
|
||||
const hasDownloads = fileInfos && Object.values(fileInfos).length > 0;
|
||||
const { fetching, claims, downloadedUris, fileInfos, navigation } = this.props;
|
||||
const { selectionMode, selectedUris } = this.state;
|
||||
const filteredUris = this.getFilteredUris();
|
||||
const hasDownloads = filteredUris && filteredUris.length > 0;
|
||||
|
||||
return (
|
||||
<View style={downloadsStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
<UriBar
|
||||
navigation={navigation}
|
||||
selectionMode={selectionMode}
|
||||
selectedItemCount={selectedUris.length}
|
||||
onExitSelectionMode={this.onExitSelectionMode}
|
||||
onDeleteActionPressed={this.onDeleteActionPressed}
|
||||
/>
|
||||
|
||||
{!fetching && !hasDownloads && (
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
<Text style={downloadsStyle.noDownloadsText}>
|
||||
You have not watched or downloaded any content from LBRY yet.
|
||||
</Text>
|
||||
</View>
|
||||
<EmptyStateView message={'You do not have any\ndownloaded content on this device.'} />
|
||||
)}
|
||||
{fetching && !hasDownloads && (
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={downloadsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
{hasDownloads && (
|
||||
<View style={downloadsStyle.subContainer}>
|
||||
<StorageStatsCard fileInfos={fileInfos} />
|
||||
|
||||
<View style={downloadsStyle.subContainer}>
|
||||
{hasDownloads && <StorageStatsCard fileInfos={this.getFilteredFileInfos()} />}
|
||||
{fetching && (
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={downloadsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!fetching && hasDownloads && (
|
||||
<FlatList
|
||||
extraData={this.state}
|
||||
style={downloadsStyle.scrollContainer}
|
||||
contentContainerStyle={downloadsStyle.scrollPadding}
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem
|
||||
autoplay
|
||||
key={item}
|
||||
uri={item}
|
||||
style={fileListStyle.item}
|
||||
uri={uriFromFileInfo(item)}
|
||||
selected={selectedUris.includes(item)}
|
||||
onPress={claim => {
|
||||
if (selectionMode) {
|
||||
this.handleSelectItem(item, claim);
|
||||
} else {
|
||||
// TODO: when shortUrl is available for my claims, navigate to that URL instead
|
||||
navigateToUri(navigation, item, { autoplay: true });
|
||||
}
|
||||
}}
|
||||
onLongPress={claim => this.handleItemLongPress(item, claim)}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, uriFromFileInfo(item), { autoplay: true })}
|
||||
/>
|
||||
)}
|
||||
data={fileInfos}
|
||||
keyExtractor={(item, index) => item.outpoint}
|
||||
data={downloadedUris}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
)}
|
||||
</View>
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
|
||||
+14
-2
@@ -1,6 +1,9 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doAbandonClaim,
|
||||
doFetchFileInfo,
|
||||
doFetchChannelListMine,
|
||||
doFetchClaimListMine,
|
||||
doFileGet,
|
||||
doPurchaseUri,
|
||||
doDeletePurchasedUri,
|
||||
@@ -18,11 +21,14 @@ import {
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
selectBalance,
|
||||
selectMyChannelClaims,
|
||||
selectMyClaimUrisWithoutChannels,
|
||||
selectPurchasedUris,
|
||||
selectFailedPurchaseUris,
|
||||
selectPurchaseUriErrorMessage,
|
||||
} from 'lbry-redux';
|
||||
import {
|
||||
doClaimEligiblePurchaseRewards,
|
||||
doFetchCostInfoForUri,
|
||||
makeSelectCostInfoForUri,
|
||||
selectRewardContentClaimIds,
|
||||
@@ -44,20 +50,22 @@ const select = (state, props) => {
|
||||
return {
|
||||
balance: selectBalance(state),
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
channels: selectMyChannelClaims(state),
|
||||
claim: makeSelectClaimForUri(selectProps.uri)(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
|
||||
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
|
||||
//obscureNsfw: !selectShowNsfw(state),
|
||||
//tab: makeSelectCurrentParam('tab')(state),
|
||||
// obscureNsfw: !selectShowNsfw(state),
|
||||
// tab: makeSelectCurrentParam('tab')(state),
|
||||
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
||||
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
||||
position: makeSelectContentPositionForUri(selectProps.uri)(state),
|
||||
purchasedUris: selectPurchasedUris(state),
|
||||
failedPurchaseUris: selectFailedPurchaseUris(state),
|
||||
myClaimUris: selectMyClaimUrisWithoutChannels(state),
|
||||
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
|
||||
@@ -66,11 +74,15 @@ const select = (state, props) => {
|
||||
};
|
||||
|
||||
const perform = dispatch => ({
|
||||
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
||||
claimEligibleRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
|
||||
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
|
||||
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
|
||||
},
|
||||
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
|
||||
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
|
||||
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
|
||||
+480
-346
@@ -1,11 +1,12 @@
|
||||
import React from 'react';
|
||||
import { Lbry, normalizeURI } from 'lbry-redux';
|
||||
import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
DeviceEventEmitter,
|
||||
Dimensions,
|
||||
Linking,
|
||||
NativeModules,
|
||||
ScrollView,
|
||||
StatusBar,
|
||||
@@ -22,6 +23,7 @@ import { navigateBack, navigateToUri } from 'utils/helper';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import ImageViewer from 'react-native-image-zoom-viewer';
|
||||
import Button from 'component/button';
|
||||
import EmptyStateView from 'component/emptyStateView';
|
||||
import Tag from 'component/tag';
|
||||
import ChannelPage from 'page/channel';
|
||||
import Colors from 'styles/colors';
|
||||
@@ -70,6 +72,7 @@ class FilePage extends React.PureComponent {
|
||||
mediaLoaded: false,
|
||||
pageSuspended: false,
|
||||
relatedContentY: 0,
|
||||
sendTipStarted: false,
|
||||
showDescription: false,
|
||||
showImageViewer: false,
|
||||
showWebView: false,
|
||||
@@ -88,17 +91,18 @@ class FilePage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
StatusBar.setHidden(false);
|
||||
NativeModules.Firebase.setCurrentScreen('File');
|
||||
|
||||
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted);
|
||||
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
|
||||
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted);
|
||||
|
||||
const { fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
|
||||
const { fetchMyClaims, fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
|
||||
const { uri, uriVars } = navigation.state.params;
|
||||
this.setState({ uri, uriVars });
|
||||
|
||||
@@ -106,6 +110,7 @@ class FilePage extends React.PureComponent {
|
||||
|
||||
this.fetchFileInfo(this.props);
|
||||
this.fetchCostInfo(this.props);
|
||||
fetchMyClaims();
|
||||
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('open_file_page', { uri: uri });
|
||||
@@ -230,8 +235,13 @@ class FilePage extends React.PureComponent {
|
||||
}
|
||||
};
|
||||
|
||||
onEditPressed = () => {
|
||||
const { claim, navigation } = this.props;
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
|
||||
};
|
||||
|
||||
onDeletePressed = () => {
|
||||
const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props;
|
||||
const { abandonClaim, claim, deleteFile, deletePurchasedUri, myClaimUris, fileInfo, navigation } = this.props;
|
||||
|
||||
Alert.alert(
|
||||
'Delete file',
|
||||
@@ -242,17 +252,27 @@ class FilePage extends React.PureComponent {
|
||||
text: 'Yes',
|
||||
onPress: () => {
|
||||
const { uri } = navigation.state.params;
|
||||
|
||||
deleteFile(`${claim.txid}:${claim.nout}`, true);
|
||||
deletePurchasedUri(uri);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.deleteDownload(uri);
|
||||
}
|
||||
|
||||
NativeModules.UtilityModule.deleteDownload(uri);
|
||||
this.setState({
|
||||
downloadPressed: false,
|
||||
fileViewLogged: false,
|
||||
mediaLoaded: false,
|
||||
stopDownloadConfirmed: false,
|
||||
});
|
||||
|
||||
if (claim) {
|
||||
const fullUri = normalizeURI(`${claim.name}#${claim.claim_id}`);
|
||||
const ownedClaim = myClaimUris.includes(fullUri);
|
||||
if (ownedClaim) {
|
||||
const { txid, nout } = claim;
|
||||
abandonClaim(txid, nout);
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISHES });
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -470,6 +490,7 @@ class FilePage extends React.PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
const { claimEligibleRewards } = this.props;
|
||||
const { nout, claim_id: claimId, txid } = claim;
|
||||
const outpoint = `${txid}:${nout}`;
|
||||
const params = {
|
||||
@@ -481,10 +502,26 @@ class FilePage extends React.PureComponent {
|
||||
params.time_to_start = timeToStart;
|
||||
}
|
||||
|
||||
Lbryio.call('file', 'view', params).catch(() => {});
|
||||
Lbryio.call('file', 'view', params)
|
||||
.then(() => claimEligibleRewards())
|
||||
.catch(() => {});
|
||||
this.setState({ fileViewLogged: true });
|
||||
};
|
||||
|
||||
// TODO: Move this to lbry-redux
|
||||
formatLbryUrlForWeb = url => {
|
||||
return url.replace('lbry://', '/').replace(/#/g, ':');
|
||||
};
|
||||
|
||||
handleSharePress = () => {
|
||||
const { claim, notify } = this.props;
|
||||
if (claim) {
|
||||
const { canonical_url: canonicalUrl, short_url: shortUrl, permanent_url: permanentUrl } = claim;
|
||||
const url = 'https://open.lbry.com' + this.formatLbryUrlForWeb(canonicalUrl || shortUrl || permanentUrl);
|
||||
NativeModules.UtilityModule.shareUrl(url);
|
||||
}
|
||||
};
|
||||
|
||||
handleSendTip = () => {
|
||||
const { claim, balance, navigation, notify, sendTip } = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
@@ -497,9 +534,25 @@ class FilePage extends React.PureComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
sendTip(tipAmount, claim.claim_id, isSupport: false, () => {
|
||||
this.setState({ tipAmount: 0, showTipView: false });
|
||||
});
|
||||
const suffix = 'credit' + (parseInt(tipAmount, 10) === 1 ? '' : 's');
|
||||
Alert.alert(
|
||||
'Send tip',
|
||||
`Are you sure you want to tip ${tipAmount} ${suffix}?`,
|
||||
[
|
||||
{ text: 'No' },
|
||||
{
|
||||
text: 'Yes',
|
||||
onPress: () => {
|
||||
this.setState({ sendTipStarted: true }, () =>
|
||||
sendTip(tipAmount, claim.claim_id, false, () => {
|
||||
this.setState({ tipAmount: null, showTipView: false, sendTipStarted: false });
|
||||
})
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
{ cancelable: true }
|
||||
);
|
||||
};
|
||||
|
||||
renderTags = tags => {
|
||||
@@ -544,6 +597,7 @@ class FilePage extends React.PureComponent {
|
||||
const {
|
||||
balance,
|
||||
claim,
|
||||
channels,
|
||||
channelUri,
|
||||
costInfo,
|
||||
fileInfo,
|
||||
@@ -553,6 +607,7 @@ class FilePage extends React.PureComponent {
|
||||
rewardedContentClaimIds,
|
||||
isResolvingUri,
|
||||
blackListedOutpoints,
|
||||
myClaimUris,
|
||||
navigation,
|
||||
position,
|
||||
purchaseUri,
|
||||
@@ -561,27 +616,56 @@ class FilePage extends React.PureComponent {
|
||||
} = this.props;
|
||||
const { uri, autoplay } = navigation.state.params;
|
||||
|
||||
const { isChannel } = parseURI(uri);
|
||||
const myChannelUris = channels ? channels.map(channel => channel.permanent_url) : [];
|
||||
const ownedClaim = myClaimUris.includes(uri) || myChannelUris.includes(uri);
|
||||
|
||||
let innerContent = null;
|
||||
if ((isResolvingUri && !claim) || !claim) {
|
||||
innerContent = (
|
||||
return (
|
||||
<View style={filePageStyle.container}>
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
{isResolvingUri && (
|
||||
<View style={filePageStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
<Text style={filePageStyle.infoText}>Loading decentralized data...</Text>
|
||||
</View>
|
||||
)}
|
||||
{claim === null && !isResolvingUri && (
|
||||
<View style={filePageStyle.container}>
|
||||
<Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>
|
||||
{ownedClaim && (
|
||||
<EmptyStateView
|
||||
message={
|
||||
isChannel
|
||||
? 'It looks like you just created this channel. It will appear in a few minutes.'
|
||||
: 'It looks you just published this content. It will appear in a few minutes.'
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!ownedClaim && (
|
||||
<EmptyStateView
|
||||
message={"There's nothing at this location."}
|
||||
buttonText={'Publish something here'}
|
||||
onButtonPress={() =>
|
||||
navigation.navigate({
|
||||
routeName: Constants.DRAWER_ROUTE_PUBLISH,
|
||||
params: { vanityUrl: uri.trim() },
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
} else if (claim && claim.name.length && claim.name[0] === '@') {
|
||||
innerContent = <ChannelPage uri={uri} navigation={navigation} />;
|
||||
} else if (claim) {
|
||||
}
|
||||
|
||||
if (claim) {
|
||||
if (isChannel) {
|
||||
return <ChannelPage uri={uri} navigation={navigation} />;
|
||||
}
|
||||
|
||||
let isClaimBlackListed = false;
|
||||
|
||||
if (blackListedOutpoints) {
|
||||
@@ -595,7 +679,7 @@ class FilePage extends React.PureComponent {
|
||||
}
|
||||
|
||||
if (isClaimBlackListed) {
|
||||
innerContent = (
|
||||
return (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
<View style={filePageStyle.dmcaContainer}>
|
||||
<Text style={filePageStyle.dmcaText}>
|
||||
@@ -607,358 +691,408 @@ class FilePage extends React.PureComponent {
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
let tags = [];
|
||||
if (claim && claim.value && claim.value.tags) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
}
|
||||
|
||||
const completed = fileInfo && fileInfo.completed;
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const description = metadata.description ? metadata.description : null;
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
const { height, signing_channel: signingChannel, value } = claim;
|
||||
const channelName = signingChannel && signingChannel.name;
|
||||
const showActions =
|
||||
fileInfo &&
|
||||
let tags = [];
|
||||
if (claim && claim.value && claim.value.tags) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
|
||||
const completed = fileInfo && fileInfo.completed;
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const description = metadata.description ? metadata.description : null;
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
const { height, signing_channel: signingChannel, value } = claim;
|
||||
const channelName = signingChannel && signingChannel.name;
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullUri = `${claim.name}#${claim.claim_id}`;
|
||||
const canEdit = myClaimUris.includes(normalizeURI(fullUri));
|
||||
const showActions =
|
||||
(canEdit || (fileInfo && fileInfo.download_path)) &&
|
||||
!this.state.fullscreenMode &&
|
||||
!this.state.showImageViewer &&
|
||||
!this.state.showWebView;
|
||||
const showFileActions =
|
||||
canEdit ||
|
||||
(fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
!this.state.fullscreenMode &&
|
||||
!this.state.showImageViewer &&
|
||||
!this.state.showWebView;
|
||||
const showFileActions =
|
||||
fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullChannelUri =
|
||||
channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)));
|
||||
const fullChannelUri =
|
||||
channelClaimId && channelClaimId.trim().length > 0
|
||||
? normalizeURI(`${channelName}#${channelClaimId}`)
|
||||
: normalizeURI(channelName);
|
||||
const shortChannelUri = signingChannel ? signingChannel.short_url : null;
|
||||
|
||||
const playerStyle = [
|
||||
filePageStyle.player,
|
||||
this.state.isLandscape
|
||||
? filePageStyle.containedPlayerLandscape
|
||||
: this.state.fullscreenMode
|
||||
? filePageStyle.fullscreenPlayer
|
||||
: filePageStyle.containedPlayer,
|
||||
];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
|
||||
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
|
||||
// at least 2MB (or the full download) before media can be loaded
|
||||
const canLoadMedia =
|
||||
this.state.streamingMode ||
|
||||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2
|
||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||
const isWebViewable = mediaType === 'text';
|
||||
const canOpen = isViewable && completed;
|
||||
const localFileUri = this.localUriForFileInfo(fileInfo);
|
||||
const playerStyle = [
|
||||
filePageStyle.player,
|
||||
this.state.isLandscape
|
||||
? filePageStyle.containedPlayerLandscape
|
||||
: this.state.fullscreenMode
|
||||
? filePageStyle.fullscreenPlayer
|
||||
: filePageStyle.containedPlayer,
|
||||
];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
|
||||
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
|
||||
// at least 2MB (or the full download) before media can be loaded
|
||||
const canLoadMedia =
|
||||
this.state.streamingMode ||
|
||||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2
|
||||
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
|
||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||
const isWebViewable = mediaType === 'text';
|
||||
const canOpen = isViewable && completed;
|
||||
const localFileUri = this.localUriForFileInfo(fileInfo);
|
||||
|
||||
const openFile = () => {
|
||||
if (mediaType === 'image') {
|
||||
// use image viewer
|
||||
if (!this.state.showImageViewer) {
|
||||
this.setState({
|
||||
imageUrls: [
|
||||
{
|
||||
url: localFileUri,
|
||||
},
|
||||
],
|
||||
showImageViewer: true,
|
||||
});
|
||||
}
|
||||
const openFile = () => {
|
||||
if (mediaType === 'image') {
|
||||
// use image viewer
|
||||
if (!this.state.showImageViewer) {
|
||||
this.setState({
|
||||
imageUrls: [
|
||||
{
|
||||
url: localFileUri,
|
||||
},
|
||||
],
|
||||
showImageViewer: true,
|
||||
});
|
||||
}
|
||||
if (isWebViewable) {
|
||||
// show webview
|
||||
if (!this.state.showWebView) {
|
||||
this.setState({
|
||||
showWebView: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (isWebViewable) {
|
||||
// show webview
|
||||
if (!this.state.showWebView) {
|
||||
this.setState({
|
||||
showWebView: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (
|
||||
fileInfo &&
|
||||
!this.state.autoDownloadStarted &&
|
||||
this.state.uriVars &&
|
||||
this.state.uriVars.download === 'true'
|
||||
) {
|
||||
this.setState({ autoDownloadStarted: true }, () => {
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (this.state.downloadPressed && canOpen) {
|
||||
// automatically open a web viewable or image file after the download button is pressed
|
||||
openFile();
|
||||
}
|
||||
if (fileInfo && !this.state.autoDownloadStarted && this.state.uriVars && this.state.uriVars.download === 'true') {
|
||||
this.setState({ autoDownloadStarted: true }, () => {
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
innerContent = (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{this.state.showWebView && isWebViewable && (
|
||||
<WebView source={{ uri: localFileUri }} style={filePageStyle.viewer} />
|
||||
)}
|
||||
if (this.state.downloadPressed && canOpen) {
|
||||
// automatically open a web viewable or image file after the download button is pressed
|
||||
openFile();
|
||||
}
|
||||
|
||||
{this.state.showImageViewer && (
|
||||
<ImageViewer
|
||||
style={StyleSheet.flatten(filePageStyle.viewer)}
|
||||
imageUrls={this.state.imageUrls}
|
||||
renderIndicator={() => null}
|
||||
/>
|
||||
)}
|
||||
return (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{this.state.showWebView && isWebViewable && (
|
||||
<WebView source={{ uri: localFileUri }} style={filePageStyle.viewer} />
|
||||
)}
|
||||
|
||||
{!this.state.showWebView && (
|
||||
<View
|
||||
style={
|
||||
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
|
||||
}
|
||||
onLayout={this.checkOrientation}
|
||||
{this.state.showImageViewer && (
|
||||
<ImageViewer
|
||||
style={StyleSheet.flatten(filePageStyle.viewer)}
|
||||
imageUrls={this.state.imageUrls}
|
||||
renderIndicator={() => null}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!this.state.showWebView && (
|
||||
<View
|
||||
style={
|
||||
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
|
||||
}
|
||||
onLayout={this.checkOrientation}
|
||||
>
|
||||
<View style={filePageStyle.mediaContainer}>
|
||||
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
|
||||
<FileItemMedia
|
||||
duration={duration}
|
||||
style={filePageStyle.thumbnail}
|
||||
title={title}
|
||||
thumbnail={thumbnail}
|
||||
/>
|
||||
)}
|
||||
{(!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded && (
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={filePageStyle.loading} />
|
||||
)}
|
||||
{((isPlayable && !completed && !canLoadMedia) ||
|
||||
canOpen ||
|
||||
(!completed && !this.state.streamingMode)) &&
|
||||
!this.state.downloadPressed && (
|
||||
<FileDownloadButton
|
||||
uri={uri}
|
||||
style={filePageStyle.downloadButton}
|
||||
openFile={openFile}
|
||||
isPlayable={isPlayable}
|
||||
isViewable={isViewable}
|
||||
onPlay={this.onFileDownloadButtonPlayed}
|
||||
onView={() => this.setState({ downloadPressed: true })}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
|
||||
/>
|
||||
)}
|
||||
{!fileInfo && (
|
||||
<FilePrice
|
||||
uri={uri}
|
||||
style={filePageStyle.filePriceContainer}
|
||||
textStyle={filePageStyle.filePriceText}
|
||||
/>
|
||||
)}
|
||||
|
||||
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
|
||||
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<View
|
||||
style={playerBgStyle}
|
||||
ref={ref => {
|
||||
this.playerBackground = ref;
|
||||
}}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode && (
|
||||
<View style={fsPlayerBgStyle} />
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<MediaPlayer
|
||||
claim={claim}
|
||||
assignPlayer={ref => {
|
||||
this.player = ref;
|
||||
}}
|
||||
uri={uri}
|
||||
source={this.playerUriForFileInfo(fileInfo)}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onBackButtonPressed={this.onBackButtonPressed}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
onPlaybackFinished={this.onPlaybackFinished}
|
||||
thumbnail={thumbnail}
|
||||
position={position}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showActions && showFileActions && (
|
||||
<View style={filePageStyle.actions}>
|
||||
{showFileActions && (
|
||||
<View style={filePageStyle.fileActions}>
|
||||
{canEdit && (
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.editButton]}
|
||||
theme={'light'}
|
||||
icon={'edit'}
|
||||
text={'Edit'}
|
||||
onPress={this.onEditPressed}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(completed || canEdit) && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
theme={'light'}
|
||||
icon={'trash-alt'}
|
||||
text={'Delete'}
|
||||
onPress={this.onDeletePressed}
|
||||
/>
|
||||
)}
|
||||
{!completed &&
|
||||
fileInfo &&
|
||||
!fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
icon={'stop'}
|
||||
theme={'light'}
|
||||
text={'Stop Download'}
|
||||
onPress={this.onStopDownloadPressed}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<ScrollView
|
||||
style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
ref={ref => {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
>
|
||||
<View style={filePageStyle.mediaContainer}>
|
||||
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
|
||||
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={thumbnail} />
|
||||
)}
|
||||
{(!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded && (
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />
|
||||
)}
|
||||
{((isPlayable && !completed && !canLoadMedia) ||
|
||||
canOpen ||
|
||||
(!completed && !this.state.streamingMode)) &&
|
||||
!this.state.downloadPressed && (
|
||||
<FileDownloadButton
|
||||
uri={uri}
|
||||
style={filePageStyle.downloadButton}
|
||||
openFile={openFile}
|
||||
isPlayable={isPlayable}
|
||||
isViewable={isViewable}
|
||||
onPlay={this.onFileDownloadButtonPlayed}
|
||||
onView={() => this.setState({ downloadPressed: true })}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
|
||||
/>
|
||||
)}
|
||||
{!fileInfo && (
|
||||
<FilePrice
|
||||
uri={uri}
|
||||
style={filePageStyle.filePriceContainer}
|
||||
textStyle={filePageStyle.filePriceText}
|
||||
/>
|
||||
)}
|
||||
<TouchableWithoutFeedback
|
||||
style={filePageStyle.titleTouch}
|
||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
||||
>
|
||||
<View style={filePageStyle.titleRow}>
|
||||
<Text style={filePageStyle.title} selectable>
|
||||
{title}
|
||||
</Text>
|
||||
{isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
|
||||
<View style={filePageStyle.descriptionToggle}>
|
||||
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
|
||||
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
|
||||
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
|
||||
<View style={filePageStyle.largeButtonsRow}>
|
||||
<TouchableOpacity style={filePageStyle.largeButton} onPress={this.handleSharePress}>
|
||||
<Icon name={'share-alt'} size={20} style={filePageStyle.largeButtonIcon} />
|
||||
<Text style={filePageStyle.largeButtonText}>Share</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={filePageStyle.largeButton}
|
||||
onPress={() => this.setState({ showTipView: true })}
|
||||
>
|
||||
<Icon name={'gift'} size={20} style={filePageStyle.largeButtonIcon} />
|
||||
<Text style={filePageStyle.largeButtonText}>Tip</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
style={filePageStyle.largeButton}
|
||||
onPress={() => Linking.openURL(`https://lbry.com/dmca/${claim.claim_id}`)}
|
||||
>
|
||||
<Icon name={'flag'} size={20} style={filePageStyle.largeButtonIcon} />
|
||||
<Text style={filePageStyle.largeButtonText}>Report</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<View
|
||||
style={playerBgStyle}
|
||||
ref={ref => {
|
||||
this.playerBackground = ref;
|
||||
}}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
|
||||
this.state.fullscreenMode && <View style={fsPlayerBgStyle} />}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<MediaPlayer
|
||||
claim={claim}
|
||||
assignPlayer={ref => {
|
||||
this.player = ref;
|
||||
}}
|
||||
uri={uri}
|
||||
source={this.playerUriForFileInfo(fileInfo)}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onBackButtonPressed={this.onBackButtonPressed}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
onPlaybackFinished={this.onPlaybackFinished}
|
||||
thumbnail={thumbnail}
|
||||
position={position}
|
||||
/>
|
||||
|
||||
<View style={filePageStyle.channelRow}>
|
||||
<View style={filePageStyle.publishInfo}>
|
||||
{channelName && (
|
||||
<Link
|
||||
style={filePageStyle.channelName}
|
||||
selectable
|
||||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!channelName && (
|
||||
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
|
||||
Anonymous
|
||||
</Text>
|
||||
)}
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
textStyle={filePageStyle.publishDateText}
|
||||
uri={uri}
|
||||
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
|
||||
show={DateTime.SHOW_DATE}
|
||||
/>
|
||||
</View>
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
{false && ((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
|
||||
theme={'light'}
|
||||
icon={'download'}
|
||||
onPress={this.onSaveFilePressed}
|
||||
/>
|
||||
)}
|
||||
{channelName && (
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
hideText={false}
|
||||
/>
|
||||
)}
|
||||
{channelName && (
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{this.state.showTipView && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView && (
|
||||
<View style={filePageStyle.tipCard}>
|
||||
<View style={filePageStyle.row}>
|
||||
<View style={filePageStyle.amountRow}>
|
||||
<TextInput
|
||||
editable={!this.state.sendTipStarted}
|
||||
ref={ref => (this.tipAmountInput = ref)}
|
||||
onChangeText={value => this.setState({ tipAmount: value })}
|
||||
underlineColorAndroid={Colors.NextLbryGreen}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.tipAmount}
|
||||
selectTextOnFocus
|
||||
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
|
||||
/>
|
||||
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
|
||||
</View>
|
||||
{this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
|
||||
<Link
|
||||
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
|
||||
text={'Cancel'}
|
||||
onPress={() => this.setState({ showTipView: false })}
|
||||
/>
|
||||
<Button
|
||||
text={'Send a tip'}
|
||||
style={[filePageStyle.button, filePageStyle.sendButton]}
|
||||
disabled={!canSendTip || this.state.sendTipStarted}
|
||||
onPress={this.handleSendTip}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{showActions && showFileActions && (
|
||||
<View style={filePageStyle.actions}>
|
||||
{showFileActions && (
|
||||
<View style={filePageStyle.fileActions}>
|
||||
{completed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
theme={'light'}
|
||||
icon={'trash'}
|
||||
text={'Delete'}
|
||||
onPress={this.onDeletePressed}
|
||||
/>
|
||||
)}
|
||||
{!completed &&
|
||||
fileInfo &&
|
||||
!fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
icon={'stop'}
|
||||
theme={'light'}
|
||||
text={'Stop Download'}
|
||||
onPress={this.onStopDownloadPressed}
|
||||
/>
|
||||
)}
|
||||
{this.state.showDescription && description && description.length > 0 && (
|
||||
<View style={filePageStyle.divider} />
|
||||
)}
|
||||
{this.state.showDescription && description && (
|
||||
<View>
|
||||
<Text style={filePageStyle.description} selectable>
|
||||
{this.linkify(description)}
|
||||
</Text>
|
||||
{tags && tags.length > 0 && (
|
||||
<View style={filePageStyle.tagContainer}>
|
||||
<Text style={filePageStyle.tagTitle}>Tags</Text>
|
||||
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<ScrollView
|
||||
style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
ref={ref => {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
>
|
||||
<TouchableWithoutFeedback
|
||||
style={filePageStyle.titleTouch}
|
||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
||||
>
|
||||
<View style={filePageStyle.titleRow}>
|
||||
<Text style={filePageStyle.title} selectable>
|
||||
{title}
|
||||
</Text>
|
||||
<View style={filePageStyle.descriptionToggle}>
|
||||
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
{channelName && (
|
||||
<View style={filePageStyle.channelRow}>
|
||||
<View style={filePageStyle.publishInfo}>
|
||||
<Link
|
||||
style={filePageStyle.channelName}
|
||||
selectable
|
||||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
textStyle={filePageStyle.publishDateText}
|
||||
uri={uri}
|
||||
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
|
||||
show={DateTime.SHOW_DATE}
|
||||
/>
|
||||
</View>
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
{false &&
|
||||
((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
|
||||
theme={'light'}
|
||||
icon={'download'}
|
||||
onPress={this.onSaveFilePressed}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.tipButton]}
|
||||
theme={'light'}
|
||||
icon={'gift'}
|
||||
onPress={() => this.setState({ showTipView: true })}
|
||||
/>
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
hideText={false}
|
||||
/>
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{this.state.showTipView && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView && (
|
||||
<View style={filePageStyle.tipCard}>
|
||||
<View style={filePageStyle.row}>
|
||||
<View style={filePageStyle.amountRow}>
|
||||
<TextInput
|
||||
ref={ref => (this.tipAmountInput = ref)}
|
||||
onChangeText={value => this.setState({ tipAmount: value })}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.tipAmount}
|
||||
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
|
||||
/>
|
||||
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
|
||||
</View>
|
||||
<Link
|
||||
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
|
||||
text={'Cancel'}
|
||||
onPress={() => this.setState({ showTipView: false })}
|
||||
/>
|
||||
<Button
|
||||
text={'Send a tip'}
|
||||
style={[filePageStyle.button, filePageStyle.sendButton]}
|
||||
disabled={!canSendTip}
|
||||
onPress={this.handleSendTip}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{costInfo && parseFloat(costInfo.cost) > balance && !fileInfo && (
|
||||
<FileRewardsDriver navigation={navigation} />
|
||||
)}
|
||||
|
||||
{this.state.showDescription && description && description.length > 0 && (
|
||||
<View style={filePageStyle.divider} />
|
||||
)}
|
||||
{this.state.showDescription && description && (
|
||||
<View>
|
||||
<Text style={filePageStyle.description} selectable>
|
||||
{this.linkify(description)}
|
||||
</Text>
|
||||
{tags && tags.length > 0 && (
|
||||
<View style={filePageStyle.tagContainer}>
|
||||
<Text style={filePageStyle.tagTitle}>Tags</Text>
|
||||
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{costInfo && parseFloat(costInfo.cost) > balance && <FileRewardsDriver navigation={navigation} />}
|
||||
|
||||
<View onLayout={this.setRelatedContentPosition} />
|
||||
<RelatedContent navigation={navigation} uri={uri} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
<View onLayout={this.setRelatedContentPosition} />
|
||||
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return innerContent;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
doAuthenticate,
|
||||
doCheckSync,
|
||||
doGetSync,
|
||||
doSetDefaultAccount,
|
||||
doSyncApply,
|
||||
doUserEmailNew,
|
||||
doUserResendVerificationEmail,
|
||||
@@ -41,12 +40,11 @@ const select = state => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
|
||||
authenticate: (appVersion, os, firebaseToken) => dispatch(doAuthenticate(appVersion, os, firebaseToken)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
||||
getSync: password => dispatch(doGetSync(password)),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
checkSync: () => dispatch(doCheckSync()),
|
||||
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
View,
|
||||
} from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
|
||||
@@ -45,8 +45,8 @@ class SkipAccountPage extends React.PureComponent {
|
||||
/>
|
||||
</View>
|
||||
<Text style={firstRunStyle.rowParagraph}>
|
||||
I understand that by uninstalling LBRY I will lose any balances or published content with no recovery
|
||||
option.
|
||||
I understand that by uninstalling LBRY I will lose any balances or published content with no recovery option
|
||||
if it is not backed up manually (see wallet page)
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
||||
@@ -62,7 +62,14 @@ class WalletPage extends React.PureComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { onPasswordChanged, onWalletViewLayout, getSyncIsPending, hasSyncedWallet, syncApplyIsPending } = this.props;
|
||||
const {
|
||||
onPasswordChanged,
|
||||
onWalletViewLayout,
|
||||
getSyncIsPending,
|
||||
hasSyncedWallet,
|
||||
syncApplyIsPending,
|
||||
syncApplyStarted,
|
||||
} = this.props;
|
||||
|
||||
let content;
|
||||
if (!this.state.walletReady || !this.state.hasCheckedSync || getSyncIsPending) {
|
||||
@@ -72,11 +79,11 @@ class WalletPage extends React.PureComponent {
|
||||
<Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text>
|
||||
</View>
|
||||
);
|
||||
} else if (syncApplyIsPending) {
|
||||
} else if (syncApplyStarted || syncApplyIsPending) {
|
||||
content = (
|
||||
<View style={firstRunStyle.centered}>
|
||||
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
|
||||
<Text style={firstRunStyle.paragraph}>Validating password...</Text>
|
||||
<Text style={firstRunStyle.paragraph}>{syncApplyIsPending ? 'Validating password' : 'Synchronizing'}...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
|
||||
import { ActivityIndicator, NativeModules, Platform, Text, View } from 'react-native';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
|
||||
class WelcomePage extends React.PureComponent {
|
||||
@@ -25,7 +25,7 @@ class WelcomePage extends React.PureComponent {
|
||||
} else {
|
||||
// first_user_auth because it's the first time
|
||||
AsyncStorage.getItem(Constants.KEY_FIRST_USER_AUTH).then(firstUserAuth => {
|
||||
if ('true' !== firstUserAuth) {
|
||||
if (firstUserAuth !== 'true') {
|
||||
// first_user_auth
|
||||
NativeModules.Firebase.track('first_user_auth', null);
|
||||
AsyncStorage.setItem(Constants.KEY_FIRST_USER_AUTH, 'true');
|
||||
@@ -44,31 +44,39 @@ class WelcomePage extends React.PureComponent {
|
||||
}
|
||||
|
||||
startAuthenticating = () => {
|
||||
const { authenticate } = this.props;
|
||||
this.setState({ authenticationStarted: true, authenticationFailed: false });
|
||||
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
||||
Lbry.status()
|
||||
.then(info => {
|
||||
this.setState({ sdkStarted: true });
|
||||
|
||||
authenticate(appVersion, Platform.OS);
|
||||
})
|
||||
.catch(error => {
|
||||
if (this.state.statusTries >= WelcomePage.MAX_STATUS_TRIES) {
|
||||
this.setState({ authenticationFailed: true });
|
||||
|
||||
// sdk_start_failed
|
||||
NativeModules.Firebase.track('sdk_start_failed', null);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startAuthenticating();
|
||||
this.setState({ statusTries: this.state.statusTries + 1 });
|
||||
}, 1000); // Retry every second for a maximum of MAX_STATUS_TRIES tries (60 seconds)
|
||||
}
|
||||
NativeModules.Firebase.getMessagingToken()
|
||||
.then(firebaseToken => this.performAuthenticate(appVersion, firebaseToken))
|
||||
.catch(() => {
|
||||
this.performAuthenticate(appVersion); /* proceed without firebase */
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
performAuthenticate(appVersion, firebaseToken) {
|
||||
const { authenticate } = this.props;
|
||||
Lbry.status()
|
||||
.then(info => {
|
||||
this.setState({ sdkStarted: true });
|
||||
|
||||
authenticate(appVersion, Platform.OS, firebaseToken);
|
||||
})
|
||||
.catch(error => {
|
||||
if (this.state.statusTries >= WelcomePage.MAX_STATUS_TRIES) {
|
||||
this.setState({ authenticationFailed: true });
|
||||
|
||||
// sdk_start_failed
|
||||
NativeModules.Firebase.track('sdk_start_failed', null);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startAuthenticating();
|
||||
this.setState({ statusTries: this.state.statusTries + 1 });
|
||||
}, 1000); // Retry every second for a maximum of MAX_STATUS_TRIES tries (60 seconds)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { authenticating, authToken, onWelcomePageLayout } = this.props;
|
||||
|
||||
|
||||
+51
-24
@@ -4,7 +4,7 @@ import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import WalletPage from './internal/wallet-page';
|
||||
import WelcomePage from './internal/welcome-page';
|
||||
import EmailCollectPage from './internal/email-collect-page';
|
||||
@@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
isEmailVerified: false,
|
||||
skipAccountConfirmed: false,
|
||||
showBottomContainer: false,
|
||||
walletPassword: null,
|
||||
walletPassword: '',
|
||||
syncApplyStarted: false,
|
||||
};
|
||||
|
||||
@@ -51,6 +51,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
this.setState({ isFirstRun: firstRun });
|
||||
|
||||
if (firstRun) {
|
||||
NativeModules.Firebase.setCurrentScreen('First Run');
|
||||
this.setState({ currentPage: FirstRunScreen.pages[0] });
|
||||
} else {
|
||||
// Not the first run. Navigate to the splash screen right away
|
||||
@@ -65,7 +66,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { emailNewErrorMessage, emailNewPending, syncApplyErrorMessage, syncApplyIsPending, user } = nextProps;
|
||||
const { notify, isApplyingSync, setClientSetting, setDefaultAccount } = this.props;
|
||||
const { notify, isApplyingSync, setClientSetting } = this.props;
|
||||
|
||||
if (this.state.emailSubmitted && !emailNewPending) {
|
||||
this.setState({ emailSubmitted: false });
|
||||
@@ -73,23 +74,40 @@ class FirstRunScreen extends React.PureComponent {
|
||||
notify({ message: String(emailNewErrorMessage), isError: true });
|
||||
} else {
|
||||
// Request successful. Navigate to email verify page.
|
||||
NativeModules.Firebase.track('email_added', { email: this.state.email });
|
||||
this.showPage(Constants.FIRST_RUN_PAGE_EMAIL_VERIFY);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state.syncApplyStarted && !syncApplyIsPending) {
|
||||
this.setState({ syncApplyStarted: false });
|
||||
if (syncApplyErrorMessage && syncApplyErrorMessage.trim().length > 0) {
|
||||
notify({ message: syncApplyErrorMessage, isError: true });
|
||||
this.setState({ showBottomContainer: true });
|
||||
this.setState({ showBottomContainer: true, syncApplyStarted: false });
|
||||
} else {
|
||||
// password successfully verified
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
|
||||
}
|
||||
setDefaultAccount();
|
||||
NativeModules.UtilityModule.setSecureValue(
|
||||
Constants.KEY_WALLET_PASSWORD,
|
||||
this.state.walletPassword ? this.state.walletPassword : ''
|
||||
);
|
||||
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
this.closeFinalPage();
|
||||
Lbry.wallet_status().then(status => {
|
||||
// unlock the wallet
|
||||
if (status.is_locked) {
|
||||
Lbry.wallet_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' }).then(
|
||||
unlocked => {
|
||||
if (unlocked) {
|
||||
this.closeFinalPage();
|
||||
} else {
|
||||
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// wallet not locked. close final page
|
||||
this.closeFinalPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +133,9 @@ class FirstRunScreen extends React.PureComponent {
|
||||
const { navigation } = this.props;
|
||||
const resetAction = StackActions.reset({
|
||||
index: 0,
|
||||
actions: [NavigationActions.navigate({ routeName: 'Splash', params: { launchUri: this.state.launchUri } })],
|
||||
actions: [NavigationActions.navigate({ routeName: 'Splash', params: { launchUri: this.state.launchUrl } })],
|
||||
});
|
||||
navigation.dispatch(resetAction);
|
||||
setTimeout(() => navigation.dispatch(resetAction), 1000);
|
||||
}
|
||||
|
||||
handleLeftButtonPressed = () => {
|
||||
@@ -218,6 +236,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
|
||||
closeFinalPage() {
|
||||
// Final page. Let the app know that first run experience is completed.
|
||||
this.setState({ syncApplyStarted: false });
|
||||
if (NativeModules.FirstRun) {
|
||||
NativeModules.FirstRun.firstRunCompleted();
|
||||
}
|
||||
@@ -228,7 +247,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
|
||||
onEmailChanged = email => {
|
||||
this.setState({ email });
|
||||
if (Constants.FIRST_RUN_PAGE_EMAIL_COLLECT == this.state.currentPage) {
|
||||
if (Constants.FIRST_RUN_PAGE_EMAIL_COLLECT === this.state.currentPage) {
|
||||
this.setState({ showSkip: !email || email.trim().length === 0 });
|
||||
} else {
|
||||
this.setState({ showSkip: false });
|
||||
@@ -236,14 +255,14 @@ class FirstRunScreen extends React.PureComponent {
|
||||
};
|
||||
|
||||
onEmailViewLayout = phase => {
|
||||
if ('collect' === phase) {
|
||||
if (phase === 'collect') {
|
||||
if (!this.state.emailCollectTracked) {
|
||||
// we only want to track this once
|
||||
this.setState({ emailCollectTracked: true }, () =>
|
||||
NativeModules.Firebase.track('first_run_email_collect', null)
|
||||
);
|
||||
}
|
||||
} else if ('verify' === phase) {
|
||||
} else if (phase === 'verify') {
|
||||
NativeModules.Firebase.track('first_run_email_verify', null);
|
||||
}
|
||||
|
||||
@@ -251,7 +270,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
};
|
||||
|
||||
onWalletPasswordChanged = password => {
|
||||
this.setState({ walletPassword: password });
|
||||
this.setState({ walletPassword: password !== null ? password : '' });
|
||||
};
|
||||
|
||||
onWalletViewLayout = () => {
|
||||
@@ -280,13 +299,20 @@ class FirstRunScreen extends React.PureComponent {
|
||||
const { getSync, setClientSetting } = this.props;
|
||||
if (NativeModules.UtilityModule) {
|
||||
const newPassword = this.state.walletPassword ? this.state.walletPassword : '';
|
||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, newPassword);
|
||||
Lbry.account_encrypt({ new_password: newPassword }).then(() => {
|
||||
// fresh account, new password set
|
||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_WALLET_PASSWORD, newPassword);
|
||||
if (newPassword.trim().length === 0) {
|
||||
// blank password. Do not encrypt
|
||||
getSync(newPassword);
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
this.closeFinalPage();
|
||||
});
|
||||
} else {
|
||||
Lbry.wallet_encrypt({ new_password: newPassword }).then(() => {
|
||||
// fresh account, new password set
|
||||
getSync(newPassword);
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
this.closeFinalPage();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -349,6 +375,7 @@ class FirstRunScreen extends React.PureComponent {
|
||||
hasSyncedWallet={hasSyncedWallet}
|
||||
getSyncIsPending={getSyncIsPending}
|
||||
syncApplyIsPending={syncApplyIsPending}
|
||||
syncApplyStarted={this.state.syncApplyStarted}
|
||||
onWalletViewLayout={this.onWalletViewLayout}
|
||||
onPasswordChanged={this.onWalletPasswordChanged}
|
||||
/>
|
||||
@@ -402,10 +429,10 @@ class FirstRunScreen extends React.PureComponent {
|
||||
|
||||
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage &&
|
||||
Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && (
|
||||
<Text style={firstRunStyle.buttonText}>
|
||||
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? 'Use LBRY' : 'Continue'} »
|
||||
</Text>
|
||||
)}
|
||||
<Text style={firstRunStyle.buttonText}>
|
||||
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? 'Use LBRY' : 'Continue'} »
|
||||
</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@@ -3,25 +3,34 @@ import {
|
||||
doPublish,
|
||||
doResolveUri,
|
||||
doToast,
|
||||
doUploadThumbnail,
|
||||
doUpdatePublishForm,
|
||||
selectBalance,
|
||||
selectPublishFormValues,
|
||||
} from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import Constants from 'constants';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { doUpdatePublishFormState, doClearPublishFormState } from 'redux/actions/form';
|
||||
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectPublishFormState, selectHasPublishFormState } from 'redux/selectors/form';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PublishPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
balance: selectBalance(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
hasFormState: selectHasPublishFormState(state),
|
||||
publishFormState: selectPublishFormState(state),
|
||||
publishFormValues: selectPublishFormValues(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
notify: data => dispatch(doToast(data)),
|
||||
uploadThumbnail: (filePath, fsAdapter) => dispatch(doUploadThumbnail(filePath, null, fsAdapter)),
|
||||
publish: params => dispatch(doPublish(params)),
|
||||
clearPublishFormState: () => dispatch(doClearPublishFormState()),
|
||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
|
||||
publish: (success, fail) => dispatch(doPublish(success, fail)),
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)),
|
||||
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
|
||||
+648
-223
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,11 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doCheckPendingPublishes, selectMyClaimUrisWithoutChannels, selectIsFetchingClaimListMine } from 'lbry-redux';
|
||||
import {
|
||||
doAbandonClaim,
|
||||
doCheckPendingPublishes,
|
||||
doFetchClaimListMine,
|
||||
selectMyClaimUrisWithoutChannels,
|
||||
selectIsFetchingClaimListMine,
|
||||
} from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PublishesPage from './view';
|
||||
@@ -10,6 +16,8 @@ const select = state => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
|
||||
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
|
||||
checkPendingPublishes: () => dispatch(doCheckPendingPublishes()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISHES)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
|
||||
+133
-19
@@ -1,20 +1,27 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { ActivityIndicator, Alert, FlatList, NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import EmptyStateView from 'component/emptyStateView';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import UriBar from 'component/uriBar';
|
||||
import publishStyle from 'styles/publish';
|
||||
import { __ } from 'utils/helper';
|
||||
import { __, navigateToUri } from 'utils/helper';
|
||||
|
||||
class PublishesPage extends React.PureComponent {
|
||||
state = {
|
||||
selectionMode: false,
|
||||
selectedUris: [],
|
||||
selectedClaimsMap: {},
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -23,48 +30,155 @@ class PublishesPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { checkPendingPublishes, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
|
||||
if (Constants.DRAWER_ROUTE_PUBLISHES === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
checkPendingPublishes();
|
||||
NativeModules.Firebase.setCurrentScreen('Publishes').then(result => {
|
||||
fetchMyClaims();
|
||||
checkPendingPublishes();
|
||||
});
|
||||
};
|
||||
|
||||
addOrRemoveItem = (uri, claim) => {
|
||||
const { selectedClaimsMap } = this.state;
|
||||
let selectedUris = [...this.state.selectedUris];
|
||||
|
||||
if (selectedUris.includes(uri)) {
|
||||
delete selectedClaimsMap[uri];
|
||||
selectedUris.splice(selectedUris.indexOf(uri), 1);
|
||||
} else {
|
||||
selectedClaimsMap[uri] = claim;
|
||||
selectedUris.push(uri);
|
||||
}
|
||||
|
||||
this.setState({ selectionMode: selectedUris.length > 0, selectedUris, selectedClaimsMap });
|
||||
};
|
||||
|
||||
handleSelectItem = (uri, claim) => {
|
||||
this.addOrRemoveItem(uri, claim);
|
||||
};
|
||||
|
||||
handleItemLongPress = (uri, claim) => {
|
||||
this.addOrRemoveItem(uri, claim);
|
||||
};
|
||||
|
||||
onExitSelectionMode = () => {
|
||||
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} });
|
||||
};
|
||||
|
||||
onEditActionPressed = () => {
|
||||
const { navigation } = this.props;
|
||||
const { selectedClaimsMap, selectedUris } = this.state;
|
||||
// only 1 item can be edited (and edit button should be visible only if there is a single selection)
|
||||
const claim = selectedClaimsMap[selectedUris[0]];
|
||||
this.onExitSelectionMode();
|
||||
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
|
||||
};
|
||||
|
||||
onDeleteActionPressed = () => {
|
||||
const { abandonClaim } = this.props;
|
||||
const { selectedClaimsMap } = this.state;
|
||||
|
||||
// show confirm alert
|
||||
Alert.alert(
|
||||
__('Unpublish'),
|
||||
__('Are you sure you want to unpublish the selected content?'),
|
||||
[
|
||||
{ text: __('No') },
|
||||
{
|
||||
text: __('Yes'),
|
||||
onPress: () => {
|
||||
const uris = Object.keys(selectedClaimsMap);
|
||||
uris.forEach(uri => {
|
||||
const { txid, nout } = selectedClaimsMap[uri];
|
||||
abandonClaim(txid, nout);
|
||||
});
|
||||
this.onExitSelectionMode();
|
||||
},
|
||||
},
|
||||
],
|
||||
{ cancelable: true }
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { fetching, navigation, uris } = this.props;
|
||||
const { selectionMode, selectedUris } = this.state;
|
||||
|
||||
return (
|
||||
<View style={publishStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
<UriBar
|
||||
allowEdit
|
||||
navigation={navigation}
|
||||
selectionMode={selectionMode}
|
||||
selectedItemCount={selectedUris.length}
|
||||
onDeleteActionPressed={this.onDeleteActionPressed}
|
||||
onEditActionPressed={this.onEditActionPressed}
|
||||
onExitSelectionMode={this.onExitSelectionMode}
|
||||
/>
|
||||
{fetching && (
|
||||
<View style={publishStyle.centered}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size={'large'} color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!fetching && (!uris || uris.length === 0) && (
|
||||
<View style={publishStyle.noPublishes}>
|
||||
<Text style={publishStyle.noPublishText}>
|
||||
{__('It looks like you have not published anything to LBRY yet.')}
|
||||
</Text>
|
||||
<Button
|
||||
style={publishStyle.publishNowButton}
|
||||
text={__('Publish something new')}
|
||||
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
|
||||
/>
|
||||
</View>
|
||||
<EmptyStateView
|
||||
message={__('It looks like you have not\npublished any content to LBRY yet.')}
|
||||
buttonText={__('Publish something new')}
|
||||
onButtonPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
|
||||
/>
|
||||
)}
|
||||
|
||||
{uris && uris.length > 0 && (
|
||||
<FlatList
|
||||
style={publishStyle.publishesList}
|
||||
contentContainerStyle={publishStyle.publishesScrollPadding}
|
||||
extraData={this.state}
|
||||
initialNumToRender={8}
|
||||
maxToRenderPerBatch={24}
|
||||
removeClippedSubviews
|
||||
ListFooterComponent={
|
||||
<View style={publishStyle.publishesFooter}>
|
||||
<Button
|
||||
style={publishStyle.publishesFooterButton}
|
||||
text={__('Publish something new')}
|
||||
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
|
||||
/>
|
||||
</View>
|
||||
}
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem hideChannel key={item} uri={item} style={publishStyle.listItem} navigation={navigation} />
|
||||
<FileListItem
|
||||
key={item}
|
||||
uri={item}
|
||||
style={publishStyle.listItem}
|
||||
selected={selectedUris.includes(item)}
|
||||
onPress={claim => {
|
||||
if (selectionMode) {
|
||||
this.handleSelectItem(item, claim);
|
||||
} else {
|
||||
// TODO: when shortUrl is available for my claims, navigate to that URL instead
|
||||
navigateToUri(navigation, item);
|
||||
}
|
||||
}}
|
||||
onLongPress={claim => this.handleItemLongPress(item, claim)}
|
||||
navigation={navigation}
|
||||
/>
|
||||
)}
|
||||
data={uris}
|
||||
keyExtractor={(item, index) => item}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { ActivityIndicator, NativeModules, ScrollView, Text, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Link from 'component/link';
|
||||
import CustomRewardCard from 'component/customRewardCard';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
@@ -28,7 +28,7 @@ class RewardsPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -42,6 +42,8 @@ class RewardsPage extends React.PureComponent {
|
||||
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Rewards');
|
||||
|
||||
fetchRewards();
|
||||
|
||||
this.setState({
|
||||
@@ -87,7 +89,7 @@ class RewardsPage extends React.PureComponent {
|
||||
// claim new_user and new_mobile rewards
|
||||
for (let i = 0; i < rewards.length; i++) {
|
||||
const { reward_type: type } = rewards[i];
|
||||
if ('new_user' === type || 'new_mobile' === type) {
|
||||
if (type === 'new_user' || type === 'new_mobile') {
|
||||
claimReward(rewards[i]);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +129,7 @@ class RewardsPage extends React.PureComponent {
|
||||
if (fetching) {
|
||||
return (
|
||||
<View style={rewardStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
<Text style={rewardStyle.infoText}>Fetching rewards...</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -10,19 +10,21 @@ import {
|
||||
} from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import SearchPage from './view';
|
||||
|
||||
const numSearchResults = 50;
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
isSearching: selectIsSearching(state),
|
||||
query: selectSearchValue(state),
|
||||
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, 25)(state))(state),
|
||||
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
|
||||
urisByQuery: selectSearchUrisByQuery(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: query => dispatch(doSearch(query, 25)),
|
||||
search: query => dispatch(doSearch(query, numSearchResults)),
|
||||
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
|
||||
+51
-50
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Lbry, parseURI, normalizeURI, isURIValid } from 'lbry-redux';
|
||||
import { ActivityIndicator, Button, Text, TextInput, View, ScrollView } from 'react-native';
|
||||
import { ActivityIndicator, Button, FlatList, NativeModules, Text, TextInput, View } from 'react-native';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
@@ -24,7 +24,7 @@ class SearchPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -37,15 +37,16 @@ class SearchPage extends React.PureComponent {
|
||||
const { pushDrawerStack, setPlayerVisible, query, search } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
|
||||
const searchQuery = query || this.getSearchQuery();
|
||||
if (searchQuery && searchQuery.trim().length > 0) {
|
||||
this.setState({
|
||||
currentQuery: searchQuery,
|
||||
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
|
||||
});
|
||||
search(searchQuery);
|
||||
}
|
||||
NativeModules.Firebase.setCurrentScreen('Search').then(result => {
|
||||
const searchQuery = query || this.getSearchQuery();
|
||||
if (searchQuery && searchQuery.trim().length > 0) {
|
||||
this.setState({
|
||||
currentQuery: searchQuery,
|
||||
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
|
||||
});
|
||||
search(searchQuery);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -83,55 +84,55 @@ class SearchPage extends React.PureComponent {
|
||||
search(keywords);
|
||||
};
|
||||
|
||||
listEmptyComponent = () => {
|
||||
const { query } = this.props;
|
||||
return (
|
||||
<View style={searchStyle.noResults}>
|
||||
<Text style={searchStyle.noResultsText}>
|
||||
There are no results to display for <Text style={searchStyle.boldText}>{query}</Text>. Please try a different
|
||||
search term.
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
listHeaderComponent = () => {
|
||||
const { navigation } = this.props;
|
||||
const { currentUri } = this.state;
|
||||
|
||||
return (
|
||||
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { isSearching, navigation, query, uris, urisByQuery } = this.props;
|
||||
|
||||
return (
|
||||
<View style={searchStyle.container}>
|
||||
<UriBar value={query} navigation={navigation} onSearchSubmitted={this.handleSearchSubmitted} />
|
||||
|
||||
{isSearching && (
|
||||
<View style={searchStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={searchStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!isSearching && (
|
||||
<ScrollView
|
||||
style={searchStyle.scrollContainer}
|
||||
contentContainerStyle={searchStyle.scrollPadding}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
>
|
||||
{this.state.currentUri && (
|
||||
<FileListItem
|
||||
key={this.state.currentUri}
|
||||
uri={this.state.currentUri}
|
||||
featuredResult={true}
|
||||
style={searchStyle.featuredResultItem}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, this.state.currentUri)}
|
||||
/>
|
||||
)}
|
||||
{uris && uris.length
|
||||
? uris.map(uri => (
|
||||
<FileListItem
|
||||
key={uri}
|
||||
uri={uri}
|
||||
style={searchStyle.resultItem}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, uri)}
|
||||
/>
|
||||
))
|
||||
: null}
|
||||
{(!uris || uris.length === 0) && (
|
||||
<View style={searchStyle.noResults}>
|
||||
<Text style={searchStyle.noResultsText}>
|
||||
There are no results to display for <Text style={searchStyle.boldText}>{query}</Text>. Please try a
|
||||
different search term.
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
)}
|
||||
<FlatList
|
||||
style={searchStyle.scrollContainer}
|
||||
contentContainerStyle={searchStyle.scrollPadding}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
data={uris}
|
||||
keyExtractor={(item, index) => item}
|
||||
initialNumToRender={10}
|
||||
maxToRenderPerBatch={20}
|
||||
removeClippedSubviews
|
||||
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
|
||||
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent() : null}
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem key={item} uri={item} style={searchStyle.resultItem} navigation={navigation} />
|
||||
)}
|
||||
/>
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/a
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectCurrentRoute, selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import SettingsPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -13,6 +13,7 @@ const select = state => ({
|
||||
drawerStack: selectDrawerStack(state),
|
||||
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
|
||||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
|
||||
showUriBarSuggestions: makeSelectClientSetting(SETTINGS.SHOW_URI_BAR_SUGGESTIONS)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import { Text, View, ScrollView, Switch, NativeModules } from 'react-native';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import settingsStyle from 'styles/settings';
|
||||
|
||||
@@ -15,7 +15,7 @@ class SettingsPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -28,6 +28,7 @@ class SettingsPage extends React.PureComponent {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Settings');
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -50,6 +51,7 @@ class SettingsPage extends React.PureComponent {
|
||||
navigation,
|
||||
popDrawerStack,
|
||||
showNsfw,
|
||||
showUriBarSuggestions,
|
||||
setClientSetting,
|
||||
} = this.props;
|
||||
|
||||
@@ -61,6 +63,7 @@ class SettingsPage extends React.PureComponent {
|
||||
<View style={settingsStyle.container}>
|
||||
<PageHeader title={'Settings'} onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
|
||||
<ScrollView style={settingsStyle.scrollContainer}>
|
||||
<Text style={settingsStyle.sectionTitle}>Content</Text>
|
||||
<View style={settingsStyle.row}>
|
||||
<View style={settingsStyle.switchText}>
|
||||
<Text style={settingsStyle.label}>Enable background media playback</Text>
|
||||
@@ -78,13 +81,29 @@ class SettingsPage extends React.PureComponent {
|
||||
|
||||
<View style={settingsStyle.row}>
|
||||
<View style={settingsStyle.switchText}>
|
||||
<Text style={settingsStyle.label}>Show NSFW content</Text>
|
||||
<Text style={settingsStyle.label}>Show mature content</Text>
|
||||
</View>
|
||||
<View style={settingsStyle.switchContainer}>
|
||||
<Switch value={showNsfw} onValueChange={value => setClientSetting(SETTINGS.SHOW_NSFW, value)} />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={settingsStyle.sectionDivider} />
|
||||
<Text style={settingsStyle.sectionTitle}>Search</Text>
|
||||
<View style={settingsStyle.row}>
|
||||
<View style={settingsStyle.switchText}>
|
||||
<Text style={settingsStyle.label}>Show URL suggestions</Text>
|
||||
</View>
|
||||
<View style={settingsStyle.switchContainer}>
|
||||
<Switch
|
||||
value={showUriBarSuggestions}
|
||||
onValueChange={value => setClientSetting(SETTINGS.SHOW_URI_BAR_SUGGESTIONS, value)}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={settingsStyle.sectionDivider} />
|
||||
<Text style={settingsStyle.sectionTitle}>Other</Text>
|
||||
<View style={settingsStyle.row}>
|
||||
<View style={settingsStyle.switchText}>
|
||||
<Text style={settingsStyle.label}>Keep the daemon background service running after closing the app</Text>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doBalanceSubscribe, doUpdateBlockHeight, doToast } from 'lbry-redux';
|
||||
import { doBalanceSubscribe, doUpdateBlockHeight, doPopulateSharedUserState, doToast } from 'lbry-redux';
|
||||
import {
|
||||
doAuthenticate,
|
||||
doBlackListedOutpointsSubscribe,
|
||||
doFilteredOutpointsSubscribe,
|
||||
doCheckSubscriptionsInit,
|
||||
doFetchMySubscriptions,
|
||||
doFetchRewardedContent,
|
||||
@@ -22,16 +23,18 @@ const select = state => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
|
||||
authenticate: (appVersion, os, firebaseToken) => dispatch(doAuthenticate(appVersion, os, firebaseToken)),
|
||||
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
|
||||
blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()),
|
||||
filteredOutpointsSubscribe: () => dispatch(doFilteredOutpointsSubscribe()),
|
||||
checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()),
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: callback => dispatch(doFetchMySubscriptions(callback)),
|
||||
getSync: password => dispatch(doGetSync(password)),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
|
||||
populateSharedUserState: settings => dispatch(doPopulateSharedUserState(settings)),
|
||||
updateBlockHeight: () => dispatch(doUpdateBlockHeight()),
|
||||
verifyUserEmail: (token, recaptcha) => dispatch(doUserEmailVerify(token, recaptcha)),
|
||||
verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)),
|
||||
|
||||
+67
-61
@@ -1,16 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { Lbry, doPreferenceGet } from 'lbry-redux';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import { decode as atob } from 'base-64';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import { navigateToUri, transformUrl } from 'utils/helper';
|
||||
import moment from 'moment';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
import ProgressBar from 'component/progressBar';
|
||||
import PropTypes from 'prop-types';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import splashStyle from 'styles/splash';
|
||||
|
||||
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
|
||||
@@ -37,12 +38,6 @@ class SplashScreen extends React.PureComponent {
|
||||
subscriptionsFetched: false,
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
if (NativeModules.DaemonServiceControl) {
|
||||
NativeModules.DaemonServiceControl.startService();
|
||||
}
|
||||
}
|
||||
|
||||
updateStatus() {
|
||||
Lbry.status().then(status => {
|
||||
this._updateStatusCallback(status);
|
||||
@@ -50,14 +45,14 @@ class SplashScreen extends React.PureComponent {
|
||||
}
|
||||
|
||||
navigateToMain = () => {
|
||||
const { navigation } = this.props;
|
||||
const { navigation, notify, verifyUserEmail, verifyUserEmailFailure } = this.props;
|
||||
const resetAction = StackActions.reset({
|
||||
index: 0,
|
||||
actions: [NavigationActions.navigate({ routeName: 'Main' })],
|
||||
});
|
||||
navigation.dispatch(resetAction);
|
||||
|
||||
const launchUrl = navigation.state.params.launchUrl || this.state.launchUrl;
|
||||
const launchUrl = navigation.state.params ? navigation.state.params.launchUrl : this.state.launchUrl;
|
||||
if (launchUrl) {
|
||||
if (launchUrl.startsWith('lbry://?verify=')) {
|
||||
let verification = {};
|
||||
@@ -81,23 +76,22 @@ class SplashScreen extends React.PureComponent {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
navigateToUri(navigation, launchUrl);
|
||||
navigateToUri(navigation, transformUrl(launchUrl));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { emailToVerify, getSync, setEmailToVerify, verifyUserEmail, verifyUserEmailFailure } = this.props;
|
||||
const { daemonReady, shouldAuthenticate } = this.state;
|
||||
const { user } = nextProps;
|
||||
|
||||
if (this.state.daemonReady && this.state.shouldAuthenticate && user && user.id) {
|
||||
if (daemonReady && shouldAuthenticate && user && user.id) {
|
||||
this.setState({ shouldAuthenticate: false }, () => {
|
||||
// user is authenticated, navigate to the main view
|
||||
if (user.has_verified_email) {
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
|
||||
if (walletPassword && walletPassword.trim().length > 0) {
|
||||
getSync(walletPassword);
|
||||
}
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
|
||||
getSync(walletPassword, () => this.getUserSettings());
|
||||
this.navigateToMain();
|
||||
});
|
||||
return;
|
||||
@@ -108,15 +102,28 @@ class SplashScreen extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
getUserSettings = () => {
|
||||
const { populateSharedUserState } = this.props;
|
||||
|
||||
doPreferenceGet(
|
||||
'shared',
|
||||
preference => {
|
||||
populateSharedUserState(preference);
|
||||
},
|
||||
error => {
|
||||
/* failed */
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
finishSplashScreen = () => {
|
||||
const {
|
||||
authenticate,
|
||||
balanceSubscribe,
|
||||
blacklistedOutpointsSubscribe,
|
||||
checkSubscriptionsInit,
|
||||
filteredOutpointsSubscribe,
|
||||
getSync,
|
||||
navigation,
|
||||
notify,
|
||||
updateBlockHeight,
|
||||
user,
|
||||
} = this.props;
|
||||
@@ -125,24 +132,21 @@ class SplashScreen extends React.PureComponent {
|
||||
// Leave the splash screen
|
||||
balanceSubscribe();
|
||||
blacklistedOutpointsSubscribe();
|
||||
filteredOutpointsSubscribe();
|
||||
checkSubscriptionsInit();
|
||||
updateBlockHeight();
|
||||
setInterval(() => {
|
||||
updateBlockHeight();
|
||||
}, BLOCK_HEIGHT_INTERVAL);
|
||||
|
||||
if (user && user.id && user.has_verified_email) {
|
||||
// user already authenticated
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
|
||||
if (walletPassword && walletPassword.trim().length > 0) {
|
||||
getSync(walletPassword);
|
||||
}
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
|
||||
getSync(walletPassword, () => this.getUserSettings());
|
||||
this.navigateToMain();
|
||||
});
|
||||
} else {
|
||||
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
||||
this.setState({ shouldAuthenticate: true });
|
||||
authenticate(appVersion, Platform.OS);
|
||||
NativeModules.Firebase.getMessagingToken()
|
||||
.then(firebaseToken => authenticate(appVersion, Platform.OS, firebaseToken))
|
||||
.catch(() => authenticate(appVersion, Platform.OS));
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -154,7 +158,10 @@ class SplashScreen extends React.PureComponent {
|
||||
|
||||
_updateStatusCallback(status) {
|
||||
const { fetchSubscriptions, getSync, setClientSetting } = this.props;
|
||||
const blockchainHeaders = status.blockchain_headers;
|
||||
const startupStatus = status.startup_status;
|
||||
const walletStatus = status.wallet;
|
||||
|
||||
// At the minimum, wallet should be started and blocks_behind equal to 0 before calling resolve
|
||||
const hasStarted = startupStatus.stream_manager && startupStatus.wallet && status.wallet.blocks_behind <= 0;
|
||||
if (hasStarted) {
|
||||
@@ -168,40 +175,40 @@ class SplashScreen extends React.PureComponent {
|
||||
isRunning: true,
|
||||
});
|
||||
|
||||
// For now, automatically unlock the wallet if a password is set so that downloads work
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
|
||||
if (password && password.trim().length > 0) {
|
||||
this.setState({
|
||||
message: 'Unlocking account',
|
||||
details: 'Decrypting wallet',
|
||||
});
|
||||
Lbry.wallet_status().then(secureWalletStatus => {
|
||||
// For now, automatically unlock the wallet if a password is set so that downloads work
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(password => {
|
||||
if (secureWalletStatus.is_locked) {
|
||||
this.setState({
|
||||
message: 'Unlocking account',
|
||||
details: 'Decrypting wallet',
|
||||
});
|
||||
|
||||
// unlock the wallet and then finish the splash screen
|
||||
Lbry.account_unlock({ password })
|
||||
.then(() => {
|
||||
this.setState({
|
||||
message: testingNetwork,
|
||||
details: waitingForResolution,
|
||||
});
|
||||
this.finishSplashScreen();
|
||||
})
|
||||
.catch(() => this.handleAccountUnlockFailed());
|
||||
return;
|
||||
} else {
|
||||
this.setState({
|
||||
message: testingNetwork,
|
||||
details: waitingForResolution,
|
||||
});
|
||||
this.finishSplashScreen();
|
||||
}
|
||||
// unlock the wallet and then finish the splash screen
|
||||
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
|
||||
if (unlocked) {
|
||||
this.setState({
|
||||
message: testingNetwork,
|
||||
details: waitingForResolution,
|
||||
});
|
||||
this.finishSplashScreen();
|
||||
} else {
|
||||
this.handleAccountUnlockFailed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
message: testingNetwork,
|
||||
details: waitingForResolution,
|
||||
});
|
||||
this.finishSplashScreen();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const blockchainHeaders = status.blockchain_headers;
|
||||
const walletStatus = status.wallet;
|
||||
|
||||
if (blockchainHeaders) {
|
||||
this.setState({
|
||||
isDownloadingHeaders: blockchainHeaders.downloading_headers,
|
||||
@@ -222,7 +229,7 @@ class SplashScreen extends React.PureComponent {
|
||||
});
|
||||
} else if (walletStatus && walletStatus.blocks_behind > 0) {
|
||||
const behind = walletStatus.blocks_behind;
|
||||
const behindText = behind + ' block' + (behind == 1 ? '' : 's') + ' behind';
|
||||
const behindText = behind + ' block' + (behind === 1 ? '' : 's') + ' behind';
|
||||
this.setState({
|
||||
message: 'Blockchain Sync',
|
||||
details: behindText,
|
||||
@@ -240,9 +247,8 @@ class SplashScreen extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('app_launch', null);
|
||||
}
|
||||
NativeModules.Firebase.track('app_launch', null);
|
||||
NativeModules.Firebase.setCurrentScreen('Splash');
|
||||
|
||||
this.props.fetchRewardedContent();
|
||||
Linking.getInitialURL().then(url => {
|
||||
@@ -254,7 +260,7 @@ class SplashScreen extends React.PureComponent {
|
||||
// Start measuring the first launch time from the splash screen
|
||||
// (time to first user interaction - after first run completed)
|
||||
AsyncStorage.getItem('hasLaunched').then(value => {
|
||||
if ('true' !== value) {
|
||||
if (value !== 'true') {
|
||||
AsyncStorage.setItem('hasLaunched', 'true');
|
||||
// only set firstLaunchTime since we've determined that this is the first app launch ever
|
||||
AsyncStorage.setItem('firstLaunchTime', String(moment().unix()));
|
||||
|
||||
@@ -5,30 +5,34 @@ import {
|
||||
doFetchRecommendedSubscriptions,
|
||||
selectSubscriptionClaims,
|
||||
selectSubscriptions,
|
||||
selectSubscriptionsBeingFetched,
|
||||
selectIsFetchingSubscriptions,
|
||||
selectIsFetchingSuggested,
|
||||
selectSuggestedChannels,
|
||||
selectUnreadSubscriptions,
|
||||
selectViewMode,
|
||||
selectFirstRunCompleted,
|
||||
selectShowSuggestedSubs,
|
||||
} from 'lbryinc';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetClientSetting, doSetTimeItem } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting, selectTimeItem } from 'redux/selectors/settings';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import SubscriptionsPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
loading: selectIsFetchingSubscriptions(state) || Boolean(Object.keys(selectSubscriptionsBeingFetched(state)).length),
|
||||
loading: selectIsFetchingSubscriptions(state),
|
||||
loadingSuggested: selectIsFetchingSuggested(state),
|
||||
subscribedChannels: selectSubscriptions(state),
|
||||
suggestedChannels: selectSuggestedChannels(state),
|
||||
subscriptionsViewMode: makeSelectClientSetting(Constants.SETTING_SUBSCRIPTIONS_VIEW_MODE)(state),
|
||||
allSubscriptions: selectSubscriptionClaims(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
viewMode: selectViewMode(state),
|
||||
firstRunCompleted: selectFirstRunCompleted(state),
|
||||
showSuggestedSubs: selectShowSuggestedSubs(state),
|
||||
timeItem: selectTimeItem(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
@@ -38,6 +42,7 @@ const perform = dispatch => ({
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SUBSCRIPTIONS)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { buildURI, parseURI } from 'lbry-redux';
|
||||
import { __, uriFromFileInfo } from 'utils/helper';
|
||||
import { __, getOrderBy } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import Button from 'component/button';
|
||||
@@ -25,6 +25,7 @@ import FileItem from 'component/fileItem';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import ModalSuggestedSubscriptions from 'component/modalSuggestedSubscriptions';
|
||||
import SubscribedChannelList from 'component/subscribedChannelList';
|
||||
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||
import UriBar from 'component/uriBar';
|
||||
@@ -33,6 +34,8 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
state = {
|
||||
showingSuggestedSubs: false,
|
||||
showSortPicker: false,
|
||||
showTimePicker: false,
|
||||
showModalSuggestedSubs: false,
|
||||
orderBy: ['release_time'],
|
||||
filteredChannels: [],
|
||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting subscriptions by new
|
||||
@@ -42,7 +45,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -63,6 +66,8 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Subscriptions');
|
||||
|
||||
doFetchMySubscriptions();
|
||||
doFetchRecommendedSubscriptions();
|
||||
};
|
||||
@@ -74,28 +79,19 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.FULL_ROUTE_NAME_MY_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
|
||||
if (Constants.DRAWER_ROUTE_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
let orderBy = [];
|
||||
switch (item.name) {
|
||||
case Constants.SORT_BY_HOT:
|
||||
orderBy = Constants.DEFAULT_ORDER_BY;
|
||||
break;
|
||||
this.setState({ currentSortByItem: item, orderBy: getOrderBy(item), showSortPicker: false });
|
||||
};
|
||||
|
||||
case Constants.SORT_BY_NEW:
|
||||
orderBy = ['release_time'];
|
||||
break;
|
||||
|
||||
case Constants.SORT_BY_TOP:
|
||||
orderBy = ['effective_amount'];
|
||||
break;
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
handleTimeItemSelected = item => {
|
||||
const { setTimeItem } = this.props;
|
||||
setTimeItem(item);
|
||||
this.setState({ showTimePicker: false });
|
||||
};
|
||||
|
||||
handleChannelSelected = channelUri => {
|
||||
@@ -115,20 +111,20 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
suggestedChannels,
|
||||
subscribedChannels,
|
||||
allSubscriptions,
|
||||
loading,
|
||||
viewMode,
|
||||
doSetViewMode,
|
||||
loadingSuggested,
|
||||
firstRunCompleted,
|
||||
doCompleteFirstRun,
|
||||
doShowSuggestedSubs,
|
||||
loading,
|
||||
loadingSuggested,
|
||||
firstRunCompleted,
|
||||
showSuggestedSubs,
|
||||
timeItem,
|
||||
unreadSubscriptions,
|
||||
navigation,
|
||||
} = this.props;
|
||||
const { currentSortByItem, filteredChannels } = this.state;
|
||||
const { currentSortByItem, filteredChannels, showModalSuggestedSubs, showSortPicker, showTimePicker } = this.state;
|
||||
|
||||
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
||||
const hasSubscriptions = numberOfSubscriptions > 0;
|
||||
@@ -154,16 +150,36 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
<UriBar navigation={navigation} belowOverlay={this.state.showSortPicker} />
|
||||
<View style={subscriptionsStyle.titleRow}>
|
||||
<Text style={subscriptionsStyle.pageTitle}>Channels you follow</Text>
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && (
|
||||
<TouchableOpacity
|
||||
style={subscriptionsStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showSortPicker: true })}
|
||||
>
|
||||
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && (
|
||||
<View style={subscriptionsStyle.pickerRow}>
|
||||
<View style={subscriptionsStyle.leftPickerRow}>
|
||||
<TouchableOpacity
|
||||
style={subscriptionsStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showSortPicker: true })}
|
||||
>
|
||||
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
|
||||
{Constants.SORT_BY_TOP === currentSortByItem.name && (
|
||||
<TouchableOpacity
|
||||
style={subscriptionsStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showTimePicker: true })}
|
||||
>
|
||||
<Text style={subscriptionsStyle.tagSortText}>{timeItem.label}</Text>
|
||||
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Link
|
||||
style={subscriptionsStyle.suggestedLink}
|
||||
text={'Suggested'}
|
||||
onPress={() => this.setState({ showModalSuggestedSubs: true })}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
|
||||
<View style={subscriptionsStyle.subContainer}>
|
||||
<SubscribedChannelList
|
||||
@@ -174,6 +190,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
style={subscriptionsStyle.claimList}
|
||||
channelIds={channelIds}
|
||||
orderBy={this.state.orderBy}
|
||||
time={timeItem.name}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
/>
|
||||
@@ -182,7 +199,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
|
||||
{hasSubscriptions && loading && (
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={subscriptionsStyle.loading} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={subscriptionsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -209,16 +226,17 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
|
||||
{loadingSuggested && (
|
||||
<View style={subscriptionsStyle.centered}>
|
||||
<ActivityIndicator size="large" colors={Colors.LbryGreen} style={subscriptionsStyle.loading} />
|
||||
\\
|
||||
<ActivityIndicator size="large" colors={Colors.NextLbryGreen} style={subscriptionsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
{!loadingSuggested && <SuggestedSubscriptions navigation={navigation} />}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!this.state.showSortPicker && <FloatingWalletBalance navigation={navigation} />}
|
||||
{this.state.showSortPicker && (
|
||||
{!showSortPicker && !showTimePicker && !showModalSuggestedSubs && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
{showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
@@ -227,6 +245,22 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showTimePicker && (
|
||||
<ModalPicker
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={timeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showModalSuggestedSubs && (
|
||||
<ModalSuggestedSubscriptions
|
||||
navigation={navigation}
|
||||
onOverlayPress={() => this.setState({ showModalSuggestedSubs: false })}
|
||||
onDonePress={() => this.setState({ showModalSuggestedSubs: false })}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,16 +1,24 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectFollowedTags, doToggleTagFollow } from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
||||
import TagPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
sortByItem: selectSortByItem(state),
|
||||
timeItem: selectTimeItem(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TAG)),
|
||||
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||
toggleTagFollow: tag => dispatch(doToggleTagFollow(tag)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
+85
-52
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS, normalizeURI } from 'lbry-redux';
|
||||
import { formatTagTitle } from 'utils/helper';
|
||||
import { formatTagTitle, getOrderBy } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import ClaimList from 'component/claimList';
|
||||
@@ -12,6 +12,7 @@ import fileListStyle from 'styles/fileList';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import Link from 'component/link';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
@@ -21,16 +22,13 @@ class TagPage extends React.PureComponent {
|
||||
showSortPicker: false,
|
||||
showTimePicker: false,
|
||||
orderBy: Constants.DEFAULT_ORDER_BY,
|
||||
time: Constants.TIME_WEEK,
|
||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[0],
|
||||
currentTimeItem: Constants.CLAIM_SEARCH_TIME_ITEMS[1],
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -40,10 +38,12 @@ class TagPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible, navigation } = this.props;
|
||||
this.setState({ tag: navigation.state.params.tag });
|
||||
pushDrawerStack();
|
||||
const { navigation, pushDrawerStack, setPlayerVisible, sortByItem } = this.props;
|
||||
const { tag } = navigation.state.params;
|
||||
this.setState({ tag, orderBy: getOrderBy(sortByItem) });
|
||||
pushDrawerStack(Constants.DRAWER_ROUTE_TAG, navigation.state.params);
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Tag');
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -59,65 +59,98 @@ class TagPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
let orderBy = [];
|
||||
switch (item.name) {
|
||||
case Constants.SORT_BY_HOT:
|
||||
orderBy = Constants.DEFAULT_ORDER_BY;
|
||||
break;
|
||||
|
||||
case Constants.SORT_BY_NEW:
|
||||
orderBy = ['release_time'];
|
||||
break;
|
||||
|
||||
case Constants.SORT_BY_TOP:
|
||||
orderBy = [Constants.ORDER_BY_EFFECTIVE_AMOUNT];
|
||||
break;
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
const { setSortByItem } = this.props;
|
||||
setSortByItem(item);
|
||||
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
|
||||
};
|
||||
|
||||
handleTimeItemSelected = item => {
|
||||
this.setState({ time: item.name });
|
||||
const { setTimeItem } = this.props;
|
||||
setTimeItem(item);
|
||||
this.setState({ showTimePicker: false });
|
||||
};
|
||||
|
||||
isFollowingTag = tag => {
|
||||
const { followedTags } = this.props;
|
||||
return followedTags.map(tag => tag.name).includes(tag);
|
||||
};
|
||||
|
||||
handleFollowTagToggle = () => {
|
||||
const { toggleTagFollow } = this.props;
|
||||
const { tag } = this.state;
|
||||
const isFollowing = this.isFollowingTag(tag);
|
||||
if (isFollowing) {
|
||||
// unfollow
|
||||
NativeModules.Firebase.track('tag_unfollow', { tag });
|
||||
} else {
|
||||
// follow
|
||||
NativeModules.Firebase.track('tag_follow', { tag });
|
||||
}
|
||||
|
||||
toggleTagFollow(tag);
|
||||
if (window.persistor) {
|
||||
window.persistor.flush();
|
||||
}
|
||||
};
|
||||
|
||||
listHeader = () => {
|
||||
const { sortByItem, timeItem } = this.props;
|
||||
const { tag } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.listHeader}>
|
||||
<View style={discoverStyle.titleRow}>
|
||||
<Text style={discoverStyle.pageTitle}>{formatTagTitle(tag)}</Text>
|
||||
</View>
|
||||
<View style={discoverStyle.pickerRow}>
|
||||
<View style={discoverStyle.leftPickerRow}>
|
||||
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
{Constants.SORT_BY_TOP === sortByItem.name && (
|
||||
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<Link
|
||||
style={discoverStyle.customizeLink}
|
||||
text={this.isFollowingTag(tag) ? 'Unfollow' : 'Follow'}
|
||||
onPress={this.handleFollowTagToggle}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { tag, currentSortByItem, currentTimeItem, showSortPicker, showTimePicker } = this.state;
|
||||
const { navigation, sortByItem, timeItem } = this.props;
|
||||
const { tag, showSortPicker, showTimePicker } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} belowOverlay={showSortPicker || showTimePicker} />
|
||||
<ClaimList
|
||||
ListHeaderComponent={
|
||||
<View style={discoverStyle.tagTitleRow}>
|
||||
<Text style={discoverStyle.tagPageTitle}>{formatTagTitle(tag)}</Text>
|
||||
{Constants.SORT_BY_TOP === currentSortByItem.name && (
|
||||
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{currentTimeItem.label}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
}
|
||||
style={discoverStyle.tagPageClaimList}
|
||||
orderBy={this.state.orderBy}
|
||||
time={this.state.time}
|
||||
tags={[tag]}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
/>
|
||||
{this.state.tag && (
|
||||
<ClaimList
|
||||
ListHeaderComponent={this.listHeader}
|
||||
style={discoverStyle.tagPageClaimList}
|
||||
orderBy={this.state.orderBy}
|
||||
time={timeItem.name}
|
||||
tags={[tag]}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
/>
|
||||
)}
|
||||
{!showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
|
||||
{showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={this.state.currentSortByItem}
|
||||
selectedItem={sortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
@@ -126,7 +159,7 @@ class TagPage extends React.PureComponent {
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={this.state.currentTimeItem}
|
||||
selectedItem={timeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import { View, ScrollView, Text } from 'react-native';
|
||||
import Constants from 'constants';
|
||||
import { ActivityIndicator, NativeModules, View, ScrollView, Text } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import EmptyStateView from 'component/emptyStateView';
|
||||
import TransactionList from 'component/transactionList';
|
||||
import UriBar from 'component/uriBar';
|
||||
import walletStyle from 'styles/wallet';
|
||||
@@ -10,7 +12,7 @@ class TransactionHistoryPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -23,7 +25,9 @@ class TransactionHistoryPage extends React.PureComponent {
|
||||
const { fetchTransactions, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
fetchTransactions();
|
||||
NativeModules.Firebase.setCurrentScreen('Transaction History').then(result => {
|
||||
fetchTransactions();
|
||||
});
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -42,16 +46,17 @@ class TransactionHistoryPage extends React.PureComponent {
|
||||
const { fetchingTransactions, transactions, navigation } = this.props;
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={walletStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
{fetchingTransactions && (
|
||||
<View style={walletStyle.loadingContainer}>
|
||||
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
|
||||
<Text style={walletStyle.loadingText}>Loading transactions...</Text>
|
||||
</View>
|
||||
)}
|
||||
{!fetchingTransactions && transactions.length === 0 && <EmptyStateView message={'No transactions to list.'} />}
|
||||
<ScrollView style={walletStyle.transactionHistoryScroll}>
|
||||
<View style={walletStyle.historyList}>
|
||||
{fetchingTransactions && !transactions.length && (
|
||||
<Text style={walletStyle.infoText}>Loading transactions...</Text>
|
||||
)}
|
||||
{!fetchingTransactions && transactions.length === 0 && (
|
||||
<Text style={walletStyle.infoText}>No transactions to list.</Text>
|
||||
)}
|
||||
{!fetchingTransactions && transactions && transactions.length > 0 && (
|
||||
<TransactionList navigation={navigation} transactions={transactions} />
|
||||
)}
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectFollowedTags } from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
||||
import TrendingPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
sortByItem: selectSortByItem(state),
|
||||
timeItem: selectTimeItem(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TRENDING)),
|
||||
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||
setTimeItem: item => dispatch(doSetTimeItem(item)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
+114
-33
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS, normalizeURI } from 'lbry-redux';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { getOrderBy } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import ClaimList from 'component/claimList';
|
||||
@@ -23,7 +24,10 @@ const TRENDING_FOR_ITEMS = [
|
||||
class TrendingPage extends React.PureComponent {
|
||||
state = {
|
||||
showModalTagSelector: false,
|
||||
showSortByPicker: false,
|
||||
showTimePicker: false,
|
||||
showTrendingForPicker: false,
|
||||
orderBy: Constants.DEFAULT_ORDER_BY,
|
||||
currentTrendingForItem: TRENDING_FOR_ITEMS[0],
|
||||
};
|
||||
|
||||
@@ -31,7 +35,7 @@ class TrendingPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -41,9 +45,15 @@ class TrendingPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
const { pushDrawerStack, setPlayerVisible, navigation, sortByItem } = this.props;
|
||||
const { filterForTags } = navigation.state.params ? navigation.state.params : { filterForTags: false };
|
||||
this.setState({
|
||||
currentTrendingForItem: TRENDING_FOR_ITEMS[filterForTags ? 1 : 0],
|
||||
orderBy: getOrderBy(sortByItem),
|
||||
});
|
||||
pushDrawerStack(Constants.DRAWER_ROUTE_TRENDING, navigation.state.params);
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('All content');
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -53,7 +63,7 @@ class TrendingPage extends React.PureComponent {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.FULL_ROUTE_NAME_TRENDING === currentRoute && currentRoute !== prevRoute) {
|
||||
if (Constants.DRAWER_ROUTE_TRENDING === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
@@ -62,43 +72,96 @@ class TrendingPage extends React.PureComponent {
|
||||
this.setState({ currentTrendingForItem: item, showTrendingForPicker: false });
|
||||
};
|
||||
|
||||
handleSortByItemSelected = item => {
|
||||
const { setSortByItem } = this.props;
|
||||
setSortByItem(item);
|
||||
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
|
||||
};
|
||||
|
||||
handleTimeItemSelected = item => {
|
||||
const { setTimeItem } = this.props;
|
||||
setTimeItem(item);
|
||||
this.setState({ showTimePicker: false });
|
||||
};
|
||||
|
||||
listHeader = () => {
|
||||
const { sortByItem, timeItem } = this.props;
|
||||
const { currentTrendingForItem } = this.state;
|
||||
const sortByTop = Constants.SORT_BY_TOP === sortByItem.name;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.listHeader}>
|
||||
<View style={discoverStyle.titleRow}>
|
||||
<Text style={discoverStyle.pageTitle}>All content</Text>
|
||||
</View>
|
||||
<View style={discoverStyle.pickerRow}>
|
||||
<View style={discoverStyle.leftPickerRow}>
|
||||
<TouchableOpacity
|
||||
style={discoverStyle.allTagSortBy}
|
||||
onPress={() => this.setState({ showSortPicker: true })}
|
||||
>
|
||||
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={discoverStyle.pickerLabel}>for</Text>
|
||||
<TouchableOpacity
|
||||
style={discoverStyle.allTagSortBy}
|
||||
onPress={() => this.setState({ showTrendingForPicker: true })}
|
||||
>
|
||||
<Text style={discoverStyle.tagSortText}>{currentTrendingForItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
|
||||
{sortByTop && <Text style={discoverStyle.pickerLabel}>from</Text>}
|
||||
|
||||
{sortByTop && (
|
||||
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
|
||||
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
{TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name && (
|
||||
<Link
|
||||
style={discoverStyle.customizeLink}
|
||||
text={'Customize'}
|
||||
onPress={() => this.setState({ showModalTagSelector: true })}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { followedTags, navigation } = this.props;
|
||||
const { currentTrendingForItem, showModalTagSelector, showTrendingForPicker } = this.state;
|
||||
const { followedTags, navigation, sortByItem, timeItem } = this.props;
|
||||
const {
|
||||
currentTrendingForItem,
|
||||
orderBy,
|
||||
showModalTagSelector,
|
||||
showSortPicker,
|
||||
showTimePicker,
|
||||
showTrendingForPicker,
|
||||
} = this.state;
|
||||
const filteredForTags = TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
<ClaimList
|
||||
ListHeaderComponent={
|
||||
<View style={discoverStyle.titleRow}>
|
||||
<Text style={discoverStyle.pageTitle}>Trending</Text>
|
||||
<View style={discoverStyle.rightTitleRow}>
|
||||
{TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name && (
|
||||
<Link
|
||||
style={discoverStyle.customizeLink}
|
||||
text={'Customize'}
|
||||
onPress={() => this.setState({ showModalTagSelector: true })}
|
||||
/>
|
||||
)}
|
||||
<TouchableOpacity
|
||||
style={discoverStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showTrendingForPicker: true })}
|
||||
>
|
||||
<Text style={discoverStyle.tagSortText}>{currentTrendingForItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
ListHeaderComponent={this.listHeader}
|
||||
style={discoverStyle.verticalClaimList}
|
||||
orderBy={Constants.DEFAULT_ORDER_BY}
|
||||
trendingForAll={TRENDING_FOR_ITEMS[0].name === currentTrendingForItem.name}
|
||||
tags={followedTags.map(tag => tag.name)}
|
||||
orderBy={orderBy}
|
||||
tags={filteredForTags ? followedTags.map(tag => tag.name) : null}
|
||||
time={timeItem.name}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
/>
|
||||
{!showModalTagSelector && <FloatingWalletBalance navigation={navigation} />}
|
||||
{!showModalTagSelector && !showTrendingForPicker && !showSortPicker && !showTimePicker && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
{showModalTagSelector && (
|
||||
<ModalTagSelector
|
||||
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
|
||||
@@ -107,13 +170,31 @@ class TrendingPage extends React.PureComponent {
|
||||
)}
|
||||
{showTrendingForPicker && (
|
||||
<ModalPicker
|
||||
title={'Trending for'}
|
||||
title={'Filter for'}
|
||||
onOverlayPress={() => this.setState({ showTrendingForPicker: false })}
|
||||
onItemSelected={this.handleTrendingForItemSelected}
|
||||
selectedItem={currentTrendingForItem}
|
||||
items={TRENDING_FOR_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={sortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showTimePicker && (
|
||||
<ModalPicker
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={timeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { doToast } from 'lbry-redux';
|
||||
import {
|
||||
doCheckSync,
|
||||
doGetSync,
|
||||
doSetDefaultAccount,
|
||||
doSyncApply,
|
||||
doUserEmailNew,
|
||||
doUserEmailToVerify,
|
||||
@@ -29,7 +28,7 @@ import {
|
||||
} from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Verification from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -54,13 +53,12 @@ const select = state => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)),
|
||||
getSync: password => dispatch(doGetSync(password)),
|
||||
addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
checkSync: () => dispatch(doCheckSync()),
|
||||
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
|
||||
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
|
||||
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { ActivityIndicator, View, Text, TextInput } from 'react-native';
|
||||
import { ActivityIndicator, NativeModules, View, Text, TextInput } from 'react-native';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
import rewardStyle from 'styles/reward';
|
||||
|
||||
@@ -44,11 +44,12 @@ class EmailVerifyPage extends React.PureComponent {
|
||||
notify({ message: String(emailNewErrorMessage), isError: true });
|
||||
this.setState({ verifyStarted: false });
|
||||
} else {
|
||||
NativeModules.Firebase.track('email_added', { email: this.state.email });
|
||||
this.setState({ phase: Constants.PHASE_VERIFICATION });
|
||||
if (setEmailVerificationPhase) {
|
||||
setEmailVerificationPhase(true);
|
||||
}
|
||||
//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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import rewardStyle from 'styles/reward';
|
||||
@@ -37,20 +37,26 @@ class SyncVerifyPage extends React.PureComponent {
|
||||
if (!hasSyncedWallet) {
|
||||
// fresh account with no sync
|
||||
const newPassword = this.state.password ? this.state.password : '';
|
||||
Lbry.account_encrypt({ new_password: newPassword }).then(() => {
|
||||
if (newPassword.trim().length === 0) {
|
||||
getSync(newPassword);
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
navigation.goBack();
|
||||
});
|
||||
} else {
|
||||
Lbry.wallet_encrypt({ new_password: newPassword }).then(() => {
|
||||
getSync(newPassword);
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
navigation.goBack();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
syncApply(syncHash, syncData, this.state.password);
|
||||
syncApply(syncHash, syncData, this.state.password ? this.state.password : '');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { getSyncIsPending, syncApplyIsPending, syncApplyErrorMessage } = nextProps;
|
||||
const { getSync, hasSyncedWallet, navigation, notify, setClientSetting, setDefaultAccount } = this.props;
|
||||
const { getSync, hasSyncedWallet, navigation, notify, setClientSetting } = this.props;
|
||||
if (this.state.checkSyncStarted && !getSyncIsPending) {
|
||||
this.setState({ syncChecked: true });
|
||||
}
|
||||
@@ -62,15 +68,40 @@ class SyncVerifyPage extends React.PureComponent {
|
||||
} else {
|
||||
// password successfully verified
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password);
|
||||
NativeModules.UtilityModule.setSecureValue(
|
||||
Constants.KEY_WALLET_PASSWORD,
|
||||
this.state.password ? this.state.password : ''
|
||||
);
|
||||
}
|
||||
setDefaultAccount();
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
navigation.goBack();
|
||||
|
||||
this.finishSync(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finishSync = (notifyUnlockFailed = false) => {
|
||||
const { navigation, notify, setClientSetting } = this.props;
|
||||
|
||||
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
|
||||
|
||||
// unlock the wallet (if locked)
|
||||
Lbry.wallet_status().then(status => {
|
||||
if (status.is_locked) {
|
||||
Lbry.wallet_unlock({ password: this.state.password ? this.state.password : '' }).then(unlocked => {
|
||||
if (unlocked) {
|
||||
navigation.goBack();
|
||||
} else {
|
||||
if (notifyUnlockFailed) {
|
||||
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' });
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
navigation.goBack();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
handleChangeText = text => {
|
||||
// save the value to the state email
|
||||
const { onPasswordChanged } = this.props;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import EmailVerifyPage from './internal/email-verify-page';
|
||||
import ManualVerifyPage from './internal/manual-verify-page';
|
||||
import PhoneVerifyPage from './internal/phone-verify-page';
|
||||
@@ -29,6 +29,7 @@ class VerificationScreen extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { user } = this.props;
|
||||
this.checkVerificationStatus(user);
|
||||
NativeModules.Firebase.setCurrentScreen('Verification');
|
||||
}
|
||||
|
||||
setEmailVerificationPhase = value => {
|
||||
@@ -68,6 +69,9 @@ class VerificationScreen extends React.PureComponent {
|
||||
if (this.state.isEmailVerified && this.state.isRewardApproved) {
|
||||
// verification steps already completed
|
||||
// simply navigate back to the rewards page
|
||||
if (user.primary_email) {
|
||||
NativeModules.Firebase.track('reward_eligibility_completed', { email: user.primary_email });
|
||||
}
|
||||
navigation.goBack();
|
||||
}
|
||||
}
|
||||
@@ -97,7 +101,6 @@ class VerificationScreen extends React.PureComponent {
|
||||
notify,
|
||||
addUserPhone,
|
||||
getSyncIsPending,
|
||||
setDefaultAccount,
|
||||
hasSyncedWallet,
|
||||
setSyncIsPending,
|
||||
syncApplyIsPending,
|
||||
@@ -158,7 +161,6 @@ class VerificationScreen extends React.PureComponent {
|
||||
notify={notify}
|
||||
setEmailVerificationPhase={this.setEmailVerificationPhase}
|
||||
setClientSetting={setClientSetting}
|
||||
setDefaultAccount={setDefaultAccount}
|
||||
setSyncIsPending={setSyncIsPending}
|
||||
syncApplyIsPending={syncApplyIsPending}
|
||||
syncApplyErrorMessage={syncApplyErrorMessage}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import { selectBalance } from 'lbry-redux';
|
||||
import { doCheckSync, doGetSync, selectUser, selectHasSyncedWallet } from 'lbryinc';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import WalletPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -21,7 +21,7 @@ const select = state => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
checkSync: () => dispatch(doCheckSync()),
|
||||
getSync: password => dispatch(doGetSync(password)),
|
||||
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_WALLET)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
|
||||
@@ -9,7 +9,7 @@ import WalletSyncDriver from 'component/walletSyncDriver';
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import UriBar from 'component/uriBar';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import walletStyle from 'styles/wallet';
|
||||
|
||||
class WalletPage extends React.PureComponent {
|
||||
@@ -17,7 +17,7 @@ class WalletPage extends React.PureComponent {
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -42,13 +42,12 @@ class WalletPage extends React.PureComponent {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Wallet');
|
||||
|
||||
const { deviceWalletSynced, getSync, user } = this.props;
|
||||
if (deviceWalletSynced && user && user.has_verified_email) {
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
|
||||
if (walletPassword && walletPassword.trim().length > 0) {
|
||||
getSync(walletPassword);
|
||||
}
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
|
||||
getSync(walletPassword);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
export const doPushDrawerStack = routeName => dispatch =>
|
||||
export const doPushDrawerStack = (routeName, params) => dispatch =>
|
||||
dispatch({
|
||||
type: Constants.ACTION_PUSH_DRAWER_STACK,
|
||||
data: routeName,
|
||||
data: { routeName, params },
|
||||
});
|
||||
|
||||
export const doPopDrawerStack = () => dispatch =>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
export const doUpdatePublishFormState = publishFormValue => dispatch =>
|
||||
dispatch({
|
||||
type: Constants.ACTION_UPDATE_PUBLISH_FORM_STATE,
|
||||
data: { ...publishFormValue },
|
||||
});
|
||||
|
||||
export const doUpdateChannelFormState = channelFormValue => dispatch =>
|
||||
dispatch({
|
||||
type: Constants.ACTION_UPDATE_CHANNEL_FORM_STATE,
|
||||
data: { ...channelFormValue },
|
||||
});
|
||||
|
||||
export const doClearPublishFormState = () => dispatch =>
|
||||
dispatch({
|
||||
type: Constants.ACTION_CLEAR_PUBLISH_FORM_STATE,
|
||||
});
|
||||
|
||||
export const doClearChannelFormState = () => dispatch =>
|
||||
dispatch({
|
||||
type: Constants.ACTION_CLEAR_CHANNEL_FORM_STATE,
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
// @flow
|
||||
import { NativeModules } from 'react-native';
|
||||
import {
|
||||
ACTIONS,
|
||||
batchActions,
|
||||
buildURI,
|
||||
doResolveUri,
|
||||
doUpdateSearchQuery,
|
||||
makeSelectSearchUris,
|
||||
selectSuggestions,
|
||||
makeSelectQueryWithOptions,
|
||||
selectSearchValue,
|
||||
} from 'lbry-redux';
|
||||
|
||||
let CONNECTION_STRING = 'https://lighthouse.lbry.com/';
|
||||
|
||||
const handleNativeFetchResponse = str => {
|
||||
const json = JSON.parse(str);
|
||||
if (json.error) {
|
||||
return Promise.reject(new Error(json.error));
|
||||
}
|
||||
|
||||
return Promise.resolve(json);
|
||||
};
|
||||
|
||||
// Use a native asyncTask to call the lighthouse api
|
||||
export const doNativeSearch = (
|
||||
rawQuery: string, // pass in a query if you don't want to search for what's in the search bar
|
||||
size: ?number, // only pass in if you don't want to use the users setting (ex: related content)
|
||||
from: ?number,
|
||||
isBackgroundSearch: boolean = false
|
||||
) => (dispatch: Dispatch, getState: GetState) => {
|
||||
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||
|
||||
if (!query) {
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_FAIL,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const state = getState();
|
||||
const queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch)(state);
|
||||
|
||||
// If we have already searched for something, we don't need to do anything
|
||||
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
||||
if (urisForQuery && !!urisForQuery.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_START,
|
||||
});
|
||||
|
||||
// If the user is on the file page with a pre-populated uri and they select
|
||||
// the search option without typing anything, searchQuery will be empty
|
||||
// We need to populate it so the input is filled on the search page
|
||||
// isBackgroundSearch means the search is happening in the background, don't update the search query
|
||||
if (!state.search.searchQuery && !isBackgroundSearch) {
|
||||
dispatch(doUpdateSearchQuery(query));
|
||||
}
|
||||
|
||||
const url = `${CONNECTION_STRING}search?${queryWithOptions}`;
|
||||
NativeModules.Requests.get(url)
|
||||
.then(handleNativeFetchResponse)
|
||||
.then((data: Array<{ name: String, claimId: string }>) => {
|
||||
const uris = [];
|
||||
const actions = [];
|
||||
|
||||
data.forEach(result => {
|
||||
if (result.name) {
|
||||
const uri = buildURI({
|
||||
claimName: result.name,
|
||||
claimId: result.claimId,
|
||||
});
|
||||
actions.push(doResolveUri(uri));
|
||||
uris.push(uri);
|
||||
}
|
||||
});
|
||||
|
||||
actions.push({
|
||||
type: ACTIONS.SEARCH_SUCCESS,
|
||||
data: {
|
||||
query: queryWithOptions,
|
||||
uris,
|
||||
},
|
||||
});
|
||||
dispatch(batchActions(...actions));
|
||||
})
|
||||
.catch(e => {
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_FAIL,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,11 +1,40 @@
|
||||
import { ACTIONS } from 'lbry-redux';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
export function doSetClientSetting(key, value) {
|
||||
return {
|
||||
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
||||
data: {
|
||||
key,
|
||||
value,
|
||||
},
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
||||
data: {
|
||||
key,
|
||||
value,
|
||||
},
|
||||
});
|
||||
|
||||
if (window.persistor) {
|
||||
window.persistor.flush();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function doSetSortByItem(item) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: Constants.ACTION_SORT_BY_ITEM_CHANGED,
|
||||
data: {
|
||||
name: item.name,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doSetTimeItem(item) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: Constants.ACTION_TIME_ITEM_CHANGED,
|
||||
data: {
|
||||
name: item.name,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
stack: [Constants.DRAWER_ROUTE_DISCOVER], // Discover is always the first drawer route
|
||||
stack: [{ route: Constants.DRAWER_ROUTE_DISCOVER, params: {} }], // Discover is always the first drawer route
|
||||
playerVisible: false,
|
||||
currentRoute: null,
|
||||
};
|
||||
@@ -13,11 +13,23 @@ reducers[Constants.ACTION_SET_PLAYER_VISIBLE] = (state, action) =>
|
||||
});
|
||||
|
||||
reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
|
||||
const routeName = action.data;
|
||||
const { routeName, params } = action.data;
|
||||
const newStack = state.stack.slice();
|
||||
|
||||
if (routeName !== newStack[newStack.length - 1]) {
|
||||
newStack.push(routeName);
|
||||
const lastRoute = newStack[newStack.length - 1].route;
|
||||
let canPushStack = routeName !== lastRoute;
|
||||
if (
|
||||
lastRoute === Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM &&
|
||||
routeName === Constants.DRAWER_ROUTE_CHANNEL_CREATOR
|
||||
) {
|
||||
canPushStack = false;
|
||||
}
|
||||
if (lastRoute === Constants.DRAWER_ROUTE_PUBLISH_FORM && routeName === Constants.DRAWER_ROUTE_PUBLISH) {
|
||||
canPushStack = false;
|
||||
}
|
||||
|
||||
if (canPushStack) {
|
||||
newStack.push({ route: routeName, params });
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
channelFormValues: {},
|
||||
publishFormValues: {},
|
||||
};
|
||||
|
||||
reducers[Constants.ACTION_UPDATE_PUBLISH_FORM_STATE] = (state, action) => {
|
||||
const { data } = action;
|
||||
const publishFormValues = Object.assign({}, state.publishFormValues);
|
||||
const newPublishFormValues = Object.assign(publishFormValues, data);
|
||||
|
||||
return {
|
||||
...state,
|
||||
publishFormValues: newPublishFormValues,
|
||||
};
|
||||
};
|
||||
|
||||
reducers[Constants.ACTION_UPDATE_CHANNEL_FORM_STATE] = (state, action) => {
|
||||
const { data } = action;
|
||||
const channelFormValues = Object.assign({}, state.channelFormValues);
|
||||
const newChannelFormValues = Object.assign(channelFormValues, data);
|
||||
|
||||
return {
|
||||
...state,
|
||||
channelFormValues: newChannelFormValues,
|
||||
};
|
||||
};
|
||||
|
||||
reducers[Constants.ACTION_CLEAR_PUBLISH_FORM_STATE] = state => {
|
||||
return {
|
||||
...state,
|
||||
publishFormValues: {},
|
||||
};
|
||||
};
|
||||
|
||||
reducers[Constants.ACTION_CLEAR_CHANNEL_FORM_STATE] = state => {
|
||||
return {
|
||||
...state,
|
||||
channelFormValues: {},
|
||||
};
|
||||
};
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
return state;
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ACTIONS } from 'lbry-redux';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
clientSettings: {},
|
||||
sortByItemName: Constants.SORT_BY_HOT,
|
||||
timeItemName: Constants.TIME_WEEK,
|
||||
};
|
||||
|
||||
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
|
||||
@@ -16,6 +19,16 @@ reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
|
||||
});
|
||||
};
|
||||
|
||||
reducers[Constants.ACTION_SORT_BY_ITEM_CHANGED] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
sortByItemName: action.data.name,
|
||||
});
|
||||
|
||||
reducers[Constants.ACTION_TIME_ITEM_CHANGED] = (state, action) =>
|
||||
Object.assign({}, state, {
|
||||
timeItemName: action.data.name,
|
||||
});
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
||||
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user