Compare commits

..
Author SHA1 Message Date
Akinwale Ariwodola a8daf84c52 NSFW -> mature 2019-10-15 13:51:33 +01:00
Akinwale Ariwodola b5d9e44445 add URI bar suggestions setting. reorganise settings page 2019-10-15 13:49:29 +01:00
110 changed files with 1140 additions and 2155 deletions

No files matched your search

+7 -10
View File
@@ -5640,8 +5640,8 @@
}
},
"lbry-redux": {
"version": "github:lbryio/lbry-redux#9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc",
"from": "github:lbryio/lbry-redux#9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc",
"version": "github:lbryio/lbry-redux#4c4f926ee2cd77d750df0a95fad669257aa31ae7",
"from": "github:lbryio/lbry-redux#4c4f926ee2cd77d750df0a95fad669257aa31ae7",
"requires": {
"proxy-polyfill": "0.1.6",
"reselect": "^3.0.0",
@@ -5649,8 +5649,8 @@
}
},
"lbryinc": {
"version": "github:lbryio/lbryinc#9ffb883cc11e36d55a729c65b70c405a4a56d35e",
"from": "github:lbryio/lbryinc#9ffb883cc11e36d55a729c65b70c405a4a56d35e",
"version": "github:lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
"from": "github:lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
"requires": {
"reselect": "^3.0.0"
}
@@ -8402,12 +8402,9 @@
}
},
"react-navigation-drawer": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-1.4.0.tgz",
"integrity": "sha512-ZyWBozcjB2aZ7vwCALv90cYA2NpDjM+WALaiYRshvPvue8l7cqynePbHK8GhlMGyJDwZqp4MxQmu8u1XAKp3Bw==",
"requires": {
"react-native-tab-view": "^1.2.0"
}
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/react-navigation-drawer/-/react-navigation-drawer-2.2.2.tgz",
"integrity": "sha512-KcFH7RRzT1XuREkTbNMCqfy7nK7yenzpGKvqp1dTvAE+DIyHHpf+Po959lsmITlt/njQBn+QxvdX1FZ9we3lNA=="
},
"react-navigation-redux-helpers": {
"version": "3.0.2",
+3 -3
View File
@@ -12,8 +12,8 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc",
"lbryinc": "lbryio/lbryinc#9ffb883cc11e36d55a729c65b70c405a4a56d35e",
"lbry-redux": "lbryio/lbry-redux#4c4f926ee2cd77d750df0a95fad669257aa31ae7",
"lbryinc": "lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",
"moment": "^2.22.1",
@@ -34,7 +34,7 @@
"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": "^1.4.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",
+10 -74
View File
@@ -27,18 +27,9 @@ import {
createNavigationReducer,
} from 'react-navigation-redux-helpers';
import { connect } from 'react-redux';
import {
AppState,
BackHandler,
DeviceEventEmitter,
Linking,
NativeModules,
StatusBar,
TextInput,
ToastAndroid,
} from 'react-native';
import { AppState, BackHandler, Linking, NativeModules, TextInput, ToastAndroid } from 'react-native';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { SETTINGS, doDismissToast, doPopulateSharedUserState, doPreferenceGet, doToast, selectToast } from 'lbry-redux';
import { SETTINGS, doDismissToast, doPopulateSharedUserState, doToast, selectToast } from 'lbry-redux';
import {
Lbryio,
doGetSync,
@@ -48,10 +39,9 @@ import {
selectEmailToVerify,
selectEmailVerifyIsPending,
selectEmailVerifyErrorMessage,
selectHashChanged,
selectUser,
} from 'lbryinc';
import { makeSelectClientSetting, selectFullscreenMode } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
@@ -63,8 +53,6 @@ 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"
@@ -281,11 +269,9 @@ class AppWithNavigationState extends React.Component {
constructor() {
super();
this.emailVerifyCheckInterval = null;
this.syncGetInterval = null;
this.state = {
emailVerifyDone: false,
verifyPending: false,
syncHashChanged: false,
};
}
@@ -306,19 +292,8 @@ class AppWithNavigationState extends React.Component {
}
componentDidMount() {
const { dispatch, user } = 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
if (user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
dispatch(doGetSync(walletPassword, () => this.getUserSettings()));
});
}
}, SYNC_GET_INTERVAL);
}
checkEmailVerification = () => {
@@ -333,47 +308,30 @@ class AppWithNavigationState extends React.Component {
getUserSettings = () => {
const { dispatch } = this.props;
doPreferenceGet(
'shared',
preference => {
dispatch(doPopulateSharedUserState(preference));
},
error => {
/* failed */
}
);
Lbryio.call('user_settings', 'get').then(settings => {
dispatch(doPopulateSharedUserState(settings));
});
};
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, hashChanged } = this.props;
const { dispatch, user } = this.props;
if (this.state.verifyPending && this.emailVerifyCheckInterval > 0 && user && user.has_verified_email) {
clearInterval(this.emailVerifyCheckInterval);
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false');
this.setState({ verifyPending: false });
NativeModules.Firebase.track('email_verified', { email: user.primary_email });
ToastAndroid.show(__('Your email address was successfully verified.'), ToastAndroid.LONG);
ToastAndroid.show('Your email address was successfully verified.', ToastAndroid.LONG);
// get user settings after email verification
this.getUserSettings();
}
if (hashChanged && !this.state.syncHashChanged) {
this.setState({ syncHashChanged: true });
this.getUserSettings();
}
}
componentWillUpdate(nextProps) {
@@ -401,7 +359,7 @@ class AppWithNavigationState extends React.Component {
this.setState({ emailVerifyDone: true });
const message = emailVerifyErrorMessage
? String(emailVerifyErrorMessage)
: __('Your email address was successfully verified.');
: 'Your email address was successfully verified.';
if (!emailVerifyErrorMessage) {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
}
@@ -436,26 +394,6 @@ class AppWithNavigationState extends React.Component {
if (backgroundPlayEnabled || NativeModules.BackgroundMedia) {
NativeModules.BackgroundMedia.hidePlaybackNotification();
}
// check fullscreen mode and show / hide navigation bar accordingly
this.checkFullscreenMode();
}
};
checkFullscreenMode = () => {
const { fullscreenMode } = this.props;
StatusBar.setHidden(fullscreenMode);
if (fullscreenMode) {
// fullscreen, so change orientation to landscape mode
NativeModules.ScreenOrientation.lockOrientationLandscape();
// hide the navigation bar (on devices that have the soft navigation bar)
NativeModules.UtilityModule.hideNavigationBar();
} else {
// Switch back to portrait mode when the media is not fullscreen
NativeModules.ScreenOrientation.lockOrientationPortrait();
// hide the navigation bar (on devices that have the soft navigation bar)
NativeModules.UtilityModule.showNavigationBar();
}
};
@@ -476,7 +414,7 @@ class AppWithNavigationState extends React.Component {
try {
dispatch(doUserEmailVerify(verification.token, verification.recaptcha));
} catch (error) {
const message = __('Invalid Verification Token');
const message = 'Invalid Verification Token';
dispatch(doUserEmailVerifyFailure(message));
dispatch(doToast({ message }));
}
@@ -500,7 +438,6 @@ 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),
@@ -510,7 +447,6 @@ const mapStateToProps = state => ({
emailVerifyErrorMessage: selectEmailVerifyErrorMessage(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
user: selectUser(state),
fullscreenMode: selectFullscreenMode(state),
});
export default connect(mapStateToProps)(AppWithNavigationState);
+2 -2
View File
@@ -15,7 +15,7 @@ export default class Address extends React.PureComponent<Props> {
return (
<View style={[walletStyle.row, style]}>
<Text selectable numberOfLines={1} style={walletStyle.address}>
<Text selectable={true} numberOfLines={1} style={walletStyle.address}>
{address || ''}
</Text>
<Button
@@ -24,7 +24,7 @@ export default class Address extends React.PureComponent<Props> {
onPress={() => {
Clipboard.setString(address);
doToast({
message: __('Address copied'),
message: 'Address copied',
});
}}
/>
+4
View File
@@ -0,0 +1,4 @@
import { connect } from 'react-redux';
import CategoryList from './view';
export default connect()(CategoryList);
+39
View File
@@ -0,0 +1,39 @@
import React from 'react';
import NavigationActions from 'react-navigation';
import { FlatList, Text, View } from 'react-native';
import { normalizeURI } from 'lbry-redux';
import FileItem from '/component/fileItem';
import discoverStyle from 'styles/discover';
class CategoryList extends React.PureComponent {
render() {
const { category, categoryMap, navigation } = this.props;
return (
<FlatList
style={discoverStyle.horizontalScrollContainer}
contentContainerStyle={discoverStyle.horizontalScrollPadding}
initialNumToRender={3}
maxToRenderPerBatch={3}
removeClippedSubviews={true}
renderItem={({ item }) => (
<FileItem
style={discoverStyle.fileItem}
mediaStyle={discoverStyle.fileItemMedia}
key={item}
uri={normalizeURI(item)}
navigation={navigation}
showDetails={true}
compactView={false}
/>
)}
horizontal={true}
showsHorizontalScrollIndicator={false}
data={categoryMap[category]}
keyExtractor={(item, index) => item}
/>
);
}
}
export default CategoryList;
+1 -1
View File
@@ -63,7 +63,7 @@ export default class ChannelIconItem extends React.PureComponent {
>
{isPlaceholder && (
<View style={channelIconStyle.centered}>
<Text style={channelIconStyle.placeholderText}>{__('ALL')}</Text>
<Text style={channelIconStyle.placeholderText}>ALL</Text>
</View>
)}
{!isPlaceholder && thumbnail && (
+1 -5
View File
@@ -11,11 +11,7 @@ class ChannelRewardsDriver extends React.PureComponent<Props> {
return (
<TouchableOpacity style={publishStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
<Icon name="award" size={16} style={publishStyle.rewardIcon} />
<Text style={publishStyle.rewardDriverText}>
{__('Channel creation requires credits.')}
{'\n'}
{__('Tap here to get some for free.')}
</Text>
<Text style={publishStyle.rewardDriverText}>Earn some credits to be able to create your channel.</Text>
</TouchableOpacity>
);
}
-2
View File
@@ -7,7 +7,6 @@ import {
doCreateChannel,
doToast,
} from 'lbry-redux';
import { doGetSync } from 'lbryinc';
import ChannelSelector from './view';
const select = state => ({
@@ -20,7 +19,6 @@ 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(
+15 -24
View File
@@ -1,7 +1,6 @@
import React from 'react';
import { CLAIM_VALUES, isNameValid } from 'lbry-redux';
import { ActivityIndicator, NativeModules, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { logPublish } from 'utils/helper';
import { ActivityIndicator, Picker, Text, TextInput, 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
@@ -87,9 +86,9 @@ export default class ChannelSelector extends React.PureComponent {
}
if (newChannelName.trim().length > 0 && !isNameValid(newChannelName)) {
newChannelNameError = __('Your channel name contains invalid characters.');
newChannelNameError = 'Your channel name contains invalid characters.';
} else if (this.channelExists(newChannelName)) {
newChannelNameError = __('You have already created a channel with the same name.');
newChannelNameError = 'You have already created a channel with the same name.';
}
this.setState({
@@ -118,21 +117,21 @@ export default class ChannelSelector extends React.PureComponent {
};
handleCreateChannelClick = () => {
const { balance, createChannel, getSync, onChannelChange, notify } = this.props;
const { balance, createChannel, onChannelChange, notify } = this.props;
const { newChannelBid, newChannelName } = this.state;
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
notify({ message: __('Your channel name contains invalid characters.') });
notify({ message: 'Your channel name contains invalid characters.' });
return;
}
if (this.channelExists(newChannelName)) {
notify({ message: __('You have already created a channel with the same name.') });
notify({ message: 'You have already created a channel with the same name.' });
return;
}
if (newChannelBid > balance) {
notify({ message: __('Deposit cannot be higher than your balance') });
notify({ message: 'Deposit cannot be higher than your balance' });
return;
}
@@ -143,25 +142,21 @@ export default class ChannelSelector extends React.PureComponent {
createChannelError: undefined,
});
const success = channelClaim => {
const success = () => {
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 = () => {
notify({ message: __('Unable to create channel due to an internal error.') });
notify({ message: 'Unable to create channel due to an internal error.' });
this.setState({
creatingChannel: false,
});
@@ -214,11 +209,7 @@ export default class ChannelSelector extends React.PureComponent {
onValueChange={this.handlePickerValueChange}
>
{pickerItems.map(item => (
<Picker.Item
label={[Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].includes(item) ? __(item) : item}
value={item}
key={item}
/>
<Picker.Item label={item} value={item} key={item} />
))}
</Picker>
@@ -231,7 +222,7 @@ export default class ChannelSelector extends React.PureComponent {
style={channelSelectorStyle.channelNameInput}
value={this.state.newChannelName}
onChangeText={this.handleNewChannelNameChange}
placeholder={__('Channel name')}
placeholder={'Channel name'}
underlineColorAndroid={Colors.NextLbryGreen}
/>
</View>
@@ -239,7 +230,7 @@ export default class ChannelSelector extends React.PureComponent {
<Text style={channelSelectorStyle.inlineError}>{newChannelNameError}</Text>
)}
<View style={channelSelectorStyle.bidRow}>
<Text style={channelSelectorStyle.label}>{__('Deposit')}</Text>
<Text style={channelSelectorStyle.label}>Deposit</Text>
<TextInput
style={channelSelectorStyle.bidAmountInput}
value={String(newChannelBid)}
@@ -251,18 +242,18 @@ export default class ChannelSelector extends React.PureComponent {
<Text style={channelSelectorStyle.currency}>LBC</Text>
</View>
<Text style={channelSelectorStyle.helpText}>
{__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')}
This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.
</Text>
<View style={channelSelectorStyle.buttonContainer}>
{creatingChannel && <ActivityIndicator size={'small'} color={Colors.LbryGreen} />}
{!creatingChannel && (
<View style={channelSelectorStyle.buttons}>
<Link style={channelSelectorStyle.cancelLink} text={__('Cancel')} onPress={this.handleCreateCancel} />
<Link style={channelSelectorStyle.cancelLink} text="Cancel" onPress={this.handleCreateCancel} />
<Button
style={channelSelectorStyle.createButton}
disabled={!(newChannelName.trim().length > 0 && newChannelBid > 0)}
text={__('Create')}
text="Create"
onPress={this.handleCreateChannelClick}
/>
</View>
+2 -4
View File
@@ -12,7 +12,7 @@ import claimListStyle from 'styles/claimList';
import discoverStyle from 'styles/discover';
import moment from 'moment';
const horizontalLimit = 10;
const horizontalLimit = 7;
const softLimit = 500;
class ClaimList extends React.PureComponent {
@@ -155,9 +155,7 @@ class ClaimList extends React.PureComponent {
verticalListEmptyComponent = () => {
return (
<Text style={claimListStyle.noContentText}>
{__('No content to display at this time. Please check back later.')}
</Text>
<Text style={claimListStyle.noContentText}>No content to display at this time. Please check back later.</Text>
);
};
+5 -5
View File
@@ -20,7 +20,7 @@ class CustomRewardCard extends React.PureComponent<Props> {
if (error && error.trim().length > 0) {
notify({ message: error });
} else {
notify({ message: __('Reward successfully claimed!') });
notify({ message: 'Reward successfully claimed!' });
this.setState({ rewardCode: '' });
}
this.setState({ claimStarted: false });
@@ -37,12 +37,12 @@ class CustomRewardCard extends React.PureComponent<Props> {
if (showVerification) {
showVerification();
}
notify({ message: __('Unfortunately, you are not eligible to claim this reward at this time.') });
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' });
return;
}
if (!rewardCode || rewardCode.trim().length === 0) {
notify({ message: __('Please enter a reward code to claim.') });
notify({ message: 'Please enter a reward code to claim.' });
return;
}
@@ -60,9 +60,9 @@ class CustomRewardCard extends React.PureComponent<Props> {
{rewardIsPending && <ActivityIndicator size="small" color={Colors.NextLbryGreen} />}
</View>
<View style={rewardStyle.midCol}>
<Text style={rewardStyle.rewardTitle}>{__('Custom Code')}</Text>
<Text style={rewardStyle.rewardTitle}>Custom Code</Text>
<Text style={rewardStyle.rewardDescription}>
{__('Are you a supermodel or rockstar that received a custom reward code? Claim it here.')}
Are you a supermodel or rockstar that received a custom reward code? Claim it here.
</Text>
<View>
+1 -15
View File
@@ -1,18 +1,4 @@
import { connect } from 'react-redux';
import { doFetchChannelListMine, selectMyChannelClaims } from 'lbry-redux';
import { selectUser } from 'lbryinc';
import DrawerContent from './view';
const select = state => ({
channels: selectMyChannelClaims(state),
user: selectUser(state),
});
const perform = dispatch => ({
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
});
export default connect(
select,
perform
)(DrawerContent);
export default connect()(DrawerContent);
+8 -95
View File
@@ -1,23 +1,21 @@
import React from 'react';
import { DrawerItems, SafeAreaView } from 'react-navigation';
import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import Button from 'component/button';
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 channelIconStyle from 'styles/channelIcon';
import discoverStyle from 'styles/discover';
const groupedMenuItems = {
'Find content': [
{ icon: 'hashtag', label: 'Your Tags', route: Constants.DRAWER_ROUTE_DISCOVER },
{ 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 },
{ 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 },
{ icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH },
],
Wallet: [
{ icon: 'wallet', label: 'Wallet', route: Constants.DRAWER_ROUTE_WALLET },
@@ -32,104 +30,19 @@ const groupedMenuItems = {
const groupNames = Object.keys(groupedMenuItems);
class DrawerContent extends React.PureComponent {
componentDidMount() {
const { fetchChannelListMine } = this.props;
fetchChannelListMine();
}
getAvatarImageUrl = () => {
const { channels = [] } = this.props;
if (channels) {
// get the first channel thumbnail found. In the future, allow the user to select a default channel thumbnail?
for (let i = 0; i < channels.length; i++) {
if (channels[i].value && channels[i].value.thumbnail) {
return channels[i].value.thumbnail.url;
}
}
}
return null;
};
launchSignInFlow = () => {
// for now, sync flow (email, then password input) will be the default sign in flow
const { navigation } = this.props;
navigation.navigate({
routeName: 'Verification',
key: 'verification',
params: { syncFlow: true, signInFlow: true },
});
};
render() {
const { activeTintColor, navigation, user, onItemPress } = this.props;
const { activeTintColor, navigation, onItemPress } = this.props;
const { state } = navigation;
const activeItemKey = state.routes[state.index] ? state.routes[state.index].key : null;
const signedIn = user && user.has_verified_email;
const avatarImageUrl = this.getAvatarImageUrl();
return (
<View style={discoverStyle.drawerContentArea}>
{false && (
<View style={discoverStyle.signInContainer}>
{!signedIn && (
<Button
style={discoverStyle.signInButton}
theme={'light'}
text={__('Sign in')}
onPress={this.launchSignInFlow}
/>
)}
{signedIn && (
<View style={discoverStyle.signedIn}>
<View style={discoverStyle.signedInAvatar}>
{avatarImageUrl && (
<Image
style={discoverStyle.signedInAvatarImage}
resizeMode={'cover'}
source={{ uri: avatarImageUrl }}
/>
)}
{!avatarImageUrl && (
<Text style={channelIconStyle.autothumbCharacter}>
{user.primary_email.substring(0, 1).toUpperCase()}
</Text>
)}
</View>
<Text style={discoverStyle.signedInEmail} numberOfLines={1}>
{user.primary_email}
</Text>
</View>
)}
</View>
)}
<ScrollView contentContainerStyle={discoverStyle.menuScrollContent}>
<SafeAreaView
style={discoverStyle.drawerContentContainer}
forceInset={{ top: 'always', horizontal: 'never' }}
>
{!signedIn && (
<TouchableOpacity
accessible
accessibilityLabel={__('Sign In')}
onPress={this.launchSignInFlow}
delayPressIn={0}
style={[discoverStyle.signInMenuItem, discoverStyle.signInMenuItemButton]}
>
<Text style={discoverStyle.signInMenuItemButtonText}>{__('SIGN IN')}</Text>
</TouchableOpacity>
)}
{signedIn && (
<View style={[discoverStyle.signInMenuItem, discoverStyle.signInMenuItemBorder]}>
<Text style={discoverStyle.signInMenuItemText} numberOfLines={1}>
{user.primary_email.toUpperCase()}
</Text>
</View>
)}
{groupNames.map(groupName => {
const menuItems = groupedMenuItems[groupName];
@@ -137,7 +50,7 @@ class DrawerContent extends React.PureComponent {
<View key={groupName} style={discoverStyle.menuGroup}>
{groupNames[3] !== groupName && (
<Text key={`${groupName}-title`} style={discoverStyle.menuGroupName}>
{__(groupName)}
{groupName}
</Text>
)}
{menuItems.map(item => {
@@ -150,7 +63,7 @@ class DrawerContent extends React.PureComponent {
return (
<TouchableOpacity
accessible
accessibilityLabel={__(item.label)}
accessibilityLabel={item.label}
style={[
discoverStyle.menuItemTouchArea,
focused ? discoverStyle.menuItemTouchAreaFocused : null,
@@ -168,7 +81,7 @@ class DrawerContent extends React.PureComponent {
/>
</View>
<Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}>
{__(item.label)}
{item.label}
</Text>
</TouchableOpacity>
);
+9 -7
View File
@@ -12,8 +12,8 @@ class FileDownloadButton extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
// this.checkAvailability(nextProps.uri);
// this.restartDownload(nextProps);
//this.checkAvailability(nextProps.uri);
//this.restartDownload(nextProps);
}
restartDownload(props) {
@@ -50,11 +50,13 @@ class FileDownloadButton extends React.PureComponent {
if ((fileInfo && !fileInfo.stopped) || loading || downloading) {
const progress = fileInfo && fileInfo.written_bytes ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0,
label = fileInfo ? progress.toFixed(0) + '% complete' : __('Connecting...');
label = fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...';
return (
<View style={[style, fileDownloadButtonStyle.container]}>
<View style={{ width: `${progress}%`, backgroundColor: '#ff0000', position: 'absolute', left: 0, top: 0 }} />
<View
style={{ width: `${progress}%`, backgroundColor: '#ff0000', position: 'absolute', left: 0, top: 0 }}
></View>
<Text style={fileDownloadButtonStyle.text}>{label}</Text>
</View>
);
@@ -62,14 +64,14 @@ class FileDownloadButton extends React.PureComponent {
if (!costInfo) {
return (
<View style={[style, fileDownloadButtonStyle.container]}>
<Text style={fileDownloadButtonStyle.text}>{__('Fetching cost info...')}</Text>
<Text style={fileDownloadButtonStyle.text}>Fetching cost info...</Text>
</View>
);
}
return (
<Button
icon={isPlayable ? 'play' : null}
text={isPlayable ? __('Play') : isViewable ? __('View') : __('Download')}
text={isPlayable ? 'Play' : isViewable ? 'View' : 'Download'}
onLayout={onButtonLayout}
style={[style, fileDownloadButtonStyle.container]}
onPress={() => {
@@ -96,7 +98,7 @@ class FileDownloadButton extends React.PureComponent {
style={[style, fileDownloadButtonStyle.container]}
onPress={openFile}
>
<Text style={fileDownloadButtonStyle.text}>{isViewable ? __('View') : __('Open')}</Text>
<Text style={fileDownloadButtonStyle.text}>{isViewable ? 'View' : 'Open'}</Text>
</TouchableOpacity>
);
}
+1 -3
View File
@@ -10,15 +10,13 @@ import {
makeSelectClaimIsNsfw,
makeSelectShortUrlForUri,
} from 'lbry-redux';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { 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),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
+5 -25
View File
@@ -30,22 +30,20 @@ class FileItem extends React.PureComponent {
}
navigateToFileUri = () => {
const { claim, navigation, uri, shortUrl } = this.props;
const { navigation, uri, shortUrl } = this.props;
const normalizedUri = normalizeURI(uri);
if (NativeModules.Firebase) {
NativeModules.Firebase.track('explore_click', { uri: normalizedUri, short_url: shortUrl });
}
navigateToUri(navigation, shortUrl || uri, null, false, claim ? claim.permanent_url : null);
navigateToUri(navigation, shortUrl || uri);
};
render() {
const {
blackListedOutpoints,
claim,
title,
thumbnail,
fileInfo,
filteredOutpoints,
metadata,
isResolvingUri,
rewardedContentClaimIds,
@@ -60,19 +58,7 @@ class FileItem extends React.PureComponent {
} = 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
? filteredOutpoints
: 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
// don't display channels in the lists on the Explore page
return null;
}
@@ -124,17 +110,11 @@ class FileItem extends React.PureComponent {
style={discoverStyle.channelName}
text={channelName}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri
);
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
}}
/>
)}
{!channelName && !isResolvingUri && <Text style={discoverStyle.anonChannelName}>{__('Anonymous')}</Text>}
{!channelName && !isResolvingUri && <Text style={discoverStyle.anonChannelName}>Anonymous</Text>}
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo uri={uri} />
</View>
)}
-1
View File
@@ -61,7 +61,6 @@ class FileItemMedia extends React.PureComponent {
let style = this.props.style;
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;
+6 -14
View File
@@ -40,8 +40,8 @@ class FileListItem extends React.PureComponent {
};
componentDidMount() {
const { claim, resolveUri, uri, batchResolve } = this.props;
if (!claim && !batchResolve) {
const { claim, resolveUri, uri } = this.props;
if (!claim) {
resolveUri(uri);
}
}
@@ -59,7 +59,7 @@ class FileListItem extends React.PureComponent {
if (featuredResult && !claim) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
} else {
navigateToUri(navigation, shortUrl || uri, { autoplay }, false, claim ? claim.permanent_url : null);
navigateToUri(navigation, shortUrl || uri, { autoplay });
}
};
@@ -120,9 +120,7 @@ class FileListItem extends React.PureComponent {
shortChannelUri = signingChannel ? signingChannel.short_url : null;
if (blackListedOutpoints || filteredOutpoints) {
const outpointsToHide = !blackListedOutpoints
? filteredOutpoints
: blackListedOutpoints.concat(filteredOutpoints);
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
}
@@ -189,7 +187,7 @@ class FileListItem extends React.PureComponent {
{featuredResult && !isResolving && !claim && (
<View style={fileListStyle.titleContainer}>
<Text style={fileListStyle.featuredTitle}>{__('Nothing here. Publish something!')}</Text>
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
</View>
)}
@@ -198,13 +196,7 @@ class FileListItem extends React.PureComponent {
style={fileListStyle.publisher}
text={channel}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri
);
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
}}
/>
)}
+4 -9
View File
@@ -42,16 +42,11 @@ class CreditAmount extends React.PureComponent {
let amountText;
if (this.props.showFree && parseFloat(this.props.amount) === 0) {
amountText = __('FREE');
amountText = 'FREE';
} else {
if (this.props.label) {
const label =
typeof this.props.label === 'string'
? this.props.label
: parseFloat(amount) === 1
? __('credit')
: __('credits');
// TODO: handling singular / plural in other languages?
typeof this.props.label === 'string' ? this.props.label : parseFloat(amount) == 1 ? 'credit' : 'credits';
amountText = `${formattedAmount} ${label}`;
} else {
@@ -62,14 +57,14 @@ class CreditAmount extends React.PureComponent {
}
}
/* {this.props.isEstimate ? (
/*{this.props.isEstimate ? (
<span
className="credit-amount__estimate"
title={__('This is an estimate and does not include data fees')}
>
*
</span>
) : null} */
) : null}*/
return <Text style={style}>{amountText}</Text>;
}
}
+2 -2
View File
@@ -9,8 +9,8 @@ class FileRewardsDriver extends React.PureComponent<Props> {
return (
<TouchableOpacity style={filePageStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
<Icon name="award" size={16} style={filePageStyle.rewardDriverIcon} />
<Text style={filePageStyle.rewardDriverText}>{__('Earn some credits to access this content.')}</Text>
<Icon name="award" size={16} style={filePageStyle.rewardIcon} />
<Text style={filePageStyle.rewardDriverText}>Earn some credits to access this content.</Text>
</TouchableOpacity>
);
}
+1 -1
View File
@@ -34,7 +34,7 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
<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), 1, true)}</Text>
<Text style={floatingButtonStyle.text}>{formatCredits(parseFloat(balance), 0, true)}</Text>
)}
</TouchableOpacity>
</View>
+1 -1
View File
@@ -46,7 +46,7 @@ export default class ModalPicker extends React.PureComponent {
onPress={() => onItemSelected(item)}
>
{item.icon && <Icon style={modalPickerStyle.itemIcon} name={item.icon} size={16} />}
<Text style={modalPickerStyle.itemLabel}>{__(item.label)}</Text>
<Text style={modalPickerStyle.itemLabel}>{item.label}</Text>
{selectedItem && selectedItem.name === item.name && (
<Icon style={modalPickerStyle.itemSelected} name={'check'} color={Colors.LbryGreen} size={16} />
)}
@@ -17,7 +17,7 @@ export default class ModalSuggestedSubcriptions extends React.PureComponent {
<TouchableOpacity style={[modalStyle.container, subscriptionsStyle.modalContainer]} activeOpacity={1}>
<SuggestedSubscriptions inModal navigation={navigation} />
<View style={modalStyle.buttons}>
<Button style={modalStyle.doneButton} text={__('Done')} onPress={onDonePress} />
<Button style={modalStyle.doneButton} text={'Done'} onPress={onDonePress} />
</View>
</TouchableOpacity>
</TouchableOpacity>
+5 -4
View File
@@ -8,6 +8,7 @@ import Icon from 'react-native-vector-icons/FontAwesome5';
import Tag from 'component/tag';
import TagSearch from 'component/tagSearch';
import modalTagSelectorStyle from 'styles/modalTagSelector';
import { __ } from 'utils/helper';
const minimumTags = 2;
@@ -54,9 +55,9 @@ export default class ModalTagSelector extends React.PureComponent {
return (
<TouchableOpacity style={modalTagSelectorStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
<TouchableOpacity style={modalTagSelectorStyle.container} activeOpacity={1}>
<View style={modalTagSelectorStyle.container}>
<View style={modalTagSelectorStyle.titleRow}>
<Text style={modalTagSelectorStyle.title}>{__('Customize your tags')}</Text>
<Text style={modalTagSelectorStyle.title}>Customize your tags</Text>
</View>
<View style={modalTagSelectorStyle.tagList}>
{tags &&
@@ -72,9 +73,9 @@ export default class ModalTagSelector extends React.PureComponent {
</View>
<TagSearch handleAddTag={this.handleAddTag} selectedTags={tags} />
<View style={modalTagSelectorStyle.buttons}>
<Button style={modalTagSelectorStyle.doneButton} text={__('Done')} onPress={onDonePress} />
<Button style={modalTagSelectorStyle.doneButton} text={'Done'} onPress={onDonePress} />
</View>
</TouchableOpacity>
</View>
</TouchableOpacity>
);
}
+1 -1
View File
@@ -7,7 +7,7 @@ class NsfwOverlay extends React.PureComponent {
return (
<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.')}
This content is Not Safe For Work. To view adult content, please change your Settings.
</Text>
</TouchableOpacity>
);
+1 -5
View File
@@ -11,11 +11,7 @@ class PublishRewardsDriver extends React.PureComponent<Props> {
return (
<TouchableOpacity style={publishStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
<Icon name="award" size={16} style={publishStyle.rewardIcon} />
<Text style={publishStyle.rewardDriverText}>
{__('Publishing requires credits.')}
{'\n'}
{__('Tap here to get some for free.')}
</Text>
<Text style={publishStyle.rewardDriverText}>Earn some credits to be able to publish your content.</Text>
</TouchableOpacity>
);
}
+2 -2
View File
@@ -1,11 +1,11 @@
import { connect } from 'react-redux';
import {
doResolveUris,
makeSelectClaimForUri,
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 => ({
resolveUris: uris => dispatch(doResolveUris(uris)),
search: query => dispatch(doNativeSearch(query, 20, undefined, true)),
});
export default connect(
+35 -11
View File
@@ -8,23 +8,45 @@ import fileListStyle from 'styles/fileList';
import relatedContentStyle from 'styles/relatedContent';
export default class RelatedContent extends React.PureComponent {
state = {
urlsResolved: false,
};
constructor() {
super();
this.didSearch = undefined;
}
componentDidMount() {
this.getRecommendedContent();
}
componentDidUpdate(prevProps) {
const { resolveUris, recommendedContent } = this.props;
const { claim, uri } = this.props;
if (recommendedContent && recommendedContent.length > 0 && !this.state.urisResolved) {
this.setState({ urisResolved: true }, () => {
// batch resolve the uris
resolveUris(recommendedContent);
});
if (uri !== prevProps.uri) {
this.didSearch = false;
}
if (claim && !this.didSearch) {
this.getRecommendedContent();
}
}
getRecommendedContent() {
const { search, title } = this.props;
if (title) {
search(title);
this.didSearch = true;
}
}
didSearch;
render() {
const { recommendedContent, navigation, uri, fullUri } = this.props;
const { recommendedContent, isSearching, navigation, uri, fullUri } = this.props;
if (!isSearching && (!recommendedContent || recommendedContent.length === 0)) {
return null;
}
return (
<View style={relatedContentStyle.container}>
@@ -37,11 +59,13 @@ export default class RelatedContent extends React.PureComponent {
style={fileListStyle.item}
key={recommendedUri}
uri={recommendedUri}
batchResolve
navigation={navigation}
autoplay
/>
))}
{isSearching && (
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={relatedContentStyle.loading} />
)}
</View>
);
}
+3 -3
View File
@@ -34,7 +34,7 @@ class RewardCard extends React.PureComponent<Props> {
notify({ message: errorMessage });
clearError(reward);
} else {
notify({ message: __('Reward successfully claimed!') });
notify({ message: 'Reward successfully claimed!' });
}
this.setState({ claimStarted: false });
}
@@ -47,7 +47,7 @@ class RewardCard extends React.PureComponent<Props> {
if (showVerification) {
showVerification();
}
notify({ message: __('Unfortunately, you are not eligible to claim this reward at this time.') });
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' });
return;
}
@@ -112,7 +112,7 @@ class RewardCard extends React.PureComponent<Props> {
style={rewardStyle.link}
href={`https://explorer.lbry.com/tx/${reward.transaction_id}`}
text={reward.transaction_id.substring(0, 7)}
error={__('The transaction URL could not be opened')}
error={'The transaction URL could not be opened'}
/>
)}
</View>
+8 -24
View File
@@ -1,8 +1,8 @@
import React from 'react';
import { Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
import { NativeModules, Text, TouchableOpacity, View } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Link from 'component/link';
import Colors from 'styles/colors';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -24,42 +24,26 @@ class RewardEnrolment extends React.Component {
navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: false } });
};
onLearnMorePressed = () => {
Linking.openURL('https://lbry.com/faq/earn-credits');
};
render() {
const { fetching, navigation, unclaimedRewardAmount, user } = this.props;
return (
<View style={rewardStyle.enrollContainer}>
<View style={rewardStyle.enrollContainer} onPress>
<View style={rewardStyle.summaryRow}>
<Icon name="award" size={36} color={Colors.White} />
<Text style={rewardStyle.summaryText}>{unclaimedRewardAmount} available credits</Text>
<Text style={rewardStyle.summaryText}>{unclaimedRewardAmount} unclaimed credits</Text>
</View>
<View style={rewardStyle.onboarding}>
<Text style={rewardStyle.enrollDescText}>
{__('LBRY credits allow you to purchase content, publish content, and influence the network.')}
{'\n\n'}
{__('You get credits for free for providing an email address and taking other basic actions.')}
{'\n\n'}
<Link style={rewardStyle.learnMoreLink} text={__('Learn more')} onPress={this.onLearnMorePressed} />.
LBRY credits allow you to purchase content, publish content, and influence the network. You can start
earning credits by watching videos on LBRY.
</Text>
</View>
<View style={rewardStyle.buttonRow}>
<Link
style={rewardStyle.notInterestedLink}
text={__('Not interested')}
onPress={this.onNotInterestedPressed}
/>
<Button
style={rewardStyle.enrollButton}
theme={'light'}
text={__('Get started')}
onPress={this.onEnrollPressed}
/>
<Link style={rewardStyle.notInterestedLink} text={'Not interested'} onPress={this.onNotInterestedPressed} />
<Button style={rewardStyle.enrollButton} theme={'light'} text={'Enroll'} onPress={this.onEnrollPressed} />
</View>
</View>
);
+20
View File
@@ -0,0 +1,20 @@
import { connect } from 'react-redux';
import { doToast } from 'lbry-redux';
import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc';
import RewardSummary from './view';
const select = state => ({
unclaimedRewardAmount: selectUnclaimedRewardValue(state),
fetching: selectFetchingRewards(state),
user: selectUser(state),
});
const perform = dispatch => ({
fetchRewards: () => dispatch(doRewardList()),
notify: data => dispatch(doToast(data)),
});
export default connect(
select,
perform
)(RewardSummary);
+82
View File
@@ -0,0 +1,82 @@
import React from 'react';
import { NativeModules, Text, TouchableOpacity, View } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Colors from 'styles/colors';
import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward';
class RewardSummary extends React.Component {
static itemKey = 'rewardSummaryDismissed';
state = {
actionsLeft: 0,
dismissed: false,
};
componentDidMount() {
this.props.fetchRewards();
AsyncStorage.getItem(RewardSummary.itemKey).then(isDismissed => {
if ('true' === isDismissed) {
this.setState({ dismissed: true });
}
const { user } = this.props;
let actionsLeft = 0;
if (!user || !user.has_verified_email) {
actionsLeft++;
}
if (!user || !user.is_identity_verified) {
actionsLeft++;
}
this.setState({ actionsLeft });
});
}
onDismissPressed = () => {
AsyncStorage.setItem(RewardSummary.itemKey, 'true');
this.setState({ dismissed: true });
this.props.notify({
message: 'You can always claim your rewards from the Rewards page.',
});
};
handleSummaryPressed = () => {
const { showVerification } = this.props;
if (showVerification) {
showVerification();
}
};
render() {
const { fetching, navigation, unclaimedRewardAmount, user } = this.props;
if (!user) {
return null;
}
if (
this.state.dismissed ||
(user && user.is_reward_approved) ||
this.state.actionsLeft === 0 ||
unclaimedRewardAmount === 0
) {
return null;
}
return (
<TouchableOpacity style={rewardStyle.summaryContainer} onPress={this.handleSummaryPressed}>
<View style={rewardStyle.summaryRow}>
<Icon name="award" size={36} color={Colors.White} />
<Text style={rewardStyle.summaryText}>{unclaimedRewardAmount} unclaimed credits</Text>
</View>
<Button style={rewardStyle.dismissButton} theme={'light'} text={'Dismiss'} onPress={this.onDismissPressed} />
</TouchableOpacity>
);
}
}
export default RewardSummary;
+19
View File
@@ -0,0 +1,19 @@
import { connect } from 'react-redux';
import { NativeModules } from 'react-native';
import { doSearch, doUpdateSearchQuery } from 'lbry-redux';
import SearchInput from './view';
const perform = dispatch => ({
search: search => {
if (NativeModules.Firebase) {
NativeModules.Firebase.track('search', { query: search });
}
return dispatch(doSearch(search));
},
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query, false)),
});
export default connect(
null,
perform
)(SearchInput);
+41
View File
@@ -0,0 +1,41 @@
import React from 'react';
import { TextInput } from 'react-native';
class SearchInput extends React.PureComponent {
static INPUT_TIMEOUT = 500;
state = {
changeTextTimeout: -1,
};
handleChangeText = text => {
clearTimeout(this.state.changeTextTimeout);
if (!text || text.trim().length < 2) {
// only perform a search if 2 or more characters have been input
return;
}
const { search, updateSearchQuery } = this.props;
updateSearchQuery(text);
let timeout = setTimeout(() => {
search(text);
}, SearchInput.INPUT_TIMEOUT);
this.setState({ changeTextTimeout: timeout });
};
render() {
const { style, value } = this.props;
return (
<TextInput
style={style}
placeholder="Search"
underlineColorAndroid="transparent"
value={value}
onChangeText={text => this.handleChangeText(text)}
/>
);
}
}
export default SearchInput;
+7 -7
View File
@@ -1,9 +1,9 @@
import React from 'react';
import { normalizeURI, parseURI } from 'lbry-redux';
import { ActivityIndicator, Platform, Switch, Text, TouchableOpacity, View } from 'react-native';
import { formatBytes } from 'utils/helper';
import Colors from 'styles/colors';
import storageStatsStyle from 'styles/storageStats';
import { formatBytes } from '../../utils/helper';
import Colors from '../../styles/colors';
import storageStatsStyle from '../../styles/storageStats';
class StorageStatsCard extends React.PureComponent {
state = {
@@ -98,28 +98,28 @@ class StorageStatsCard extends React.PureComponent {
{this.state.totalAudioBytes > 0 && (
<View style={[storageStatsStyle.row, storageStatsStyle.legendItem]}>
<View style={[storageStatsStyle.legendBox, storageStatsStyle.audioDistribution]} />
<Text style={storageStatsStyle.legendText}>{__('Audio')}</Text>
<Text style={storageStatsStyle.legendText}>Audio</Text>
<Text style={storageStatsStyle.legendSize}>{formatBytes(this.state.totalAudioBytes, 2)}</Text>
</View>
)}
{this.state.totalImageBytes > 0 && (
<View style={[storageStatsStyle.row, storageStatsStyle.legendItem]}>
<View style={[storageStatsStyle.legendBox, storageStatsStyle.imageDistribution]} />
<Text style={storageStatsStyle.legendText}>{__('Images')}</Text>
<Text style={storageStatsStyle.legendText}>Images</Text>
<Text style={storageStatsStyle.legendSize}>{formatBytes(this.state.totalImageBytes, 2)}</Text>
</View>
)}
{this.state.totalVideoBytes > 0 && (
<View style={[storageStatsStyle.row, storageStatsStyle.legendItem]}>
<View style={[storageStatsStyle.legendBox, storageStatsStyle.videoDistribution]} />
<Text style={storageStatsStyle.legendText}>{__('Videos')}</Text>
<Text style={storageStatsStyle.legendText}>Videos</Text>
<Text style={storageStatsStyle.legendSize}>{formatBytes(this.state.totalVideoBytes, 2)}</Text>
</View>
)}
{this.state.totalOtherBytes > 0 && (
<View style={[storageStatsStyle.row, storageStatsStyle.legendItem]}>
<View style={[storageStatsStyle.legendBox, storageStatsStyle.otherDistribution]} />
<Text style={storageStatsStyle.legendText}>{__('Other')}</Text>
<Text style={storageStatsStyle.legendText}>Other</Text>
<Text style={storageStatsStyle.legendSize}>{formatBytes(this.state.totalOtherBytes, 2)}</Text>
</View>
)}
@@ -57,7 +57,7 @@ class SuggestedSubscriptionItem extends React.PureComponent {
style={subscriptionsStyle.suggestedItemName}
numberOfLines={1}
text={claim.name}
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri), null, false, claim.permanent_url)}
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri))}
/>
)}
{tags && (
@@ -72,9 +72,7 @@ class SuggestedSubscriptionItem extends React.PureComponent {
)}
</View>
{claim && (
<SubscribeButton style={subscriptionsStyle.suggestedItemSubscribe} uri={normalizeURI(claim.permanent_url)} />
)}
<SubscribeButton style={subscriptionsStyle.suggestedItemSubscribe} uri={normalizeURI(uri)} />
</View>
);
}
+1 -1
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
import { MATURE_TAGS, createNormalizedClaimSearchKey, normalizeURI } from 'lbry-redux';
import { navigateToUri } from 'utils/helper';
import { __, navigateToUri } from 'utils/helper';
import SubscribeButton from 'component/subscribeButton';
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
import Colors from 'styles/colors';
+1 -1
View File
@@ -89,7 +89,7 @@ export default class TagSearch extends React.PureComponent {
</KeyboardAvoidingView>
{showNsfwTags && (
<View style={tagStyle.nsfwTagsContainer}>
<Text style={tagStyle.nsfwTagsTitle}>{__('Mature tags')}</Text>
<Text style={tagStyle.nsfwTagsTitle}>Mature tags</Text>
<View style={tagStyle.tagResultsList}>
{MATURE_TAGS.map(tag => (
<Tag
@@ -2,10 +2,10 @@
import React from 'react';
import { Text, View, Linking } from 'react-native';
import { buildURI, formatCredits } from 'lbry-redux';
import { navigateToUri } from 'utils/helper';
import Link from 'component/link';
import { navigateToUri } from '../../../utils/helper';
import Link from '../../link';
import moment from 'moment';
import transactionListStyle from 'styles/transactionList';
import transactionListStyle from '../../../styles/transactionList';
class TransactionListItem extends React.PureComponent {
capitalize(string: string) {
@@ -43,14 +43,14 @@ class TransactionListItem extends React.PureComponent {
style={transactionListStyle.smallLink}
text={txid.substring(0, 8)}
href={`https://explorer.lbry.com/tx/${txid}`}
error={__('The transaction URL could not be opened')}
error={'The transaction URL could not be opened'}
/>
</View>
<View style={transactionListStyle.col}>
{date ? (
<Text style={transactionListStyle.smallText}>{moment(date).format('MMM D')}</Text>
) : (
<Text style={transactionListStyle.smallText}>{__('Pending')}</Text>
<Text style={transactionListStyle.smallText}>Pending</Text>
)}
</View>
</View>
+1 -1
View File
@@ -47,7 +47,7 @@ class TransactionList extends React.PureComponent {
return (
<View>
{!transactionList.length && (
<Text style={transactionListStyle.noTransactions}>{emptyMessage || __('No transactions to list.')}</Text>
<Text style={transactionListStyle.noTransactions}>{emptyMessage || 'No transactions to list.'}</Text>
)}
{!!transactionList.length && (
+8 -8
View File
@@ -2,11 +2,11 @@
import React from 'react';
// import BusyIndicator from 'component/common/busy-indicator';
import { Text, View } from 'react-native';
import Button from 'component/button';
import Link from 'component/link';
import TransactionList from 'component/transactionList';
import type { Transaction } from 'component/transactionList/view';
import walletStyle from 'styles/wallet';
import Button from '../button';
import Link from '../link';
import TransactionList from '../transactionList';
import type { Transaction } from '../transactionList/view';
import walletStyle from '../../styles/wallet';
type Props = {
fetchTransactions: () => void,
@@ -27,14 +27,14 @@ class TransactionListRecent extends React.PureComponent<Props> {
<View style={walletStyle.transactionsCard}>
<View style={[walletStyle.row, walletStyle.transactionsHeader]}>
<Text style={walletStyle.transactionsTitle}>Recent Transactions</Text>
<Link style={walletStyle.link} navigation={navigation} text={__('View All')} href={'#TransactionHistory'} />
<Link style={walletStyle.link} navigation={navigation} text={'View All'} href={'#TransactionHistory'} />
</View>
{fetchingTransactions && <Text style={walletStyle.infoText}>{__('Fetching transactions...')}</Text>}
{fetchingTransactions && <Text style={walletStyle.infoText}>Fetching transactions...</Text>}
{!fetchingTransactions && (
<TransactionList
navigation={navigation}
transactions={transactions.slice(0, 5)}
emptyMessage={__("Looks like you don't have any recent transactions.")}
emptyMessage={"Looks like you don't have any recent transactions."}
/>
)}
</View>
+1 -1
View File
@@ -256,7 +256,7 @@ class UriBar extends React.PureComponent {
this.setSelection();
}}
selectTextOnFocus
placeholder={__('Search movies, music, and more')}
placeholder={'Search movies, music, and more'}
underlineColorAndroid={'transparent'}
numberOfLines={1}
clearButtonMode={'while-editing'}
+5 -6
View File
@@ -27,22 +27,21 @@ class WalletAddress extends React.PureComponent<Props> {
return (
<View style={walletStyle.card}>
<Text style={walletStyle.title}>{__('Receive Credits')}</Text>
<Text style={walletStyle.title}>Receive Credits</Text>
<Text style={[walletStyle.text, walletStyle.bottomMarginMedium]}>
{__('Use this wallet address to receive credits sent by another user (or yourself).')}
Use this wallet address to receive credits sent by another user (or yourself).
</Text>
<Address address={receiveAddress} style={walletStyle.bottomMarginSmall} />
<Button
style={[walletStyle.button, walletStyle.bottomMarginLarge]}
icon={'sync'}
text={__('Get new address')}
text={'Get new address'}
onPress={getNewAddress}
disabled={gettingNewAddress}
/>
<Text style={walletStyle.smallText}>
{__(
'You can generate a new address at any time, and any previous addresses will continue to work. Using multiple addresses can be helpful for keeping track of incoming payments from multiple sources.'
)}
You can generate a new address at any time, and any previous addresses will continue to work. Using multiple
addresses can be helpful for keeping track of incoming payments from multiple sources.
</Text>
</View>
);
+2 -2
View File
@@ -16,8 +16,8 @@ class WalletBalance extends React.PureComponent<Props> {
return (
<View style={walletStyle.balanceCard}>
<Image style={walletStyle.balanceBackground} resizeMode={'cover'} source={require('../../assets/stripe.png')} />
<Text style={walletStyle.balanceTitle}>{__('Balance')}</Text>
<Text style={walletStyle.balanceCaption}>{__('You currently have')}</Text>
<Text style={walletStyle.balanceTitle}>Balance</Text>
<Text style={walletStyle.balanceCaption}>You currently have</Text>
<Text style={walletStyle.balance}>
{(balance || balance === 0) && formatCredits(parseFloat(balance), 2) + ' LBC'}
</Text>
+1 -6
View File
@@ -1,9 +1,4 @@
import { connect } from 'react-redux';
import { selectUnclaimedRewardValue } from 'lbryinc';
import WalletRewardsDriver from './view';
const select = state => ({
unclaimedRewardAmount: selectUnclaimedRewardValue(state),
});
export default connect(select)(WalletRewardsDriver);
export default connect()(WalletRewardsDriver);
+2 -5
View File
@@ -5,15 +5,12 @@ import walletStyle from 'styles/wallet';
class WalletRewardsDriver extends React.PureComponent<Props> {
render() {
const { navigation, unclaimedRewardAmount } = this.props;
const { navigation } = this.props;
return (
<TouchableOpacity style={walletStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
<Icon name="award" size={16} style={walletStyle.rewardIcon} />
<Text style={walletStyle.rewardDriverText}>
Get {unclaimedRewardAmount > 0 ? unclaimedRewardAmount : ''} free credit
{unclaimedRewardAmount === 1 ? '' : 's'} after creating an account.
</Text>
<Text style={walletStyle.rewardDriverText}>Earn credits while using the LBRY app.</Text>
</TouchableOpacity>
);
}
+11 -12
View File
@@ -38,24 +38,24 @@ class WalletSend extends React.PureComponent<Props> {
const { address, amount } = this.state;
if (address && !regexAddress.test(address)) {
notify({
message: __('The recipient address is not a valid LBRY address.'),
message: 'The recipient address is not a valid LBRY address.',
});
return;
}
if (amount > balance) {
notify({
message: __('Insufficient credits'),
message: 'Insufficient credits',
});
return;
}
if (amount && address) {
// Show confirmation before send
Alert.alert(__('Send LBC'), `Are you sure you want to send ${amount} LBC to ${address}?`, [
{ text: __('No') },
Alert.alert('Send LBC', `Are you sure you want to send ${amount} LBC to ${address}?`, [
{ text: 'No' },
{
text: __('Yes'),
text: 'Yes',
onPress: () => {
sendToAddress(address, parseFloat(amount));
this.setState({ address: null, amount: null });
@@ -69,7 +69,7 @@ class WalletSend extends React.PureComponent<Props> {
if (this.state.addressChanged && !this.state.addressValid) {
const { notify } = this.props;
notify({
message: __('The recipient address is not a valid LBRY address.'),
message: 'The recipient address is not a valid LBRY address.',
});
}
};
@@ -82,20 +82,19 @@ class WalletSend extends React.PureComponent<Props> {
render() {
const { balance } = this.props;
const canSend =
this.state.address && this.state.amount > 0 && this.state.address.trim().length > 0 && this.state.addressValid;
const canSend = this.state.address && this.state.amount > 0 && this.state.address.trim().length > 0;
return (
<View style={walletStyle.card}>
<Text style={walletStyle.title}>{__('Send Credits')}</Text>
<Text style={walletStyle.text}>{__('Recipient address')}</Text>
<Text style={walletStyle.title}>Send Credits</Text>
<Text style={walletStyle.text}>Recipient address</Text>
<View style={[walletStyle.row, walletStyle.bottomMarginMedium]}>
<TextInput
onChangeText={value =>
this.setState({
address: value,
addressChanged: true,
addressValid: value.trim().length === 0 || regexAddress.test(value),
addressValid: value.trim().length == 0 || regexAddress.test(value),
})
}
onBlur={this.handleAddressInputBlur}
@@ -112,7 +111,7 @@ class WalletSend extends React.PureComponent<Props> {
onPress={() => Clipboard.getString().then(value => this.setState({ address: value, addressChanged: true }))}
/>
</View>
<Text style={walletStyle.text}>{__('Amount')}</Text>
<Text style={walletStyle.text}>Amount</Text>
<View style={walletStyle.row}>
<View style={walletStyle.amountRow}>
<TextInput
-19
View File
@@ -1,19 +0,0 @@
import { connect } from 'react-redux';
import { doToast } from 'lbry-redux';
import { doSetClientSetting } from 'redux/actions/settings';
import { selectUser } from 'lbryinc';
import WalletSignIn from './view';
const select = state => ({
user: selectUser(state),
});
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
});
export default connect(
select,
perform
)(WalletSignIn);
-59
View File
@@ -1,59 +0,0 @@
import React from 'react';
import { Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Link from 'component/link';
import Colors from 'styles/colors';
import Icon from 'react-native-vector-icons/FontAwesome5';
import walletStyle from 'styles/wallet';
class WalletSignIn extends React.Component {
onContinuePressed = () => {
const { navigation, setClientSetting } = this.props;
setClientSetting(Constants.SETTING_ALPHA_UNDERSTANDS_RISKS, true);
};
onSignInPressed = () => {
const { navigation } = this.props;
navigation.navigate({
routeName: 'Verification',
key: 'verification',
params: { syncFlow: true, signInFlow: true },
});
};
render() {
const { navigation, user } = this.props;
return (
<View style={walletStyle.signInContainer}>
<View style={walletStyle.signInSummaryRow}>
<Text style={walletStyle.signInTitle}>Account Recommended</Text>
</View>
<View style={walletStyle.onboarding}>
<Text style={walletStyle.onboardingText}>
{__(
'An account with LBRY Inc. allows you to earn rewards, backup your wallet, and keep everything synced.'
)}
{'\n\n'}
{__('Without an account, you assume all responsibility for securing your wallet and LBRY data.')}
</Text>
</View>
<View style={walletStyle.buttonRow}>
<Link style={walletStyle.continueLink} text={__('Skip Account')} onPress={this.onContinuePressed} />
<Button
style={walletStyle.signInButton}
theme={'light'}
text={__('Sign Up')}
onPress={this.onSignInPressed}
/>
</View>
</View>
);
}
}
export default WalletSignIn;
+1 -1
View File
@@ -3,7 +3,7 @@ import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doToast } from 'lbry-redux';
import { selectUserEmail } from 'lbryinc';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import WalletSyncDriver from './view';
const select = state => ({
+15 -15
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { Alert, NativeModules, Switch, Text, View } from 'react-native';
import Button from 'component/button';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Link from 'component/link';
import walletStyle from 'styles/wallet';
@@ -15,15 +15,15 @@ class WalletSyncDriver extends React.PureComponent<Props> {
// turning off
// set deviceWalletSynced to false (if confirmed)
Alert.alert(
__('Disable wallet sync'),
__('Are you sure you want to turn off wallet sync?'),
'Disable wallet sync',
'Are you sure you want to turn off wallet sync?',
[
{ text: __('No') },
{ text: 'No' },
{
text: __('Yes'),
text: 'Yes',
onPress: () => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, false);
notify({ message: __('Wallet sync was successfully disabled.') });
notify({ message: 'Wallet sync was successfully disabled.' });
},
},
],
@@ -37,14 +37,14 @@ class WalletSyncDriver extends React.PureComponent<Props> {
return (
<View style={walletStyle.syncDriverCard}>
<Text style={walletStyle.syncDriverTitle}>{__('Wallet Sync')}</Text>
<Text style={walletStyle.syncDriverTitle}>Wallet Sync</Text>
<View style={walletStyle.switchRow}>
<View style={walletStyle.tableCol}>
<Text style={walletStyle.labelText}>{__('Sync status')}</Text>
<Text style={walletStyle.labelText}>Sync status</Text>
</View>
<View style={walletStyle.tableColRow}>
<Text selectable style={walletStyle.valueText}>
{deviceWalletSynced ? __('On') : __('Off')}
<Text selectable={true} style={walletStyle.valueText}>
{deviceWalletSynced ? 'On' : 'Off'}
</Text>
<Switch
style={walletStyle.syncSwitch}
@@ -56,11 +56,11 @@ class WalletSyncDriver extends React.PureComponent<Props> {
{deviceWalletSynced && (
<View style={walletStyle.tableRow}>
<View style={walletStyle.tableCol}>
<Text style={walletStyle.labelText}>{__('Connected email')}</Text>
<Text style={walletStyle.labelText}>Connected email</Text>
</View>
<View style={walletStyle.tableCol}>
<Text selectable style={walletStyle.valueText} numberOfLines={1}>
{userEmail || __('No connected email')}
<Text selectable={true} style={walletStyle.valueText}>
{userEmail ? userEmail : 'No connected email'}
</Text>
</View>
</View>
@@ -69,7 +69,7 @@ class WalletSyncDriver extends React.PureComponent<Props> {
<View style={walletStyle.linkRow}>
<View style={walletStyle.tableCol}>
<Link
text={__('Manual backup')}
text="Manual backup"
href="https://lbry.com/faq/how-to-backup-wallet#android"
style={walletStyle.syncDriverLink}
/>
@@ -77,7 +77,7 @@ class WalletSyncDriver extends React.PureComponent<Props> {
<View style={walletStyle.rightTableCol}>
{!deviceWalletSynced && (
<Link
text={__('Sync FAQ')}
text="Sync FAQ"
href="https://lbry.com/faq/how-to-backup-wallet#sync"
style={[walletStyle.syncDriverLink, walletStyle.rightLink]}
/>
+2 -8
View File
@@ -32,7 +32,7 @@ const Constants = {
ABOUT_TAB: 'about',
KEY_FIRST_RUN_EMAIL: 'firstRunEmail',
KEY_WALLET_PASSWORD: 'firstRunPassword',
KEY_FIRST_RUN_PASSWORD: 'firstRunPassword',
KEY_FIRST_USER_AUTH: 'firstUserAuth',
KEY_SHOULD_VERIFY_EMAIL: 'shouldVerifyEmail',
KEY_EMAIL_VERIFY_PENDING: 'emailVerifyPending',
@@ -64,8 +64,6 @@ const Constants = {
ACTION_CLEAR_PUBLISH_FORM_STATE: 'CLEAR_PUBLISH_FORM_STATE',
ACTION_CLEAR_CHANNEL_FORM_STATE: 'CLEAR_CHANNEL_FORM_STATE',
ACTION_FULLSCREEN_MODE_TOGGLED: 'FULLSCREEN_MODE_TOGGLED',
ORIENTATION_HORIZONTAL: 'horizontal',
ORIENTATION_VERTICAL: 'vertical',
@@ -129,7 +127,7 @@ const Constants = {
{ name: TIME_ALL, label: 'All time' },
],
DEFAULT_ORDER_BY: ['trending_group', 'trending_mixed'],
DEFAULT_ORDER_BY: ['trending_global', 'trending_mixed'],
ORDER_BY_EFFECTIVE_AMOUNT: 'effective_amount',
@@ -140,10 +138,6 @@ const Constants = {
MORE_PLACEHOLDER: '_more',
TRUE_STRING: 'true',
MINIMUM_TRANSACTION_BALANCE: 0.1,
SHARE_BASE_URL: 'https://open.lbry.com',
};
export default Constants;
-79
View File
@@ -1,79 +0,0 @@
import { NativeModules, Platform } from 'react-native';
import { SETTINGS } from 'lbry-redux';
import { doTransifexUpload } from 'lbryinc';
import AsyncStorage from '@react-native-community/async-storage';
import RNFS from 'react-native-fs';
const isProduction = !__DEV__; // eslint-disable-line no-undef
let knownMessages = null;
window.language = NativeModules.UtilityModule.language;
window.i18n_messages = window.i18n_messages || {};
function saveMessage(message) {
// file path that won't get wiped if app storage is cleared or the app is uninstalled
const messagesFilePath = RNFS.ExternalStorageDirectoryPath + '/lbry-app-strings.json';
if (knownMessages === null) {
RNFS.readFile(messagesFilePath, 'utf8')
.then(fileContents => {
knownMessages = JSON.parse(fileContents);
checkMessageAndSave(message, messagesFilePath);
})
.catch(err => {
knownMessages = {}; // no known messages, initialise the object
checkMessageAndSave(message, messagesFilePath);
});
} else {
checkMessageAndSave(message, messagesFilePath);
}
}
function checkMessageAndSave(message, messagesFilePath) {
if (!knownMessages[message]) {
knownMessages[message] = message;
const contents = JSON.stringify(knownMessages, null, 2);
RNFS.writeFile(messagesFilePath, contents, 'utf8')
.then(() => {
// successful write
// send to transifex (should we do this even if the file doesn't get saved?)
// TODO: load token from .env
/* doTransifexUpload(
contents,
'lbry-mobile',
'*token*',
() => {
// successful
},
err => {
// failed
}
); */
})
.catch(err => {
if (err) {
throw err;
}
});
}
}
export function __(message, tokens) {
const w = global.window ? global.window : window;
let language = w.language ? w.language : 'en';
if (!isProduction) {
saveMessage(message);
}
const translatedMessage = w.i18n_messages[language] ? w.i18n_messages[language][message] || message : message;
if (!tokens) {
return translatedMessage;
}
return translatedMessage.replace(/%([^%]+)%/g, function($1, $2) {
return tokens[$2] || $2;
});
}
+29 -61
View File
@@ -4,8 +4,6 @@ import { Provider, connect } from 'react-redux';
import { AppRegistry, Text, View, NativeModules } from 'react-native';
import {
Lbry,
buildSharedStateMiddleware,
blockedReducer,
claimsReducer,
contentReducer,
fileReducer,
@@ -15,24 +13,19 @@ 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,
@@ -40,8 +33,6 @@ import AppWithNavigationState, {
reactNavigationMiddleware,
} from 'component/AppNavigator';
import { REHYDRATE, PURGE, persistCombineReducers, persistStore } from 'redux-persist';
import { __ } from 'i18n';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import getStoredStateMigrateV4 from 'redux-persist/lib/integration/getStoredStateMigrateV4';
import FilesystemStorage from 'redux-persist-filesystem-storage';
import createCompressor from 'redux-persist-transform-compress';
@@ -51,8 +42,7 @@ import formReducer from 'redux/reducers/form';
import drawerReducer from 'redux/reducers/drawer';
import settingsReducer from 'redux/reducers/settings';
import thunk from 'redux-thunk';
window.__ = __;
import isEqual from 'utils/deep-equal';
const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) {
@@ -91,7 +81,6 @@ 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', ['claimsByUri']);
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions', 'latest']);
@@ -100,18 +89,10 @@ const tagsFilter = createFilter('tags', ['followedTags']);
const walletFilter = createFilter('wallet', ['receiveAddress']);
const v4PersistOptions = {
whitelist: ['auth', 'blocked', 'claims', 'content', 'subscriptions', 'settings', 'tags', 'wallet'],
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'tags', 'wallet'],
// Order is important. Needs to be compressed last or other transforms can't
// read the data
transforms: [
authFilter,
blockedFilter,
saveClaimsFilter,
subscriptionsFilter,
settingsFilter,
walletFilter,
compressor,
],
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
debounce: 10000,
storage: FilesystemStorage,
};
@@ -124,7 +105,6 @@ const persistOptions = Object.assign({}, v4PersistOptions, {
const reducers = persistCombineReducers(persistOptions, {
auth: authReducer,
blacklist: blacklistReducer,
blocked: blockedReducer,
claims: claimsReducer,
content: contentReducer,
costInfo: costInfoReducer,
@@ -147,45 +127,8 @@ 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 = [sharedStateMiddleware, thunk, bulkThunk, reactNavigationMiddleware];
const middleware = [thunk, bulkThunk, reactNavigationMiddleware];
// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = compose;
@@ -204,6 +147,31 @@ const persistor = persistStore(store, persistOptions, err => {
});
window.persistor = persistor;
let currentPayload;
store.subscribe(() => {
const state = store.getState();
const subscriptions = state.subscriptions.subscriptions.map(({ uri }) => uri);
const tags = state.tags.followedTags;
const newPayload = {
version: '0.1',
shared: {
subscriptions,
tags,
},
};
if (!isEqual(newPayload, currentPayload)) {
currentPayload = newPayload;
if (Lbryio.authToken) {
Lbryio.call('user_settings', 'set', { settings: JSON.stringify(newPayload) });
}
}
});
// TODO: Find i18n module that is compatible with react-native
global.__ = str => str;
class LBRYApp extends React.Component {
render() {
return (
+19 -19
View File
@@ -67,7 +67,7 @@ class AboutPage extends React.PureComponent {
render() {
const { accessToken, drawerStack, navigation, notify, popDrawerStack, userEmail } = this.props;
const loading = __('Loading...');
const loading = 'Loading...';
const ver = this.state.versionInfo ? this.state.versionInfo : null;
return (
@@ -76,20 +76,20 @@ class AboutPage extends React.PureComponent {
<ScrollView style={aboutStyle.scrollContainer}>
<Text style={aboutStyle.title}>Content Freedom</Text>
<Text style={aboutStyle.paragraph}>
{__(
'LBRY is a free, open, and community-run digital marketplace. It is a decentralized peer-to-peer content distribution platform for creators to upload and share content, and earn LBRY credits for their effort. Users will be able to find a wide selection of videos, music, ebooks and other digital content they are interested in.'
)}
LBRY is a free, open, and community-run digital marketplace. It is a decentralized peer-to-peer content
distribution platform for creators to upload and share content, and earn LBRY credits for their effort.
Users will be able to find a wide selection of videos, music, ebooks and other digital content they are
interested in.
</Text>
<View style={aboutStyle.links}>
<Link style={aboutStyle.link} href="https://lbry.com/faq/what-is-lbry" text={__('What is LBRY?')} />
<Link style={aboutStyle.link} href="https://lbry.com/faq/android-basics" text={__('Android App Basics')} />
<Link style={aboutStyle.link} href="https://lbry.com/faq" text={__('Frequently Asked Questions')} />
<Link style={aboutStyle.link} href="https://lbry.com/faq/what-is-lbry" text="What is LBRY?" />
<Link style={aboutStyle.link} href="https://lbry.com/faq/android-basics" text="Android App Basics" />
<Link style={aboutStyle.link} href="https://lbry.com/faq" text="Frequently Asked Questions" />
</View>
<Text style={aboutStyle.socialTitle}>Get Social</Text>
<Text style={aboutStyle.paragraph}>
{__(
'You can interact with the LBRY team and members of the community on Discord, Facebook, Instagram, Twitter or Reddit.'
)}
You can interact with the LBRY team and members of the community on Discord, Facebook, Instagram, Twitter or
Reddit.
</Text>
<View style={aboutStyle.links}>
<Link style={aboutStyle.link} href="https://discordapp.com/invite/Z3bERWA" text="Discord" />
@@ -99,12 +99,12 @@ class AboutPage extends React.PureComponent {
<Link style={aboutStyle.link} href="https://reddit.com/r/lbry" text="Reddit" />
<Link style={aboutStyle.link} href="https://t.me/lbryofficial" text="Telegram" />
</View>
<Text style={aboutStyle.releaseInfoTitle}>{__('App info')}</Text>
<Text style={aboutStyle.releaseInfoTitle}>App info</Text>
{userEmail && userEmail.trim().length > 0 && (
<View style={aboutStyle.verticalRow}>
<View style={aboutStyle.innerRow}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('Connected email')}</Text>
<Text style={aboutStyle.text}>Connected email</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
@@ -116,7 +116,7 @@ class AboutPage extends React.PureComponent {
<Link
style={aboutStyle.listLink}
href={`http://lbry.com/list/edit/${accessToken}`}
text={__('Update mailing preferences')}
text="Update mailing preferences"
/>
</View>
</View>
@@ -124,7 +124,7 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('App version')}</Text>
<Text style={aboutStyle.text}>App version</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
@@ -135,7 +135,7 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('LBRY SDK')}</Text>
<Text style={aboutStyle.text}>LBRY SDK</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
@@ -146,7 +146,7 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('Platform')}</Text>
<Text style={aboutStyle.text}>Platform</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
@@ -157,7 +157,7 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('Installation ID')}</Text>
<Text style={aboutStyle.text}>Installation ID</Text>
<Text selectable style={aboutStyle.lineValueText}>
{this.state.lbryId ? this.state.lbryId : loading}
</Text>
@@ -166,12 +166,12 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>{__('Logs')}</Text>
<Text style={aboutStyle.text}>Logs</Text>
</View>
<View style={aboutStyle.col}>
<Link
style={aboutStyle.listLink}
text={__('Send log')}
text="Send log"
onPress={() => {
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.shareLogFile(error => {
+10 -26
View File
@@ -13,7 +13,7 @@ import {
} from 'react-native';
import { TabView, SceneMap } from 'react-native-tab-view';
import { normalizeURI } from 'lbry-redux';
import { navigateBack, getOrderBy, formatLbryUrlForWeb } from 'utils/helper';
import { navigateBack, getOrderBy } from 'utils/helper';
import ChannelIconItem from 'component/channelIconItem';
import ClaimList from 'component/claimList';
import Colors from 'styles/colors';
@@ -36,7 +36,7 @@ class ChannelPage extends React.PureComponent {
autoStyle: null,
showSortPicker: false,
showTimePicker: false,
orderBy: ['release_time'], // sort by new by default
orderBy: Constants.DEFAULT_ORDER_BY,
activeTab: Constants.CONTENT_TAB,
};
@@ -48,9 +48,8 @@ class ChannelPage extends React.PureComponent {
}
componentDidMount() {
const { fetchChannelListMine, setSortByItem } = this.props;
const { fetchChannelListMine } = this.props;
NativeModules.Firebase.setCurrentScreen('Channel');
setSortByItem(Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1]); // sort by newest first
fetchChannelListMine();
}
@@ -74,12 +73,12 @@ class ChannelPage extends React.PureComponent {
<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>
<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>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
@@ -122,7 +121,7 @@ class ChannelPage extends React.PureComponent {
return (
<View style={channelPageStyle.aboutTab}>
<View style={channelPageStyle.busyContainer}>
<Text style={channelPageStyle.infoText}>{__('No information to display.')}</Text>
<Text style={channelPageStyle.infoText}>No information to display.</Text>
</View>
</View>
);
@@ -132,21 +131,21 @@ class ChannelPage extends React.PureComponent {
return (
<View style={channelPageStyle.aboutTab}>
{!websiteUrl && !email && !description && (
<EmptyStateView message={__("There's nothing here yet.\nPlease check back later.")} />
<EmptyStateView message={"There's nothing here yet.\nPlease check back later."} />
)}
{(websiteUrl || email || description) && (
<ScrollView style={channelPageStyle.aboutScroll} contentContainerStyle={channelPageStyle.aboutScrollContent}>
{websiteUrl && websiteUrl.trim().length > 0 && (
<View style={channelPageStyle.aboutItem}>
<Text style={channelPageStyle.aboutTitle}>{__('Website')}</Text>
<Text style={channelPageStyle.aboutTitle}>Website</Text>
<Link style={channelPageStyle.aboutText} text={websiteUrl} href={websiteUrl} />
</View>
)}
{email && email.trim().length > 0 && (
<View style={channelPageStyle.aboutItem}>
<Text style={channelPageStyle.aboutTitle}>{__('Email')}</Text>
<Text style={channelPageStyle.aboutTitle}>Email</Text>
<Link style={channelPageStyle.aboutText} text={email} href={`mailto:${email}`} />
</View>
)}
@@ -173,15 +172,6 @@ class ChannelPage extends React.PureComponent {
}
};
onSharePressed = () => {
const { claim } = this.props;
if (claim) {
const { canonical_url: canonicalUrl, short_url: shortUrl, permanent_url: permanentUrl } = claim;
const url = Constants.SHARE_BASE_URL + formatLbryUrlForWeb(canonicalUrl || shortUrl || permanentUrl);
NativeModules.UtilityModule.shareUrl(url);
}
};
onDeletePressed = () => {
const { abandonClaim, claim, navigation } = this.props;
if (claim) {
@@ -284,14 +274,8 @@ class ChannelPage extends React.PureComponent {
onPress={this.onDeletePressed}
/>
)}
<Button
style={[channelPageStyle.actionButton, channelPageStyle.shareButton]}
theme={'light'}
icon={'share-alt'}
onPress={this.onSharePressed}
/>
{!ownedChannel && <SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} />}
{false && !ownedChannel && (
{!ownedChannel && (
<SubscribeNotificationButton
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]}
uri={fullUri}
-2
View File
@@ -12,7 +12,6 @@ import {
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';
@@ -38,7 +37,6 @@ const perform = dispatch => ({
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)),
+35 -56
View File
@@ -14,7 +14,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import { navigateToUri, uploadImageAsset } from 'utils/helper';
import Button from 'component/button';
import ChannelIconItem from 'component/channelIconItem';
import ChannelRewardsDriver from 'component/channelRewardsDriver';
@@ -32,11 +32,9 @@ import channelIconStyle from 'styles/channelIcon';
import seedrandom from 'seedrandom';
export default class ChannelCreator extends React.PureComponent {
scrollView = null;
state = {
autoStyle: null,
canSave: true,
canSave: false,
claimId: null,
currentSelectedValue: Constants.ITEM_ANONYMOUS,
currentPhase: null,
@@ -163,6 +161,9 @@ export default class ChannelCreator extends React.PureComponent {
if (!fetchingChannels) {
fetchChannelListMine();
}
if (balance >= 0.1) {
this.setState({ canSave: true });
}
DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled);
@@ -375,15 +376,7 @@ export default class ChannelCreator extends React.PureComponent {
};
handleCreateChannelClick = () => {
const {
balance,
clearChannelFormState,
createChannel,
onChannelChange,
getSync,
notify,
updateChannel,
} = this.props;
const { balance, clearChannelFormState, createChannel, onChannelChange, notify, updateChannel } = this.props;
const {
claimId,
coverImageUrl,
@@ -399,16 +392,6 @@ export default class ChannelCreator extends React.PureComponent {
website,
} = this.state;
if (balance < Constants.MINIMUM_TRANSACTION_BALANCE) {
notify({
message: 'Creating a channel requires credits. Press the blue bar to get some for free.',
});
if (this.scrollView) {
this.scrollView.scrollTo({ x: 0, y: 0, animated: true });
}
return;
}
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
notify({ message: 'Your channel name contains invalid characters.' });
return;
@@ -440,7 +423,7 @@ export default class ChannelCreator extends React.PureComponent {
createChannelError: undefined,
});
const success = channelClaim => {
const success = () => {
this.setState({
creatingChannel: false,
addingChannel: false,
@@ -456,8 +439,6 @@ export default class ChannelCreator extends React.PureComponent {
clearChannelFormState();
notify({ message: 'The channel was successfully created.' });
this.showChannelList();
logPublish(channelClaim);
};
const failure = () => {
@@ -547,9 +528,9 @@ export default class ChannelCreator extends React.PureComponent {
};
handleNewChannelPress = () => {
const { pushDrawerStack } = this.props;
const { balance, pushDrawerStack } = this.props;
pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM);
this.setState({ currentPhase: Constants.PHASE_CREATE });
this.setState({ canSave: balance >= 0.1, currentPhase: Constants.PHASE_CREATE });
};
handleCreateCancel = () => {
@@ -567,7 +548,7 @@ export default class ChannelCreator extends React.PureComponent {
resetChannelCreator = () => {
this.setState({
canSave: true,
canSave: false,
claimId: null,
editMode: false,
displayName: null,
@@ -629,7 +610,7 @@ export default class ChannelCreator extends React.PureComponent {
pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM);
this.setState({
canSave: true,
canSave: balance >= 0.1,
claimId: channel.claim_id,
currentPhase: Constants.PHASE_CREATE,
displayName: value && value.title ? value.title : channel.name.substring(1),
@@ -793,8 +774,8 @@ export default class ChannelCreator extends React.PureComponent {
{currentPhase === Constants.PHASE_LIST && !fetchingChannels && !hasChannels && (
<EmptyStateView
message={__('You have not created a channel.\nStart now by creating a new channel!')}
buttonText={__('Create a channel')}
message={'You have not created a channel.\nStart now by creating a new channel!'}
buttonText={'Create a channel'}
onButtonPress={this.handleNewChannelPress}
/>
)}
@@ -807,7 +788,7 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.listFooter}>
<Button
style={channelCreatorStyle.createChannelButton}
text={__('Create a channel')}
text={'Create a channel'}
onPress={this.handleNewChannelPress}
/>
</View>
@@ -860,7 +841,7 @@ export default class ChannelCreator extends React.PureComponent {
)}
{currentPhase === Constants.PHASE_CREATE && (
<ScrollView ref={ref => (this.scrollView = ref)} style={channelCreatorStyle.createChannelContainer}>
<ScrollView style={channelCreatorStyle.createChannelContainer}>
<View style={channelCreatorStyle.imageSelectors}>
<TouchableOpacity style={channelCreatorStyle.coverImageTouchArea} onPress={this.onCoverImagePress}>
<Image
@@ -879,7 +860,7 @@ export default class ChannelCreator extends React.PureComponent {
{this.state.uploadingImage && (
<View style={channelCreatorStyle.uploadProgress}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={channelCreatorStyle.uploadText}>{__('Uploading image...')}</Text>
<Text style={channelCreatorStyle.uploadText}>Uploading image...</Text>
</View>
)}
</TouchableOpacity>
@@ -905,20 +886,20 @@ export default class ChannelCreator extends React.PureComponent {
</TouchableOpacity>
</View>
</View>
{balance < Constants.MINIMUM_TRANSACTION_BALANCE && <ChannelRewardsDriver navigation={navigation} />}
{balance < 0.1 && <ChannelRewardsDriver navigation={navigation} />}
<View style={channelCreatorStyle.card}>
<View style={channelCreatorStyle.textInputLayout}>
{(this.state.titleFocused ||
(this.state.newChannelTitle != null && this.state.newChannelTitle.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>{__('Title')}</Text>
<Text style={channelCreatorStyle.textInputTitle}>Title</Text>
)}
<TextInput
editable={canSave && !creatingChannel && !updatingChannel}
style={channelCreatorStyle.inputText}
value={this.state.newChannelTitle}
onChangeText={this.handleNewChannelTitleChange}
placeholder={this.state.titleFocused ? '' : __('Title')}
placeholder={this.state.titleFocused ? '' : 'Title'}
underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ titleFocused: true })}
onBlur={() => this.setState({ titleFocused: false })}
@@ -928,7 +909,7 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.channelInputLayout}>
{(this.state.channelNameFocused ||
(this.state.newChannelName != null && this.state.newChannelName.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>{__('Channel')}</Text>
<Text style={channelCreatorStyle.textInputTitle}>Channel</Text>
)}
<View>
<Text style={channelCreatorStyle.channelAt}>@</Text>
@@ -937,7 +918,7 @@ export default class ChannelCreator extends React.PureComponent {
style={channelCreatorStyle.channelNameInput}
value={this.state.newChannelName}
onChangeText={value => this.handleNewChannelNameChange(value, true)}
placeholder={this.state.channelNameFocused ? '' : __('Channel')}
placeholder={this.state.channelNameFocused ? '' : 'Channel'}
underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ channelNameFocused: true })}
onBlur={() => this.setState({ channelNameFocused: false })}
@@ -948,13 +929,11 @@ export default class ChannelCreator extends React.PureComponent {
<Text style={channelCreatorStyle.inlineError}>{newChannelNameError}</Text>
)}
{editMode && (
<Text style={channelCreatorStyle.helpText}>
{__('The channel name cannot be changed while editing.')}
</Text>
<Text style={channelCreatorStyle.helpText}>The channel name cannot be changed while editing.</Text>
)}
<View style={channelCreatorStyle.bidRow}>
<Text style={channelCreatorStyle.label}>{__('Deposit')}</Text>
<Text style={channelCreatorStyle.label}>Deposit</Text>
<TextInput
editable={canSave && !creatingChannel && !updatingChannel}
style={channelCreatorStyle.bidAmountInput}
@@ -967,7 +946,7 @@ export default class ChannelCreator extends React.PureComponent {
<Text style={channelCreatorStyle.currency}>LBC</Text>
</View>
<Text style={channelCreatorStyle.helpText}>
{__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')}
This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.
</Text>
</View>
@@ -976,7 +955,7 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.textInputLayout}>
{(this.state.descriptionFocused ||
(this.state.description != null && this.state.description.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>{__('Description')}</Text>
<Text style={channelCreatorStyle.textInputTitle}>Description</Text>
)}
<TextInput
editable={canSave && !creatingChannel && !updatingChannel}
@@ -984,7 +963,7 @@ export default class ChannelCreator extends React.PureComponent {
multiline
value={this.state.description}
onChangeText={this.handleDescriptionChange}
placeholder={this.state.descriptionFocused ? '' : __('Description')}
placeholder={this.state.descriptionFocused ? '' : 'Description'}
underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ descriptionFocused: true })}
onBlur={() => this.setState({ descriptionFocused: false })}
@@ -994,14 +973,14 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.textInputLayout}>
{(this.state.websiteFocused ||
(this.state.website != null && this.state.website.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>{__('Website')}</Text>
<Text style={channelCreatorStyle.textInputTitle}>Website</Text>
)}
<TextInput
editable={canSave && !creatingChannel && !updatingChannel}
style={channelCreatorStyle.inputText}
value={this.state.website}
onChangeText={this.handleWebsiteChange}
placeholder={this.state.websiteFocused ? '' : __('Website')}
placeholder={this.state.websiteFocused ? '' : 'Website'}
underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ websiteFocused: true })}
onBlur={() => this.setState({ websiteFocused: false })}
@@ -1010,14 +989,14 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.textInputLayout}>
{(this.state.emailFocused || (this.state.email != null && this.state.email.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>{__('Email')}</Text>
<Text style={channelCreatorStyle.textInputTitle}>Email</Text>
)}
<TextInput
editable={canSave && !creatingChannel && !updatingChannel}
style={channelCreatorStyle.inputText}
value={this.state.email}
onChangeText={this.handleEmailChange}
placeholder={this.state.emailFocused ? '' : __('Email')}
placeholder={this.state.emailFocused ? '' : 'Email'}
underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ emailFocused: true })}
onBlur={() => this.setState({ emailFocused: false })}
@@ -1028,7 +1007,7 @@ export default class ChannelCreator extends React.PureComponent {
{this.state.showOptionalFields && (
<View style={channelCreatorStyle.card}>
<Text style={channelCreatorStyle.cardTitle}>{__('Tags')}</Text>
<Text style={channelCreatorStyle.cardTitle}>Tags</Text>
<View style={channelCreatorStyle.tagList}>
{this.state.tags &&
this.state.tags.map(tag => (
@@ -1052,7 +1031,7 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.toggleContainer}>
<Link
text={this.state.showOptionalFields ? __('Hide optional fields') : __('Show optional fields')}
text={this.state.showOptionalFields ? 'Hide optional fields' : 'Show optional fields'}
onPress={this.handleModePressed}
style={channelCreatorStyle.modeLink}
/>
@@ -1064,11 +1043,11 @@ export default class ChannelCreator extends React.PureComponent {
)}
{!creatingChannel && !updatingChannel && (
<View style={channelCreatorStyle.buttons}>
<Link style={channelCreatorStyle.cancelLink} text={__('Cancel')} onPress={this.handleCreateCancel} />
<Link style={channelCreatorStyle.cancelLink} text="Cancel" onPress={this.handleCreateCancel} />
<Button
style={channelCreatorStyle.createButton}
disabled={!canSave || uploadingImage}
text={editMode ? __('Update') : __('Create')}
disabled={!canSave || uploadingImage || !newChannelName || newChannelName.trim().length === 0}
text={editMode ? 'Update' : 'Create'}
onPress={this.handleCreateChannelClick}
/>
</View>
+14 -15
View File
@@ -11,9 +11,10 @@ import {
View,
} from 'react-native';
import { DEFAULT_FOLLOWED_TAGS, Lbry, normalizeURI, parseURI } from 'lbry-redux';
import { formatTagTitle, getOrderBy } 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';
import ClaimList from 'component/claimList';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Colors from 'styles/colors';
@@ -175,18 +176,16 @@ class DiscoverPage extends React.PureComponent {
if (!isNaN(lastShownTime) && !isNaN(lastShownCount)) {
if (now > lastShownTime + Constants.RATING_REMINDER_INTERVAL * lastShownCount) {
Alert.alert(
__('Enjoying LBRY?'),
__(
'Are you enjoying your experience with the LBRY app? You can leave a review for us on the Play Store.'
),
'Enjoying LBRY?',
'Are you enjoying your experience with the LBRY app? You can leave a review for us on the Play Store.',
[
{
text: __('Never ask again'),
text: 'Never ask again',
onPress: () => setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true'),
},
{ text: __('Maybe later'), onPress: () => this.updateRatingReminderShown(lastShownCount) },
{ text: 'Maybe later', onPress: () => this.updateRatingReminderShown(lastShownCount) },
{
text: __('Rate app'),
text: 'Rate app',
onPress: () => {
setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true');
Linking.openURL(Constants.PLAY_STORE_URL);
@@ -213,7 +212,7 @@ class DiscoverPage extends React.PureComponent {
buildSections = () => {
return this.state.tagCollection.map(tags => ({
title: tags.length === 1 ? tags[0] : __('All tags you follow'),
title: tags.length === 1 ? tags[0] : 'All tags you follow',
data: [tags],
}));
};
@@ -237,7 +236,7 @@ class DiscoverPage extends React.PureComponent {
handleTagPress = name => {
const { navigation, sortByItem } = this.props;
if (name.toLowerCase() !== __('all tags you follow')) {
if (name.toLowerCase() !== 'all tags you follow') {
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_TAG,
key: `tagPage`,
@@ -256,18 +255,18 @@ class DiscoverPage extends React.PureComponent {
return (
<View style={discoverStyle.listHeader}>
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>{__('Your Tags')}</Text>
<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>
<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>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
@@ -275,7 +274,7 @@ class DiscoverPage extends React.PureComponent {
<Link
style={discoverStyle.customizeLink}
text={__('Customize')}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
</View>
@@ -291,7 +290,7 @@ class DiscoverPage extends React.PureComponent {
return (
<View style={discoverStyle.footer}>
<Text style={discoverStyle.footerTitle}>{__('More tags you follow')}</Text>
<Text style={discoverStyle.footerTitle}>More tags you follow</Text>
<View style={discoverStyle.footerTags}>
{remainingTags.map(tag => (
<Text
+2 -2
View File
@@ -11,7 +11,7 @@ import {
View,
ScrollView,
} from 'react-native';
import { navigateToUri, uriFromFileInfo } from 'utils/helper';
import { __, navigateToUri, uriFromFileInfo } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PageHeader from 'component/pageHeader';
@@ -156,7 +156,7 @@ class DownloadsPage extends React.PureComponent {
/>
{!fetching && !hasDownloads && (
<EmptyStateView message={__('You do not have any\ndownloaded content on this device.')} />
<EmptyStateView message={'You do not have any\ndownloaded content on this device.'} />
)}
<View style={downloadsStyle.subContainer}>
+14 -22
View File
@@ -8,7 +8,6 @@ import {
doPurchaseUri,
doDeletePurchasedUri,
doResolveUri,
doSearch,
doSendTip,
doToast,
makeSelectIsUriResolving,
@@ -18,7 +17,6 @@ import {
makeSelectContentPositionForUri,
makeSelectContentTypeForUri,
makeSelectMetadataForUri,
makeSelectRecommendedContentForUri,
makeSelectStreamingUrlForUri,
makeSelectThumbnailForUri,
makeSelectTitleForUri,
@@ -28,7 +26,6 @@ import {
selectPurchasedUris,
selectFailedPurchaseUris,
selectPurchaseUriErrorMessage,
selectIsSearching,
} from 'lbry-redux';
import {
doClaimEligiblePurchaseRewards,
@@ -45,37 +42,34 @@ import {
doStopDownloadingFile,
} from 'redux/actions/file';
import { doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doToggleFullscreenMode } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer';
import FilePage from './view';
const select = (state, props) => {
const { uri, fullUri } = props.navigation.state.params;
const contentUri = fullUri || uri;
const selectProps = { uri: contentUri };
const selectProps = { uri: props.navigation.state.params.uri };
return {
balance: selectBalance(state),
blackListedOutpoints: selectBlackListedOutpoints(state),
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(contentUri)(state),
claim: makeSelectClaimForUri(selectProps.uri)(state),
drawerStack: selectDrawerStack(state),
isResolvingUri: makeSelectIsUriResolving(contentUri)(state),
contentType: makeSelectContentTypeForUri(contentUri)(state),
costInfo: makeSelectCostInfoForUri(contentUri)(state),
metadata: makeSelectMetadataForUri(contentUri)(state),
fileInfo: makeSelectFileInfoForUri(contentUri)(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),
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
channelUri: makeSelectChannelForClaimUri(contentUri, true)(state),
position: makeSelectContentPositionForUri(contentUri)(state),
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(contentUri)(state),
thumbnail: makeSelectThumbnailForUri(contentUri)(state),
title: makeSelectTitleForUri(contentUri)(state),
recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state),
isSearchingRecommendContent: selectIsSearching(state),
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
title: makeSelectTitleForUri(selectProps.uri)(state),
};
};
@@ -95,7 +89,6 @@ const perform = dispatch => ({
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)),
resolveUri: uri => dispatch(doResolveUri(uri)),
searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)),
sendTip: (amount, claimId, isSupport, successCallback, errorCallback) =>
dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
@@ -103,7 +96,6 @@ const perform = dispatch => ({
startDownload: (uri, outpoint, fileInfo) => dispatch(doStartDownload(uri, outpoint, fileInfo)),
updateDownload: (uri, outpoint, fileInfo, progress) => dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress)),
completeDownload: (uri, outpoint, fileInfo) => dispatch(doCompleteDownload(uri, outpoint, fileInfo)),
toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)),
});
export default connect(
+56 -123
View File
@@ -6,7 +6,6 @@ import {
Alert,
DeviceEventEmitter,
Dimensions,
Image,
Linking,
NativeModules,
ScrollView,
@@ -20,7 +19,7 @@ import {
WebView,
} from 'react-native';
import { NavigationEvents } from 'react-navigation';
import { navigateBack, navigateToUri, formatLbryUrlForWeb } from 'utils/helper';
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';
@@ -61,7 +60,6 @@ class FilePage extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
attemptAutoGet: false,
autoPlayMedia: false,
autoDownloadStarted: false,
downloadButtonShown: false,
@@ -86,7 +84,6 @@ class FilePage extends React.PureComponent {
uriVars: null,
stopDownloadConfirmed: false,
streamingMode: false,
didSearchRecommended: false,
};
}
@@ -187,27 +184,12 @@ class FilePage extends React.PureComponent {
}
componentDidUpdate(prevProps) {
const {
claim,
contentType,
costInfo,
fileInfo,
isResolvingUri,
resolveUri,
navigation,
purchaseUri,
searchRecommended,
title,
} = this.props;
const { claim, contentType, fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
const { uri } = this.state;
if (!isResolvingUri && claim === undefined && uri) {
resolveUri(uri);
}
if (title && !this.state.didSearchRecommended) {
this.setState({ didSearchRecommended: true }, () => searchRecommended(title));
}
// Returned to the page. If mediaLoaded, and currentMediaInfo is different, update
if (this.state.mediaLoaded && window.currentMediaInfo && window.currentMediaInfo.uri !== this.state.uri) {
const { metadata } = this.props;
@@ -217,21 +199,6 @@ class FilePage extends React.PureComponent {
uri: this.state.uri,
};
}
// attempt to retrieve images and html/text automatically once the claim is loaded, and it's free
const mediaType = Lbry.getMediaType(contentType);
const isViewable = mediaType === 'image' || mediaType === 'text';
if (claim && costInfo && costInfo.cost === 0 && !this.state.autoGetAttempted && isViewable) {
this.setState(
{
autoGetAttempted: true,
downloadPressed: true,
autoPlayMedia: true,
stopDownloadConfirmed: false,
},
() => purchaseUri(claim.permanent_url, costInfo, true)
);
}
}
fetchFileInfo(props) {
@@ -246,25 +213,25 @@ class FilePage extends React.PureComponent {
}
}
handleFullscreenToggle = isFullscreen => {
const { toggleFullscreenMode } = this.props;
this.setState({ fullscreenMode: isFullscreen });
toggleFullscreenMode(isFullscreen);
StatusBar.setHidden(isFullscreen);
if (isFullscreen) {
// fullscreen, so change orientation to landscape mode
NativeModules.ScreenOrientation.lockOrientationLandscape();
// hide the navigation bar (on devices that have the soft navigation bar)
NativeModules.UtilityModule.hideNavigationBar();
} else {
// Switch back to portrait mode when the media is not fullscreen
NativeModules.ScreenOrientation.lockOrientationPortrait();
// hide the navigation bar (on devices that have the soft navigation bar)
NativeModules.UtilityModule.showNavigationBar();
handleFullscreenToggle = mode => {
this.setState({ fullscreenMode: mode });
StatusBar.setHidden(mode);
if (NativeModules.ScreenOrientation) {
if (mode) {
// fullscreen, so change orientation to landscape mode
NativeModules.ScreenOrientation.lockOrientationLandscape();
if (NativeModules.UtilityModule) {
// hide the navigation bar (on devices that use have soft navigation bar)
NativeModules.UtilityModule.hideNavigationBar();
}
} else {
// Switch back to portrait mode when the media is not fullscreen
NativeModules.ScreenOrientation.lockOrientationPortrait();
if (NativeModules.UtilityModule) {
// hide the navigation bar (on devices that use have soft navigation bar)
NativeModules.UtilityModule.showNavigationBar();
}
}
}
};
@@ -541,11 +508,16 @@ class FilePage extends React.PureComponent {
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 = Constants.SHARE_BASE_URL + formatLbryUrlForWeb(canonicalUrl || shortUrl || permanentUrl);
const url = 'https://lbry.tv' + this.formatLbryUrlForWeb(canonicalUrl || shortUrl || permanentUrl);
NativeModules.UtilityModule.shareUrl(url);
}
};
@@ -639,8 +611,6 @@ class FilePage extends React.PureComponent {
navigation,
position,
purchaseUri,
isSearchingRecommendContent,
recommendedContent,
thumbnail,
title,
} = this.props;
@@ -658,7 +628,7 @@ class FilePage extends React.PureComponent {
{isResolvingUri && (
<View style={filePageStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
<Text style={filePageStyle.infoText}>{__('Loading decentralized data...')}</Text>
<Text style={filePageStyle.infoText}>Loading decentralized data...</Text>
</View>
)}
{claim === null && !isResolvingUri && (
@@ -667,15 +637,15 @@ class FilePage extends React.PureComponent {
<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.')
? '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')}
message={"There's nothing at this location."}
buttonText={'Publish something here'}
onButtonPress={() =>
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_PUBLISH,
@@ -713,11 +683,10 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.pageContainer}>
<View style={filePageStyle.dmcaContainer}>
<Text style={filePageStyle.dmcaText}>
{__(
'In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.'
)}
In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked
access to this content from our applications.
</Text>
<Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text={__('Read More')} />
<Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text="Read More" />
</View>
<UriBar value={uri} navigation={navigation} />
</View>
@@ -775,7 +744,6 @@ class FilePage extends React.PureComponent {
const isWebViewable = mediaType === 'text';
const canOpen = isViewable && completed;
const localFileUri = this.localUriForFileInfo(fileInfo);
const unsupported = !isPlayable && !canOpen;
const openFile = () => {
if (mediaType === 'image') {
@@ -846,36 +814,15 @@ class FilePage extends React.PureComponent {
thumbnail={thumbnail}
/>
)}
{!unsupported &&
(!this.state.downloadButtonShown || this.state.downloadPressed) &&
!this.state.mediaLoaded && (
{(!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded && (
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={filePageStyle.loading} />
)}
{unsupported && fileInfo && completed && (
<View style={filePageStyle.unsupportedContent}>
<Image
style={filePageStyle.unsupportedContentImage}
resizeMode={'stretch'}
source={require('../../assets/gerbil-happy.png')}
/>
<View style={filePageStyle.unspportedContentTextContainer}>
<Text style={filePageStyle.unsupportedContentTitle}>{__('Unsupported Content')}</Text>
<Text style={filePageStyle.unsupportedContentText}>
Sorry, we are unable to display this content in the app. You can find the file named{' '}
<Text style={filePageStyle.unsupportedContentFilename}>{fileInfo.file_name}</Text> in your
downloads folder.
</Text>
</View>
</View>
)}
{((isPlayable && !completed && !canLoadMedia) ||
canOpen ||
(!completed && !this.state.streamingMode)) &&
!this.state.downloadPressed && (
<FileDownloadButton
uri={claim && claim.permanent_url ? claim.permanent_url : uri}
uri={uri}
style={filePageStyle.downloadButton}
openFile={openFile}
isPlayable={isPlayable}
@@ -947,7 +894,7 @@ class FilePage extends React.PureComponent {
style={[filePageStyle.actionButton, filePageStyle.editButton]}
theme={'light'}
icon={'edit'}
text={__('Edit')}
text={'Edit'}
onPress={this.onEditPressed}
/>
)}
@@ -957,7 +904,7 @@ class FilePage extends React.PureComponent {
style={filePageStyle.actionButton}
theme={'light'}
icon={'trash-alt'}
text={__('Delete')}
text={'Delete'}
onPress={this.onDeletePressed}
/>
)}
@@ -970,7 +917,7 @@ class FilePage extends React.PureComponent {
style={filePageStyle.actionButton}
icon={'stop'}
theme={'light'}
text={__('Stop Download')}
text={'Stop Download'}
onPress={this.onStopDownloadPressed}
/>
)}
@@ -1003,24 +950,16 @@ class FilePage extends React.PureComponent {
<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>
<Icon name={'share-alt'} size={24} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>Share</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>
<Icon name={'flag'} size={24} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>Report</Text>
</TouchableOpacity>
</View>
@@ -1034,19 +973,13 @@ class FilePage extends React.PureComponent {
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(shortChannelUri || fullChannelUri),
null,
false,
fullChannelUri
);
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
}}
/>
)}
{!channelName && (
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
{__('Anonymous')}
Anonymous
</Text>
)}
<DateTime
@@ -1066,6 +999,12 @@ class FilePage extends React.PureComponent {
onPress={this.onSaveFilePressed}
/>
)}
<Button
style={[filePageStyle.actionButton, filePageStyle.tipButton]}
theme={'light'}
icon={'gift'}
onPress={() => this.setState({ showTipView: true })}
/>
{channelName && (
<SubscribeButton
style={filePageStyle.actionButton}
@@ -1074,7 +1013,7 @@ class FilePage extends React.PureComponent {
hideText={false}
/>
)}
{false && channelName && (
{channelName && (
<SubscribeNotificationButton
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
uri={fullChannelUri}
@@ -1105,11 +1044,11 @@ class FilePage extends React.PureComponent {
{this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
<Link
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
text={__('Cancel')}
text={'Cancel'}
onPress={() => this.setState({ showTipView: false })}
/>
<Button
text={__('Send a tip')}
text={'Send a tip'}
style={[filePageStyle.button, filePageStyle.sendButton]}
disabled={!canSendTip || this.state.sendTipStarted}
onPress={this.handleSendTip}
@@ -1140,13 +1079,7 @@ class FilePage extends React.PureComponent {
)}
<View onLayout={this.setRelatedContentPosition} />
{isSearchingRecommendContent && (
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={filePageStyle.relatedLoading} />
)}
{!isSearchingRecommendContent && recommendedContent && recommendedContent.length > 0 && (
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
)}
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
</ScrollView>
</View>
)}
+5 -7
View File
@@ -1,14 +1,14 @@
import { connect } from 'react-redux';
import { SETTINGS, doToast } from 'lbry-redux';
import { doToast } from 'lbry-redux';
import {
doAuthenticate,
doCheckSync,
doGetSync,
doSetDefaultAccount,
doSyncApply,
doUserEmailNew,
doUserResendVerificationEmail,
selectAuthToken,
selectEmailAlreadyExists,
selectEmailNewErrorMessage,
selectEmailNewIsPending,
selectEmailToVerify,
@@ -22,19 +22,16 @@ import {
selectUser,
} from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import FirstRun from './view';
const select = state => ({
authenticating: selectAuthenticationIsPending(state),
authToken: selectAuthToken(state),
emailToVerify: selectEmailToVerify(state),
emailAlreadyExists: selectEmailAlreadyExists(state),
emailNewErrorMessage: selectEmailNewErrorMessage(state),
emailNewPending: selectEmailNewIsPending(state),
hasSyncedWallet: selectHasSyncedWallet(state),
getSyncIsPending: selectGetSyncIsPending(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
syncApplyErrorMessage: selectSyncApplyErrorMessage(state),
syncApplyIsPending: selectSyncApplyIsPending(state),
syncHash: selectSyncHash(state),
@@ -44,11 +41,12 @@ const select = state => ({
const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)),
authenticate: (appVersion, os, firebaseToken) => dispatch(doAuthenticate(appVersion, os, firebaseToken)),
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
});
@@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
import { NativeModules, Platform, Text, TextInput, View } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
class EmailCollectPage extends React.PureComponent {
@@ -44,7 +44,7 @@ class EmailCollectPage extends React.PureComponent {
const content = (
<View onLayout={() => onEmailViewLayout('collect')}>
<Text style={firstRunStyle.title}>{__('Setup account')}</Text>
<Text style={firstRunStyle.title}>Setup account</Text>
<TextInput
style={firstRunStyle.emailInput}
placeholder={this.state.placeholder}
@@ -64,10 +64,10 @@ class EmailCollectPage extends React.PureComponent {
}}
/>
<Text style={firstRunStyle.paragraph}>
{__('A lbry.tv account allows you to earn rewards, backup your wallet, and keep everything in sync.')}
An account will allow you to earn rewards and keep your account and settings synced.
</Text>
<Text style={firstRunStyle.infoParagraph}>
{__('This information is disclosed only to LBRY, Inc. and not to the LBRY network.')}
This information is disclosed only to LBRY, Inc. and not to the LBRY network.
</Text>
</View>
);
+10 -12
View File
@@ -4,7 +4,7 @@ import { ActivityIndicator, Linking, NativeModules, Platform, Switch, Text, Text
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Icon from 'react-native-vector-icons/FontAwesome5';
import firstRunStyle from 'styles/firstRun';
@@ -13,30 +13,28 @@ class EmailVerifyPage extends React.PureComponent {
const { email, notify, resendVerificationEmail } = this.props;
resendVerificationEmail(email);
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
notify({ message: __('Please follow the instructions in the email sent to your address to continue.') });
notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
};
render() {
const { onEmailViewLayout, email, emailAlreadyExists } = this.props;
const { onEmailViewLayout, email } = this.props;
const content = (
<View onLayout={() => onEmailViewLayout('verify')}>
<Text style={firstRunStyle.title}>{emailAlreadyExists ? __('Sign In') : __('Verify Email')}</Text>
<Text style={firstRunStyle.title}>Verify Email</Text>
<Text style={firstRunStyle.paragraph}>
{__('An email has been sent to')}
{'\n\n'}
{email}
{'\n\n'}
{emailAlreadyExists && __('Please click the link in the message to complete signing in')}
{!emailAlreadyExists && __('Please click the link in the message to verify your email address')}.
An email has been sent to{' '}
<Text style={firstRunStyle.nowrap} numberOfLines={1}>
{email}
</Text>
. Please follow the instructions in the message to verify your email address.
</Text>
<View style={firstRunStyle.buttonContainer}>
<Button
style={firstRunStyle.verificationButton}
theme={'light'}
text={__('Resend')}
text={'Resend'}
onPress={this.onResendPressed}
/>
</View>
@@ -12,7 +12,7 @@ import {
View,
} from 'react-native';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Icon from 'react-native-vector-icons/FontAwesome5';
import firstRunStyle from 'styles/firstRun';
@@ -28,10 +28,10 @@ class SkipAccountPage extends React.PureComponent {
<View onLayout={onSkipAccountViewLayout}>
<View style={firstRunStyle.row}>
<Icon name="exclamation-triangle" style={firstRunStyle.titleIcon} size={32} color={Colors.White} />
<Text style={firstRunStyle.title}>{__('Are you sure?')}</Text>
<Text style={firstRunStyle.title}>Are you sure?</Text>
</View>
<Text style={firstRunStyle.paragraph}>
{__('Without an account, you will not receive rewards, sync and backup services, or security updates.')}
Without an account, you will not receive rewards, sync and backup services, or security updates.
</Text>
<View style={[firstRunStyle.row, firstRunStyle.confirmContainer]}>
@@ -45,9 +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 if it is not backed up manually (see wallet page)'
)}
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>
+11 -42
View File
@@ -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'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -28,32 +28,12 @@ class WalletPage extends React.PureComponent {
walletReady: false,
hasCheckedSync: false,
revealPassword: false,
autoPassword: false,
autoLoginAttempted: false,
};
componentDidMount() {
this.checkWalletReady();
}
componentDidUpdate() {
const { hasSyncedWallet, getSyncIsPending, onPasswordChanged, autoLogin } = this.props;
if (this.state.walletReady && this.state.hasCheckedSync && !getSyncIsPending) {
if (!hasSyncedWallet && !this.state.autoPassword) {
// new account, in which case, don't ask for a password, and act as the final first run step
this.setState({ password: '', autoPassword: true });
if (onPasswordChanged) {
onPasswordChanged('', true);
}
}
if (hasSyncedWallet && !this.state.autoLoginAttempted && autoLogin) {
autoLogin();
this.setState({ autoLoginAttempted: true });
}
}
}
checkWalletReady = () => {
// make sure the sdk wallet component is ready
Lbry.status()
@@ -82,42 +62,31 @@ class WalletPage extends React.PureComponent {
};
render() {
const {
onPasswordChanged,
onWalletViewLayout,
getSyncIsPending,
hasSyncedWallet,
syncApplyIsPending,
syncApplyStarted,
syncApplyCompleted,
} = this.props;
const { onPasswordChanged, onWalletViewLayout, getSyncIsPending, hasSyncedWallet, syncApplyIsPending } = this.props;
let content;
if (!this.state.walletReady || !this.state.hasCheckedSync || getSyncIsPending) {
content = (
<View style={firstRunStyle.centered}>
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
<Text style={firstRunStyle.paragraph}>{__('Retrieving your account information...')}</Text>
<Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text>
</View>
);
} else if (syncApplyStarted || syncApplyIsPending || syncApplyCompleted) {
} else if (syncApplyIsPending) {
content = (
<View style={firstRunStyle.centered}>
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
<Text style={firstRunStyle.paragraph}>
{syncApplyIsPending ? __('Validating password') : __('Synchronizing')}...
</Text>
<Text style={firstRunStyle.paragraph}>Validating password...</Text>
</View>
);
} else if (hasSyncedWallet && this.state.autoLoginAttempted) {
// only display this view if it's not a new user (or auto-login has been attempted once)
} else {
content = (
<View onLayout={onWalletViewLayout}>
<Text style={firstRunStyle.title}>Password</Text>
<Text style={firstRunStyle.paragraph}>
{hasSyncedWallet
? __('Please enter the password you used to secure your wallet.')
: __('Please enter a password to secure your account and wallet.')}
? 'Please enter the password you used to secure your wallet.'
: 'Please enter a password to secure your account and wallet.'}
</Text>
<View style={firstRunStyle.passwordInputContainer}>
<TextInput
@@ -150,8 +119,8 @@ class WalletPage extends React.PureComponent {
<View style={firstRunStyle.passwordWarning}>
<Text style={firstRunStyle.passwordWarningText}>
{hasSyncedWallet
? __('If you did not provide a password, please press Use LBRY to continue.')
: __('You can proceed without a password, but this is not recommended.')}
? 'If you did not provide a password, please press Use LBRY to continue.'
: 'You can proceed without a password, but this is not recommended.'}
</Text>
</View>
)}
@@ -166,7 +135,7 @@ class WalletPage extends React.PureComponent {
</View>
)}
<Text style={firstRunStyle.infoParagraph}>
{__('Note: for wallet security purposes, LBRY is unable to reset your password.')}
Note: for wallet security purposes, LBRY is unable to reset your password.
</Text>
</View>
);
+26 -42
View File
@@ -3,8 +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'; // eslint-disable-line node/no-deprecated-api
import Link from 'component/link';
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
class WelcomePage extends React.PureComponent {
@@ -26,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 (firstUserAuth !== 'true') {
if ('true' !== firstUserAuth) {
// first_user_auth
NativeModules.Firebase.track('first_user_auth', null);
AsyncStorage.setItem(Constants.KEY_FIRST_USER_AUTH, 'true');
@@ -45,39 +44,31 @@ class WelcomePage extends React.PureComponent {
}
startAuthenticating = () => {
const { authenticate } = this.props;
this.setState({ authenticationStarted: true, authenticationFailed: false });
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
NativeModules.Firebase.getMessagingToken()
.then(firebaseToken => this.performAuthenticate(appVersion, firebaseToken))
.catch(() => {
this.performAuthenticate(appVersion); /* proceed without firebase */
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)
}
});
});
};
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;
@@ -87,9 +78,8 @@ class WelcomePage extends React.PureComponent {
content = (
<View>
<Text style={firstRunStyle.paragraph}>
{__(
'The LBRY servers were unreachable at this time. Please check your Internet connection and then restart the app to try again.'
)}
The LBRY servers were unreachable at this time. Please check your Internet connection and then restart the
app to try again.
</Text>
</View>
);
@@ -97,7 +87,7 @@ class WelcomePage extends React.PureComponent {
content = (
<View style={firstRunStyle.centered}>
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
<Text style={firstRunStyle.paragraph}>{__('Please wait while we get some things ready...')}</Text>
<Text style={firstRunStyle.paragraph}>Please wait while we get some things ready...</Text>
</View>
);
} else {
@@ -105,14 +95,8 @@ class WelcomePage extends React.PureComponent {
<View onLayout={onWelcomePageLayout}>
<Text style={firstRunStyle.title}>Welcome to LBRY.</Text>
<Text style={firstRunStyle.paragraph}>
{__(
'LBRY is a community-controlled content platform where you can find and publish videos, music, books, and more.'
)}
</Text>
<Text style={[firstRunStyle.infoParagraph, firstRunStyle.tosParagraph]}>
By continuing, I agree to the{' '}
<Link style={firstRunStyle.tosLink} text={'Terms of Service'} href={'https://lbry.com/termsofservice'} />{' '}
and confirm I am over the age of 13.
LBRY is a community-controlled content platform where you can find and publish videos, music, books, and
more.
</Text>
</View>
);
+52 -123
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { SETTINGS, Lbry } from 'lbry-redux';
import { Lbry } from 'lbry-redux';
import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
@@ -11,7 +11,6 @@ import EmailCollectPage from './internal/email-collect-page';
import EmailVerifyPage from './internal/email-verify-page';
import SkipAccountPage from './internal/skip-account-page';
import firstRunStyle from 'styles/firstRun';
import RNFS from 'react-native-fs';
class FirstRunScreen extends React.PureComponent {
static pages = [
@@ -30,15 +29,12 @@ class FirstRunScreen extends React.PureComponent {
enterPasswordTracked: false,
isFirstRun: false,
launchUrl: null,
languageLoaded: false,
showSkip: false,
isEmailVerified: false,
skipAccountConfirmed: false,
showBottomContainer: false,
walletPassword: '',
syncApplyStarted: false,
syncApplyCompleted: false,
language: null,
};
componentDidMount() {
@@ -48,70 +44,29 @@ class FirstRunScreen extends React.PureComponent {
}
});
NativeModules.UtilityModule.getNativeStringSetting(SETTINGS.LANGUAGE, 'en').then(language =>
this.loadLanguage(language)
);
}
if (NativeModules.FirstRun) {
NativeModules.FirstRun.isFirstRun().then(firstRun => {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
this.setState({ isFirstRun: firstRun });
loadLanguage = language => {
if (!language || language === 'en') {
this.checkFirstRun();
} else {
// Load the current language setting before doing anything
const languageFile = RNFS.ExternalDirectoryPath + '/' + language + '.json';
RNFS.readFile(languageFile, 'utf8')
.then(fileContents => {
const json = JSON.parse(fileContents);
window.language = language;
window.i18n_messages[language] = json;
// language exists, so download an update
this.downloadLanguageUpdate(language);
this.checkFirstRun();
})
.catch(err => {
// language file doesn't exist? maintain the default language
this.checkFirstRun();
});
}
};
downloadLanguageUpdate = language => {
fetch('https://lbry.com/i18n/get/lbry-mobile/app-strings/' + language + '.json')
.then(r => r.json())
.then(j => {
window.i18n_messages[language] = j;
// write the language file to the filesystem
const langFilePath = RNFS.ExternalDirectoryPath + '/' + language + '.json';
RNFS.writeFile(langFilePath, JSON.stringify(j), 'utf8');
// update state and client setting
window.language = language;
})
.catch(() => {
/* pass */
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
this.launchSplashScreen();
}
});
};
checkFirstRun = () => {
NativeModules.FirstRun.isFirstRun().then(firstRun => {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
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
this.launchSplashScreen();
}
});
};
} else {
// The first run module was not detected. Go straight to the splash screen.
this.launchSplashScreen();
}
}
componentWillReceiveProps(nextProps) {
const { emailNewErrorMessage, emailNewPending, syncApplyErrorMessage, syncApplyIsPending, user } = nextProps;
const { notify, isApplyingSync, setClientSetting } = this.props;
const { notify, isApplyingSync, setClientSetting, setDefaultAccount } = this.props;
if (this.state.emailSubmitted && !emailNewPending) {
this.setState({ emailSubmitted: false });
@@ -126,34 +81,32 @@ class FirstRunScreen extends React.PureComponent {
if (this.state.syncApplyStarted && !syncApplyIsPending) {
if (syncApplyErrorMessage && syncApplyErrorMessage.trim().length > 0) {
notify({ message: __(syncApplyErrorMessage), isError: true });
this.setState({ showBottomContainer: true, syncApplyStarted: false, syncApplyCompleted: false });
notify({ message: syncApplyErrorMessage, syncApplyStarted: false, isError: true });
this.setState({ showBottomContainer: true });
} else {
this.setState({ syncApplyCompleted: true });
// password successfully verified
NativeModules.UtilityModule.setSecureValue(
Constants.KEY_WALLET_PASSWORD,
Constants.KEY_FIRST_RUN_PASSWORD,
this.state.walletPassword ? this.state.walletPassword : ''
);
setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
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();
// unlock the wallet
Lbry.account_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' })
.then(() => this.closeFinalPage())
.catch(err =>
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })
);
},
err => {
notify({
message:
'The account restore operation could not be completed successfully. Please restart the app and try again.',
});
}
});
);
}
}
@@ -179,9 +132,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.launchUrl } })],
actions: [NavigationActions.navigate({ routeName: 'Splash', params: { launchUri: this.state.launchUri } })],
});
setTimeout(() => navigation.dispatch(resetAction), 1000);
navigation.dispatch(resetAction);
}
handleLeftButtonPressed = () => {
@@ -210,13 +163,6 @@ class FirstRunScreen extends React.PureComponent {
});
};
autoLogin = () => {
const { hasSyncedWallet } = this.props;
if (hasSyncedWallet && !this.state.syncApplyStarted) {
this.checkWalletPassword();
}
};
handleContinuePressed = () => {
const { notify, user, hasSyncedWallet } = this.props;
const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage);
@@ -231,7 +177,7 @@ class FirstRunScreen extends React.PureComponent {
}
if (Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT === this.state.currentPage && !this.state.skipAccountConfirmed) {
notify({ message: __('Please confirm that you want to use LBRY without creating an account.') });
notify({ message: 'Please confirm that you want to use LBRY without creating an account.' });
return;
}
@@ -257,7 +203,7 @@ class FirstRunScreen extends React.PureComponent {
// validate the email
if (!email || email.indexOf('@') === -1) {
return notify({
message: __('Please provide a valid email address to continue.'),
message: 'Please provide a valid email address to continue.',
});
}
@@ -322,12 +268,8 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true, showSkip: true });
};
onWalletPasswordChanged = (password, finalStep) => {
onWalletPasswordChanged = password => {
this.setState({ walletPassword: password !== null ? password : '' });
if (finalStep) {
// final step for a new user
this.setFreshPassword();
}
};
onWalletViewLayout = () => {
@@ -356,20 +298,13 @@ 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_WALLET_PASSWORD, newPassword);
if (newPassword.trim().length === 0) {
// blank password. Do not encrypt
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, newPassword);
Lbry.account_encrypt({ new_password: newPassword }).then(() => {
// fresh account, new password set
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();
});
}
});
}
};
@@ -379,11 +314,9 @@ class FirstRunScreen extends React.PureComponent {
authenticating,
authToken,
checkSync,
emailAlreadyExists,
emailNewErrorMessage,
emailNewPending,
emailToVerify,
language,
notify,
hasSyncedWallet,
getSyncIsPending,
@@ -421,7 +354,6 @@ class FirstRunScreen extends React.PureComponent {
<EmailVerifyPage
onEmailViewLayout={this.onEmailViewLayout}
email={this.state.email}
emailAlreadyExists={emailAlreadyExists}
notify={notify}
resendVerificationEmail={resendVerificationEmail}
/>
@@ -435,11 +367,8 @@ class FirstRunScreen extends React.PureComponent {
hasSyncedWallet={hasSyncedWallet}
getSyncIsPending={getSyncIsPending}
syncApplyIsPending={syncApplyIsPending}
syncApplyStarted={this.state.syncApplyStarted}
syncApplyCompleted={this.state.syncApplyCompleted}
onWalletViewLayout={this.onWalletViewLayout}
onPasswordChanged={this.onWalletPasswordChanged}
autoLogin={this.autoLogin}
/>
);
break;
@@ -472,27 +401,27 @@ class FirstRunScreen extends React.PureComponent {
<Text style={firstRunStyle.buttonText}>
«{' '}
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT === this.state.currentPage
? __('Setup account')
: __('Change email')}
? 'Setup account'
: 'Change email'}
</Text>
</TouchableOpacity>
)}
{!emailNewPending && Constants.FIRST_RUN_PAGE_EMAIL_COLLECT === this.state.currentPage && (
<TouchableOpacity style={firstRunStyle.leftButton} onPress={this.handleLeftButtonPressed}>
<Text style={firstRunStyle.smallLeftButtonText}>{__('No, thanks')} »</Text>
<Text style={firstRunStyle.smallLeftButtonText}>No, thanks »</Text>
</TouchableOpacity>
)}
{!emailNewPending && (
<TouchableOpacity style={firstRunStyle.button} onPress={this.handleContinuePressed}>
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT === this.state.currentPage && (
<Text style={firstRunStyle.smallButtonText}>{__('Use LBRY')} »</Text>
<Text style={firstRunStyle.smallButtonText}>Use LBRY »</Text>
)}
{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')} »
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? 'Use LBRY' : 'Continue'} »
</Text>
)}
</TouchableOpacity>
+1 -4
View File
@@ -5,11 +5,10 @@ import {
doToast,
doUpdatePublishForm,
selectBalance,
selectMyClaims,
selectPublishFormValues,
} from 'lbry-redux';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { doUpdatePublishFormState, doClearPublishFormState, doPendingPublishSuccess } from 'redux/actions/form';
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
@@ -19,7 +18,6 @@ const select = state => ({
balance: selectBalance(state),
drawerStack: selectDrawerStack(state),
hasFormState: selectHasPublishFormState(state),
myClaims: selectMyClaims(state),
publishFormState: selectPublishFormState(state),
publishFormValues: selectPublishFormValues(state),
});
@@ -27,7 +25,6 @@ const select = state => ({
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
clearPublishFormState: () => dispatch(doClearPublishFormState()),
pendingPublishSuccess: pendingClaim => dispatch(doPendingPublishSuccess(pendingClaim)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
publish: (success, fail) => dispatch(doPublish(success, fail)),
+55 -90
View File
@@ -17,12 +17,10 @@ import {
import { FlatGrid } from 'react-native-super-grid';
import {
isNameValid,
batchActions,
buildURI,
normalizeURI,
parseURI,
regexInvalidURI,
ACTIONS,
CLAIM_VALUES,
LICENSES,
MATURE_TAGS,
@@ -45,7 +43,7 @@ import Tag from 'component/tag';
import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import { __, navigateToUri, uploadImageAsset } from 'utils/helper';
const languages = {
en: 'English',
@@ -78,10 +76,8 @@ const languages = {
class PublishPage extends React.PureComponent {
camera = null;
scrollView = null;
state = {
canPublish: true,
canPublish: false,
canUseCamera: false,
documentPickerOpen: false,
editMode: false,
@@ -190,6 +186,7 @@ class PublishPage extends React.PureComponent {
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState(
{
canPublish: balance >= 0.1,
loadingVideos: true,
},
() => {
@@ -322,7 +319,7 @@ class PublishPage extends React.PureComponent {
};
handlePublishPressed = () => {
const { balance, notify, publish, updatePublishForm } = this.props;
const { notify, publish, updatePublishForm } = this.props;
const {
editMode,
bid,
@@ -343,29 +340,19 @@ class PublishPage extends React.PureComponent {
uri,
} = this.state;
if (balance < Constants.MINIMUM_TRANSACTION_BALANCE) {
notify({
message: __('Publishing content requires credits. Press the blue bar to get some for free.'),
});
if (this.scrollView) {
this.scrollView.scrollTo({ x: 0, y: 0, animated: true });
}
return;
}
if (!title || title.trim().length === 0) {
notify({ message: __('Please provide a title') });
notify({ message: 'Please provide a title' });
return;
}
if (!name) {
notify({ message: __('Please specify an address where people can find your content.') });
notify({ message: 'Please specify an address where people can find your content.' });
return;
}
if (!currentMedia && !editMode) {
// sanity check. normally shouldn't happen
notify({ message: __('No file selected. Please select a video or take a photo before publishing.') });
notify({ message: 'No file selected. Please select a video or take a photo before publishing.' });
return;
}
@@ -373,7 +360,7 @@ class PublishPage extends React.PureComponent {
filePath: currentMedia ? currentMedia.filePath : null,
bid: bid || 0.1,
title: title || '',
thumbnail: thumbnail || '',
thumbnail,
description: description || '',
language,
license,
@@ -396,14 +383,9 @@ class PublishPage extends React.PureComponent {
};
handlePublishSuccess = data => {
const { clearPublishFormState, navigation, notify, pendingPublishSuccess } = this.props;
const pendingClaim = data.outputs[0];
logPublish(pendingClaim);
pendingPublishSuccess(pendingClaim);
const { clearPublishFormState, navigation, notify } = this.props;
notify({
message: __('Your content was successfully published. It will be available in a few mintues.'),
message: `Your content was successfully published to ${this.state.uri}. It will be available in a few mintues.`,
});
clearPublishFormState();
this.setState({ publishStarted: false });
@@ -553,7 +535,7 @@ class PublishPage extends React.PureComponent {
handleThumbnailUploadFailure = err => {
const { notify } = this.props;
this.setState({ uploadThumbnailStarted: false });
notify({ message: __('The thumbnail could not be uploaded. Please try again.') });
notify({ message: 'The thumbnail could not be uploaded. Please try again.' });
};
onFilePicked = evt => {
@@ -586,7 +568,7 @@ class PublishPage extends React.PureComponent {
}
} else {
// could not determine the file path
notify({ message: __('The path could not be determined. Please try a different file.') });
notify({ message: 'The path could not be determined. Please try a different file.' });
}
};
@@ -701,7 +683,7 @@ class PublishPage extends React.PureComponent {
}
if (!isNameValid(name, false)) {
notify({ message: __('Your content address contains invalid characters') });
notify({ message: 'Your content address contains invalid characters' });
return;
}
@@ -731,7 +713,7 @@ class PublishPage extends React.PureComponent {
updatePublishFormState({ tags: newTags });
this.setState({ tags: newTags });
} else {
notify({ message: __(`You already added the "${tag}" tag.`) }); // TODO: tokenize i18n
notify({ message: __(`You already added the "${tag}" tag.`) });
}
};
@@ -868,7 +850,7 @@ class PublishPage extends React.PureComponent {
const { notify } = this.props;
if (this.state.thumbnailImagePickerOpen || this.state.uploadThumbnailStarted) {
if (this.state.uploadThumbnailStarted) {
notify({ message: __('A thumbnail is already being uploaded. Please wait for the upload to finish.') });
notify({ message: 'A thumbnail is already being uploaded. Please wait for the upload to finish.' });
}
return;
}
@@ -913,7 +895,7 @@ class PublishPage extends React.PureComponent {
onPress={this.handleRecordVideoPressed}
>
<Icon name="video" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>{__('Record')}</Text>
<Text style={publishStyle.actionText}>Record</Text>
</TouchableOpacity>
<View style={publishStyle.subActions}>
<TouchableOpacity
@@ -924,11 +906,11 @@ class PublishPage extends React.PureComponent {
onPress={this.handleTakePhotoPressed}
>
<Icon name="camera" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>{__('Take a photo')}</Text>
<Text style={publishStyle.actionText}>Take a photo</Text>
</TouchableOpacity>
<TouchableOpacity style={publishStyle.upload} onPress={this.handleUploadPressed}>
<Icon name="file-upload" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>{__('Upload a file')}</Text>
<Text style={publishStyle.actionText}>Upload a file</Text>
</TouchableOpacity>
</View>
</View>
@@ -936,13 +918,13 @@ class PublishPage extends React.PureComponent {
{(loadingVideos || !allThumbnailsChecked) && (
<View style={publishStyle.loadingView}>
<ActivityIndicator size="small" color={Colors.NextLbryGreen} />
<Text style={publishStyle.loadingText}>{__('Please wait while we load your videos...')}</Text>
<Text style={publishStyle.loadingText}>Please wait while we load your videos...</Text>
</View>
)}
{!loadingVideos && (!videos || videos.length === 0) && (
<View style={publishStyle.relativeCentered}>
<Text style={publishStyle.noVideos}>
{__('We could not find any videos on your device. Take a photo or record a video to get started.')}
We could not find any videos on your device. Take a photo or record a video to get started.
</Text>
</View>
)}
@@ -979,7 +961,7 @@ class PublishPage extends React.PureComponent {
this.updateThumbnailUriForMedia(currentMedia);
}
content = (
<ScrollView ref={ref => (this.scrollView = ref)} style={publishStyle.publishDetails}>
<ScrollView style={publishStyle.publishDetails}>
<TouchableOpacity style={publishStyle.mainThumbnailContainer} onPress={this.handleThumbnailPressed}>
<FastImage
style={publishStyle.mainThumbnail}
@@ -994,20 +976,20 @@ class PublishPage extends React.PureComponent {
{this.state.uploadThumbnailStarted && (
<View style={publishStyle.thumbnailUploadContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={publishStyle.thumbnailUploadText}>{__('Uploading thumbnail...')}</Text>
<Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text>
</View>
)}
</TouchableOpacity>
{balance < Constants.MINIMUM_TRANSACTION_BALANCE && <PublishRewardsDriver navigation={navigation} />}
{!this.state.canPublish && <PublishRewardsDriver navigation={navigation} />}
<View style={publishStyle.card}>
<View style={publishStyle.textInputLayout}>
{(this.state.titleFocused || (this.state.title != null && this.state.title.trim().length > 0)) && (
<Text style={publishStyle.textInputTitle}>{__('Title')}</Text>
<Text style={publishStyle.textInputTitle}>Title</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={this.state.titleFocused ? '' : __('Title')}
placeholder={this.state.titleFocused ? '' : 'Title'}
style={publishStyle.inputText}
value={this.state.title}
numberOfLines={1}
@@ -1021,12 +1003,12 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.textInputLayout}>
{(this.state.descriptionFocused ||
(this.state.description != null && this.state.description.trim().length > 0)) && (
<Text style={publishStyle.textInputTitle}>{__('Description')}</Text>
<Text style={publishStyle.textInputTitle}>Description</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
multiline
placeholder={this.state.descriptionFocused ? '' : __('Description')}
placeholder={this.state.descriptionFocused ? '' : 'Description'}
style={publishStyle.inputText}
value={this.state.description}
underlineColorAndroid={Colors.NextLbryGreen}
@@ -1038,7 +1020,7 @@ class PublishPage extends React.PureComponent {
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>{__('Tags')}</Text>
<Text style={publishStyle.cardTitle}>Tags</Text>
<View style={publishStyle.tagList}>
{this.state.tags &&
this.state.tags.map(tag => (
@@ -1055,7 +1037,7 @@ class PublishPage extends React.PureComponent {
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>{__('Channel')}</Text>
<Text style={publishStyle.cardTitle}>Channel</Text>
<ChannelSelector
enabled={this.state.canPublish && !this.state.publishStarted}
@@ -1066,16 +1048,14 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.card}>
<View style={publishStyle.titleRow}>
<Text style={publishStyle.cardTitle}>{__('Price')}</Text>
<Text style={publishStyle.cardTitle}>Price</Text>
<View style={publishStyle.switchTitleRow}>
<Switch value={this.state.priceSet} onValueChange={value => this.setState({ priceSet: value })} />
</View>
</View>
{!this.state.priceSet && (
<Text style={publishStyle.cardText}>
{__('Your content will be free. Press the toggle to set a price.')}
</Text>
<Text style={publishStyle.cardText}>Your content will be free. Press the toggle to set a price.</Text>
)}
{this.state.priceSet && (
@@ -1105,13 +1085,11 @@ class PublishPage extends React.PureComponent {
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>{__('Content address')}</Text>
<Text style={publishStyle.cardTitle}>Content address</Text>
<Text style={publishStyle.helpText}>
{__('The address where people can find your content (ex. lbry://myvideo). ')}
The address where people can find your content (ex. lbry://myvideo).
{this.state.editMode &&
__(
'You cannot change this address while editing your content. If you wish to use a new address, please republish the content.'
)}
' You cannot change this address while editing your content. If you wish to use a new address, please republish the content.'}
</Text>
<TextInput
@@ -1136,16 +1114,14 @@ class PublishPage extends React.PureComponent {
/>
<Text style={publishStyle.currency}>LBC</Text>
</View>
<Text style={publishStyle.helpText}>
{__('This LBC remains yours and the deposit can be undone at any time.')}
</Text>
<Text style={publishStyle.helpText}>This LBC remains yours and the deposit can be undone at any time.</Text>
</View>
{this.state.advancedMode && (
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>{__('Additional Options')}</Text>
<Text style={publishStyle.cardTitle}>Additional Options</Text>
<View>
<Text style={publishStyle.cardText}>{__('Language')}</Text>
<Text style={publishStyle.cardText}>Language</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.language}
@@ -1154,13 +1130,13 @@ class PublishPage extends React.PureComponent {
onValueChange={this.handleLanguageValueChange}
>
{Object.keys(languages).map(lang => (
<Picker.Item label={__(languages[lang])} value={lang} key={lang} />
<Picker.Item label={languages[lang]} value={lang} key={lang} />
))}
</Picker>
</View>
<View>
<Text style={publishStyle.cardText}>{__('License')}</Text>
<Text style={publishStyle.cardText}>License</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.license}
@@ -1168,22 +1144,18 @@ class PublishPage extends React.PureComponent {
itemStyle={publishStyle.pickerItem}
onValueChange={this.handleLicenseValueChange}
>
<Picker.Item label={__('None')} value={LICENSES.NONE} key={LICENSES.NONE} />
<Picker.Item
label={__('Public Domain')}
value={LICENSES.PUBLIC_DOMAIN}
key={LICENSES.PUBLIC_DOMAIN}
/>
<Picker.Item label={'None'} value={LICENSES.NONE} key={LICENSES.NONE} />
<Picker.Item label={'Public Domain'} value={LICENSES.PUBLIC_DOMAIN} key={LICENSES.PUBLIC_DOMAIN} />
{LICENSES.CC_LICENSES.map(({ value, url }) => (
<Picker.Item label={value} value={value} key={value} />
))}
<Picker.Item label={__('Copyrighted...')} value={LICENSES.COPYRIGHT} key={LICENSES.COPYRIGHT} />
<Picker.Item label={__('Other...')} value={LICENSES.OTHER} key={LICENSES.OTHER} />
<Picker.Item label={'Copyrighted...'} value={LICENSES.COPYRIGHT} key={LICENSES.COPYRIGHT} />
<Picker.Item label={'Other...'} value={LICENSES.OTHER} key={LICENSES.OTHER} />
</Picker>
{[LICENSES.COPYRIGHT, LICENSES.OTHER].includes(this.state.license) && (
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={__('License description')}
placeholder={'License description'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
@@ -1197,7 +1169,7 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.toggleContainer}>
<Link
text={this.state.advancedMode ? __('Hide extra fields') : __('Show extra fields')}
text={this.state.advancedMode ? 'Hide extra fields' : 'Show extra fields'}
onPress={this.handleModePressed}
style={publishStyle.modeLink}
/>
@@ -1211,15 +1183,15 @@ class PublishPage extends React.PureComponent {
)}
{!this.state.publishStarted && (
<Link style={publishStyle.cancelLink} text={__('Cancel')} onPress={() => this.showSelector()} />
<Link style={publishStyle.cancelLink} text="Cancel" onPress={() => this.showSelector()} />
)}
{!this.state.publishStarted && (
<View style={publishStyle.rightActionButtons}>
<Button
style={publishStyle.publishButton}
disabled={this.state.uploadThumbnailStarted}
text={this.state.editMode ? __('Save changes') : __('Publish')}
disabled={!this.state.canPublish || this.state.uploadThumbnailStarted}
text={this.state.editMode ? 'Save changes' : 'Publish'}
onPress={this.handlePublishPressed}
/>
</View>
@@ -1231,10 +1203,8 @@ class PublishPage extends React.PureComponent {
content = (
<ScrollView style={publishStyle.publishDetails}>
<View style={publishStyle.successContainer}>
<Text style={publishStyle.successTitle}>{__('Success!')}</Text>
<Text style={publishStyle.successText}>
{__('Congratulations! Your content was successfully uploaded.')}
</Text>
<Text style={publishStyle.successTitle}>Success!</Text>
<Text style={publishStyle.successText}>Congratulations! Your content was successfully uploaded.</Text>
<View style={publishStyle.successRow}>
<Link
style={publishStyle.successUrl}
@@ -1244,24 +1214,19 @@ class PublishPage extends React.PureComponent {
<TouchableOpacity
onPress={() => {
Clipboard.setString(this.state.uri);
notify({ message: __('Copied.') });
notify({ message: 'Copied.' });
}}
>
<Icon name="clipboard" size={24} color={Colors.LbryGreen} />
</TouchableOpacity>
</View>
<Text style={publishStyle.successText}>
{__(
'Your content will be live in a few minutes. In the mean time, feel free to publish more content or explore the app.'
)}
Your content will be live in a few minutes. In the mean time, feel free to publish more content or explore
the app.
</Text>
</View>
<View style={publishStyle.actionButtons}>
<Button
style={publishStyle.publishButton}
text={__('Publish again')}
onPress={this.handlePublishAgainPressed}
/>
<Button style={publishStyle.publishButton} text="Publish again" onPress={this.handlePublishAgainPressed} />
</View>
</ScrollView>
);
@@ -1299,7 +1264,7 @@ class PublishPage extends React.PureComponent {
}}
notAuthorizedView={
<View style={publishStyle.fullCentered}>
<Text style={publishStyle.cameraInfo}>{__('Camera not authorized')}</Text>
<Text style={publishStyle.cameraInfo}>Camera not authorized</Text>
</View>
}
/>
-4
View File
@@ -3,9 +3,7 @@ import {
doAbandonClaim,
doCheckPendingPublishes,
doFetchClaimListMine,
doToast,
selectMyClaimUrisWithoutChannels,
selectPendingClaims,
selectIsFetchingClaimListMine,
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
@@ -15,14 +13,12 @@ import PublishesPage from './view';
const select = state => ({
uris: selectMyClaimUrisWithoutChannels(state),
fetching: selectIsFetchingClaimListMine(state),
pendingClaims: selectPendingClaims(state),
});
const perform = dispatch => ({
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
checkPendingPublishes: () => dispatch(doCheckPendingPublishes()),
notify: data => dispatch(doToast(data)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISHES)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
});
+3 -12
View File
@@ -8,7 +8,7 @@ import FileListItem from 'component/fileListItem';
import FloatingWalletBalance from 'component/floatingWalletBalance';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { navigateToUri } from 'utils/helper';
import { __, navigateToUri } from 'utils/helper';
class PublishesPage extends React.PureComponent {
state = {
@@ -54,8 +54,6 @@ class PublishesPage extends React.PureComponent {
};
addOrRemoveItem = (uri, claim) => {
const { pendingClaims } = this.state;
const { selectedClaimsMap } = this.state;
let selectedUris = [...this.state.selectedUris];
@@ -174,15 +172,8 @@ class PublishesPage extends React.PureComponent {
if (selectionMode) {
this.handleSelectItem(item, claim);
} else {
const { notify, pendingClaims } = this.props;
if (pendingClaims.some(pendingClaim => pendingClaim.claim_id === claim.claim_id)) {
notify({
message: __('This content is currently pending. It will be available in a few minutes.'),
});
} else {
// TODO: when shortUrl is available for my claims, navigate to that URL instead
navigateToUri(navigation, item);
}
// TODO: when shortUrl is available for my claims, navigate to that URL instead
navigateToUri(navigation, item);
}
}}
onLongPress={claim => this.handleItemLongPress(item, claim)}
+4 -6
View File
@@ -8,6 +8,7 @@ import CustomRewardCard from 'component/customRewardCard';
import PageHeader from 'component/pageHeader';
import RewardCard from 'component/rewardCard';
import RewardEnrolment from 'component/rewardEnrolment';
import RewardSummary from 'component/rewardSummary';
import UriBar from 'component/uriBar';
import rewardStyle from 'styles/reward';
@@ -106,8 +107,7 @@ class RewardsPage extends React.PureComponent {
<View style={[rewardStyle.card, rewardStyle.verification]}>
<Text style={rewardStyle.title}>Manual Reward Verification</Text>
<Text style={rewardStyle.text}>
__('You need to be manually verified before you can start claiming rewards.') Please request to be verified
on the{' '}
You need to be manually verified before you can start claiming rewards. Please request to be verified on the{' '}
<Link
style={rewardStyle.greenLink}
href="https://discordapp.com/invite/Z3bERWA"
@@ -130,15 +130,13 @@ class RewardsPage extends React.PureComponent {
return (
<View style={rewardStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
<Text style={rewardStyle.infoText}>{__('Fetching rewards...')}</Text>
<Text style={rewardStyle.infoText}>Fetching rewards...</Text>
</View>
);
} else if (user === null) {
return (
<View style={rewardStyle.busyContainer}>
<Text style={rewardStyle.infoText}>
{__('This app is unable to earn rewards due to an authentication failure.')}
</Text>
<Text style={rewardStyle.infoText}>This app is unable to earn rewards due to an authentication failure.</Text>
</View>
);
}
+1 -5
View File
@@ -1,10 +1,8 @@
import { connect } from 'react-redux';
import {
doClaimSearch,
doSearch,
doUpdateSearchQuery,
makeSelectSearchUris,
selectClaimSearchByQuery,
selectIsSearching,
selectSearchValue,
makeSelectQueryWithOptions,
@@ -15,10 +13,9 @@ import { selectCurrentRoute } from 'redux/selectors/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import SearchPage from './view';
const numSearchResults = 25;
const numSearchResults = 50;
const select = state => ({
claimSearchByQuery: selectClaimSearchByQuery(state),
currentRoute: selectCurrentRoute(state),
isSearching: selectIsSearching(state),
query: selectSearchValue(state),
@@ -28,7 +25,6 @@ const select = state => ({
const perform = dispatch => ({
search: query => dispatch(doSearch(query, numSearchResults)),
claimSearch: options => dispatch(doClaimSearch(options)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+7 -58
View File
@@ -1,15 +1,6 @@
import React from 'react';
import { Lbry, createNormalizedClaimSearchKey, parseURI, normalizeURI, isURIValid } from 'lbry-redux';
import {
ActivityIndicator,
Button,
FlatList,
NativeModules,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import { Lbry, parseURI, normalizeURI, isURIValid } from 'lbry-redux';
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'; // eslint-disable-line node/no-deprecated-api
@@ -23,9 +14,6 @@ class SearchPage extends React.PureComponent {
state = {
currentQuery: null,
currentUri: null,
showTagResult: false,
claimSearchRun: false,
claimSearchOptions: null,
};
static navigationOptions = {
@@ -55,9 +43,6 @@ class SearchPage extends React.PureComponent {
this.setState({
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
claimSearchOptions: null,
claimSearchRun: false,
showTagResult: false,
});
search(searchQuery);
}
@@ -95,12 +80,7 @@ class SearchPage extends React.PureComponent {
handleSearchSubmitted = keywords => {
const { search } = this.props;
this.setState({
currentUri: isURIValid(keywords) ? normalizeURI(keywords) : null,
claimSearchOptions: null,
claimSearchRun: false,
showTagResult: false,
});
this.setState({ currentUri: isURIValid(keywords) ? normalizeURI(keywords) : null });
search(keywords);
};
@@ -116,45 +96,15 @@ class SearchPage extends React.PureComponent {
);
};
listHeaderComponent = showTagResult => {
const { navigation, claimSearch, claimSearchByQuery } = this.props;
listHeaderComponent = () => {
const { navigation } = this.props;
const { currentUri } = this.state;
const query = this.getSearchQuery();
const canBeTag = query && query.trim().length > 0 && isURIValid(query);
if (canBeTag && !this.state.claimSearchRun) {
const options = {
any_tags: [query],
page: 1,
no_totals: true,
};
this.setState({ claimSearchOptions: options, claimSearchRun: true }, () => claimSearch(options));
}
if (this.state.claimSearchRun && this.state.claimSearchOptions) {
const claimSearchKey = createNormalizedClaimSearchKey(this.state.claimSearchOptions);
const claimSearchUris = claimSearchByQuery[claimSearchKey];
this.setState({ showTagResult: claimSearchUris && claimSearchUris.length > 0 });
}
return (
<View>
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
{showTagResult && (
<TouchableOpacity style={searchStyle.tagResultItem} onPress={() => this.handleTagResultPressed(query)}>
<Text style={searchStyle.tagResultTitle}>#{query.toLowerCase()}</Text>
<Text style={searchStyle.tagResultDescription}>{__('Explore content for this tag')}</Text>
</TouchableOpacity>
)}
</View>
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
);
};
handleTagResultPressed = tag => {
const { navigation } = this.props;
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: `tagPage`, params: { tag: tag.toLowerCase() } });
};
render() {
const { isSearching, navigation, query, uris, urisByQuery } = this.props;
@@ -169,7 +119,6 @@ class SearchPage extends React.PureComponent {
)}
<FlatList
extraData={this.state}
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
@@ -179,7 +128,7 @@ class SearchPage extends React.PureComponent {
maxToRenderPerBatch={20}
removeClippedSubviews
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent(this.state.showTagResult) : null}
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent() : null}
renderItem={({ item }) => (
<FileListItem key={item} uri={item} style={searchStyle.resultItem} navigation={navigation} />
)}
+1 -7
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { SETTINGS, doToast } from 'lbry-redux';
import { SETTINGS } from 'lbry-redux';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doSetClientSetting } from 'redux/actions/settings';
import { selectCurrentRoute, selectDrawerStack } from 'redux/selectors/drawer';
@@ -12,17 +12,11 @@ const select = state => ({
currentRoute: selectCurrentRoute(state),
drawerStack: selectDrawerStack(state),
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
showUriBarSuggestions: makeSelectClientSetting(SETTINGS.SHOW_URI_BAR_SUGGESTIONS)(state),
receiveSubscriptionNotifications: makeSelectClientSetting(SETTINGS.RECEIVE_SUBSCRIPTION_NOTIFICATIONS)(state),
receiveRewardNotifications: makeSelectClientSetting(SETTINGS.RECEIVE_REWARD_NOTIFICATIONS)(state),
receiveInterestsNotifications: makeSelectClientSetting(SETTINGS.RECEIVE_INTERESTS_NOTIFICATIONS)(state),
receiveCreatorNotifications: makeSelectClientSetting(SETTINGS.RECEIVE_CREATOR_NOTIFICATIONS)(state),
});
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SETTINGS)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
+17 -195
View File
@@ -1,33 +1,12 @@
import React from 'react';
import { SETTINGS } from 'lbry-redux';
import { ActivityIndicator, Picker, Platform, Text, View, ScrollView, Switch, NativeModules } from 'react-native';
import { Text, View, ScrollView, Switch, NativeModules } from 'react-native';
import { navigateBack } 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
import PageHeader from 'component/pageHeader';
import RNFS from 'react-native-fs';
import settingsStyle from 'styles/settings';
const languageOptions = [
{ code: 'default', name: 'Use device language' },
{ code: 'en', name: 'English' },
{ code: 'gu', name: 'Gujarati' },
{ code: 'hi', name: 'Hindi' },
{ code: 'id', name: 'Indonesian' },
{ code: 'it', name: 'Italian' },
{ code: 'ms', name: 'Malay' },
{ code: 'tr', name: 'Turkish' },
{ code: 'pl', name: 'Polish' },
{ code: 'pt', name: 'Portuguese' },
{ code: 'es', name: 'Spanish' },
];
class SettingsPage extends React.PureComponent {
state = {
downloadingLanguage: false,
};
static navigationOptions = {
title: 'Settings',
};
@@ -64,102 +43,32 @@ class SettingsPage extends React.PureComponent {
}
}
setNativeBooleanSetting = (key, value) => {
const { setClientSetting } = this.props;
setClientSetting(key, value);
NativeModules.UtilityModule.setNativeBooleanSetting(key, value);
};
getBooleanSetting = (value, defaultValue) => {
return value === null || value === undefined ? defaultValue : value;
};
handleLanguageValueChange = value => {
const { notify, setClientSetting } = this.props;
let language;
if (value === 'default') {
language =
Platform.OS === 'android'
? NativeModules.I18nManager.localeIdentifier
: NativeModules.SettingsManager.settings.AppleLocale;
language = language ? language.substring(0, 2) : 'en';
} else {
language = value;
}
// check the local filesystem for the language first? Or download remote strings first?
// download and save the language file
this.setState({ downloadingLanguage: true }, () => {
fetch('https://lbry.com/i18n/get/lbry-mobile/app-strings/' + language + '.json')
.then(r => r.json())
.then(j => {
window.i18n_messages[language] = j;
// write the language file to the filesystem
const langFilePath = RNFS.ExternalDirectoryPath + '/' + language + '.json';
RNFS.writeFile(langFilePath, JSON.stringify(j), 'utf8');
// save the setting outside redux because when the first component mounts, the redux value isn't loaded yet
// so we have to load it from native settings
NativeModules.UtilityModule.setNativeStringSetting(SETTINGS.LANGUAGE, value);
// update state and client setting
window.language = language;
setClientSetting(SETTINGS.LANGUAGE, value);
this.setState({ downloadingLanguage: false });
})
.catch(e => {
notify({ message: __('Failed to load %language% translations.', { language: language }), isError: true });
this.setState({ downloadingLanguage: false });
});
});
};
handleBackPressed = () => {
const { navigation, notify, drawerStack, popDrawerStack } = this.props;
if (this.state.downloadingLanguage) {
notify({ message: 'Please wait for the language file to finish downloading' });
return;
}
navigateBack(navigation, drawerStack, popDrawerStack);
};
render() {
const {
backgroundPlayEnabled,
drawerStack,
keepDaemonRunning,
receiveSubscriptionNotifications,
receiveRewardNotifications,
receiveInterestsNotifications,
receiveCreatorNotifications,
language,
navigation,
popDrawerStack,
showNsfw,
showUriBarSuggestions,
setClientSetting,
} = this.props;
// default to true if the setting is null or undefined
const actualKeepDaemonRunning = this.getBooleanSetting(keepDaemonRunning, true);
const actualReceiveSubscriptionNotifications = this.getBooleanSetting(receiveSubscriptionNotifications, true);
const actualReceiveRewardNotifications = this.getBooleanSetting(receiveRewardNotifications, true);
const actualReceiveInterestsNotifications = this.getBooleanSetting(receiveInterestsNotifications, true);
const actualReceiveCreatorNotifications = this.getBooleanSetting(receiveCreatorNotifications, true);
const actualKeepDaemonRunning =
keepDaemonRunning === null || keepDaemonRunning === undefined ? true : keepDaemonRunning;
return (
<View style={settingsStyle.container}>
<PageHeader title={__('Settings')} onBackPressed={this.handleBackPressed} />
<PageHeader title={'Settings'} onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
<ScrollView style={settingsStyle.scrollContainer}>
<Text style={settingsStyle.sectionTitle}>{__('Content')}</Text>
<Text style={settingsStyle.sectionTitle}>Content</Text>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Enable background media playback')}</Text>
<Text style={settingsStyle.label}>Enable background media playback</Text>
<Text style={settingsStyle.description}>
{__('Enable this option to play audio or video in the background when the app is suspended.')}
Enable this option to play audio or video in the background when the app is suspended.
</Text>
</View>
<View style={settingsStyle.switchContainer}>
@@ -170,30 +79,9 @@ class SettingsPage extends React.PureComponent {
</View>
</View>
<Text style={settingsStyle.sectionTitle}>{__('Language')}</Text>
<View style={settingsStyle.pickerRow}>
<View style={settingsStyle.pickerText}>
<Text style={settingsStyle.label}>{__('Choose language')}</Text>
</View>
<View style={settingsStyle.pickerContainer}>
{this.state.downloadingLanguage && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
<Picker
enabled={!this.state.downloadingLanguage}
selectedValue={language || 'default'}
style={settingsStyle.languagePicker}
itemStyle={settingsStyle.languagePickerItem}
onValueChange={this.handleLanguageValueChange}
>
{languageOptions.map(option => (
<Picker.Item label={__(option.name)} value={option.code} key={option.code} />
))}
</Picker>
</View>
</View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Show mature 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)} />
@@ -201,73 +89,10 @@ class SettingsPage extends React.PureComponent {
</View>
<View style={settingsStyle.sectionDivider} />
<Text style={settingsStyle.sectionTitle}>{__('Notifications')}</Text>
<Text style={settingsStyle.sectionDescription}>
{__('Choose the notifications you would like to receive.')}
</Text>
<Text style={settingsStyle.sectionTitle}>Search</Text>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Subscriptions')}</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
value={actualReceiveSubscriptionNotifications}
onValueChange={value => {
this.setNativeBooleanSetting(SETTINGS.RECEIVE_SUBSCRIPTION_NOTIFICATIONS, value);
}}
/>
</View>
</View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Rewards')}</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
value={actualReceiveRewardNotifications}
onValueChange={value => {
this.setNativeBooleanSetting(SETTINGS.RECEIVE_REWARD_NOTIFICATIONS, value);
}}
/>
</View>
</View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Content Interests')}</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
value={actualReceiveInterestsNotifications}
onValueChange={value => {
this.setNativeBooleanSetting(SETTINGS.RECEIVE_INTERESTS_NOTIFICATIONS, value);
}}
/>
</View>
</View>
{false && (
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Content creator tips')}</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
value={actualReceiveCreatorNotifications}
onValueChange={value => {
this.setNativeBooleanSetting(SETTINGS.RECEIVE_CREATOR_NOTIFICATIONS, 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>
<Text style={settingsStyle.label}>Show URL suggestions</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
@@ -278,16 +103,13 @@ class SettingsPage extends React.PureComponent {
</View>
<View style={settingsStyle.sectionDivider} />
<Text style={settingsStyle.sectionTitle}>{__('Other')}</Text>
<Text style={settingsStyle.sectionTitle}>Other</Text>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>
{__('Keep the SDK background service running after closing the app')}
</Text>
<Text style={settingsStyle.label}>Keep the daemon background service running after closing the app</Text>
<Text style={settingsStyle.description}>
{__(
'Enable this option for quicker app launch and to keep the synchronisation with the blockchain up to date.'
)}
Enable this option for quicker app launch and to keep the synchronisation with the blockchain up to
date.
</Text>
</View>
<View style={settingsStyle.switchContainer}>
+3 -3
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { SETTINGS, doBalanceSubscribe, doUpdateBlockHeight, doPopulateSharedUserState, doToast } from 'lbry-redux';
import { doBalanceSubscribe, doUpdateBlockHeight, doPopulateSharedUserState, doToast } from 'lbry-redux';
import {
doAuthenticate,
doBlackListedOutpointsSubscribe,
@@ -23,14 +23,14 @@ const select = state => ({
});
const perform = dispatch => ({
authenticate: (appVersion, os, firebaseToken) => dispatch(doAuthenticate(appVersion, os, firebaseToken)),
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()),
filteredOutpointsSubscribe: () => dispatch(doFilteredOutpointsSubscribe()),
checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()),
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
fetchSubscriptions: callback => dispatch(doFetchMySubscriptions(callback)),
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
getSync: password => dispatch(doGetSync(password)),
notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
+91 -118
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { Lbry, doPreferenceGet } from 'lbry-redux';
import { Lbry } from 'lbry-redux';
import { Lbryio } from 'lbryinc';
import { ActivityIndicator, DeviceEventEmitter, Linking, NativeModules, Platform, Text, View } from 'react-native';
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, transformUrl } from 'utils/helper';
@@ -13,10 +13,14 @@ import PropTypes from 'prop-types';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import splashStyle from 'styles/splash';
import RNFS from 'react-native-fs';
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
const SETTINGS_GET_INTERVAL = 1000 * 60 * 5; // every 5 minutes
const testingNetwork = 'Testing network';
const waitingForResolution = 'Waiting for name resolution';
class SplashScreen extends React.PureComponent {
static navigationOptions = {
title: 'Splash',
@@ -25,8 +29,8 @@ class SplashScreen extends React.PureComponent {
state = {
accountUnlockFailed: false,
daemonReady: false,
details: __('Starting up'),
message: __('Connecting'),
details: 'Starting up',
message: 'Connecting',
isRunning: false,
isLagging: false,
launchUrl: null,
@@ -36,6 +40,12 @@ class SplashScreen extends React.PureComponent {
subscriptionsFetched: false,
};
componentWillMount() {
if (NativeModules.DaemonServiceControl) {
NativeModules.DaemonServiceControl.startService();
}
}
updateStatus() {
Lbry.status().then(status => {
this._updateStatusCallback(status);
@@ -50,10 +60,7 @@ class SplashScreen extends React.PureComponent {
});
navigation.dispatch(resetAction);
const launchUrl =
navigation.state.params && navigation.state.params.launchUrl
? navigation.state.params.launchUrl
: this.state.launchUrl;
const launchUrl = navigation.state.params.launchUrl || this.state.launchUrl;
if (launchUrl) {
if (launchUrl.startsWith('lbry://?verify=')) {
let verification = {};
@@ -67,13 +74,13 @@ class SplashScreen extends React.PureComponent {
try {
verifyUserEmail(verification.token, verification.recaptcha);
} catch (error) {
const message = __('Invalid Verification Token');
const message = 'Invalid Verification Token';
verifyUserEmailFailure(message);
notify({ message });
}
} else {
notify({
message: __('Invalid Verification URI'),
message: 'Invalid Verification URI',
});
}
} else {
@@ -84,18 +91,17 @@ class SplashScreen extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { emailToVerify, getSync, setEmailToVerify, verifyUserEmail, verifyUserEmailFailure } = this.props;
const { daemonReady, shouldAuthenticate } = this.state;
const { user } = nextProps;
if (daemonReady && shouldAuthenticate && user && user.id) {
if (this.state.daemonReady && this.state.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_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
this.navigateToMain();
});
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword) {
getSync(walletPassword);
}
this.navigateToMain();
});
return;
}
@@ -107,22 +113,9 @@ class SplashScreen extends React.PureComponent {
getUserSettings = () => {
const { populateSharedUserState } = this.props;
doPreferenceGet(
'shared',
preference => {
populateSharedUserState(preference);
},
error => {
/* failed */
}
);
};
onNotificationTargetLaunch = evt => {
if (evt.url && evt.url.startsWith('lbry://')) {
this.setState({ launchUrl: evt.url });
}
Lbryio.call('user_settings', 'get').then(settings => {
populateSharedUserState(settings);
});
};
finishSplashScreen = () => {
@@ -144,22 +137,22 @@ class SplashScreen extends React.PureComponent {
filteredOutpointsSubscribe();
checkSubscriptionsInit();
// get user settings interval
this.getUserSettings();
setInterval(() => this.getUserSettings(), SETTINGS_GET_INTERVAL);
if (user && user.id && user.has_verified_email) {
// user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
this.navigateToMain();
});
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword) {
getSync(walletPassword);
}
this.navigateToMain();
});
} else {
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
this.setState({ shouldAuthenticate: true });
NativeModules.Firebase.getMessagingToken()
.then(firebaseToken => {
authenticate(appVersion, Platform.OS, firebaseToken);
})
.catch(() => authenticate(appVersion, Platform.OS));
authenticate(appVersion, Platform.OS);
});
}
});
@@ -188,35 +181,31 @@ class SplashScreen extends React.PureComponent {
isRunning: true,
});
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_encrypted && !secureWalletStatus.is_locked) || secureWalletStatus.is_locked) {
this.setState({
message: __('Unlocking account'),
details: __('Decrypting wallet'),
});
// 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 (walletStatus.is_locked) {
this.setState({
message: 'Unlocking account',
details: 'Decrypting wallet',
});
// unlock the wallet and then finish the splash screen
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
if (unlocked) {
this.setState({
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
} else {
this.handleAccountUnlockFailed();
}
});
} else {
this.setState({
message: __('Testing network'),
details: __('Waiting for name resolution'),
});
this.finishSplashScreen();
}
});
// unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password: password || '' })
.then(() => {
this.setState({
message: testingNetwork,
details: waitingForResolution,
});
this.finishSplashScreen();
})
.catch(() => this.handleAccountUnlockFailed());
} else {
this.setState({
message: testingNetwork,
details: waitingForResolution,
});
this.finishSplashScreen();
}
});
return;
@@ -237,20 +226,20 @@ class SplashScreen extends React.PureComponent {
if (blockchainHeaders && blockchainHeaders.downloading_headers) {
const downloadProgress = blockchainHeaders.download_progress ? blockchainHeaders.download_progress : 0;
this.setState({
message: __('Blockchain Sync'),
details: `Catching up with the blockchain (${downloadProgress}%)`, // TODO: i18n tokenization
message: 'Blockchain Sync',
details: `Catching up with the blockchain (${downloadProgress}%)`,
});
} else if (walletStatus && walletStatus.blocks_behind > 0) {
const behind = walletStatus.blocks_behind;
const behindText = behind + ' block' + (behind === 1 ? '' : 's') + ' behind'; // TODO: i18n tokenization
const behindText = behind + ' block' + (behind === 1 ? '' : 's') + ' behind';
this.setState({
message: __('Blockchain Sync'),
message: 'Blockchain Sync',
details: behindText,
});
} else {
this.setState({
message: __('Network Loading'),
details: __('Initializing LBRY service'),
message: 'Network Loading',
details: 'Initializing LBRY service',
});
}
@@ -259,16 +248,11 @@ class SplashScreen extends React.PureComponent {
}, 1000);
}
componentWillMount() {
DeviceEventEmitter.addListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch);
}
componentWillUnmount() {
DeviceEventEmitter.removeListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch);
}
componentDidMount() {
NativeModules.Firebase.track('app_launch', null);
if (NativeModules.Firebase) {
NativeModules.Firebase.track('app_launch', null);
}
NativeModules.Firebase.setCurrentScreen('Splash');
this.props.fetchRewardedContent();
@@ -276,27 +260,6 @@ class SplashScreen extends React.PureComponent {
if (url) {
this.setState({ launchUrl: url });
}
NativeModules.UtilityModule.getNotificationLaunchTarget().then(target => {
if (target) {
this.setState({ launchUrl: target });
}
// Only connect after checking initial launch url / notification launch target
Lbry.connect()
.then(() => {
this.updateStatus();
})
.catch(e => {
this.setState({
isLagging: true,
message: __('Connection Failure'),
details: __(
'We could not establish a connection to the SDK. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.'
),
});
});
});
});
// Start measuring the first launch time from the splash screen
@@ -308,14 +271,27 @@ class SplashScreen extends React.PureComponent {
AsyncStorage.setItem('firstLaunchTime', String(moment().unix()));
}
});
Lbry.connect()
.then(() => {
this.updateStatus();
})
.catch(e => {
this.setState({
isLagging: true,
message: 'Connection Failure',
details:
'We could not establish a connection to the daemon. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.',
});
});
}
handleContinueAnywayPressed = () => {
this.setState(
{
accountUnlockFailed: false,
message: __('Testing network'),
details: __('Waiting for name resolution'),
message: testingNetwork,
details: waitingForResolution,
},
() => this.finishSplashScreen()
);
@@ -327,22 +303,19 @@ class SplashScreen extends React.PureComponent {
if (accountUnlockFailed) {
return (
<View style={splashStyle.container}>
<Text style={splashStyle.errorTitle}>{__('Oops! Something went wrong.')}</Text>
<Text style={splashStyle.errorTitle}>Oops! Something went wrong.</Text>
<Text style={splashStyle.paragraph}>
{__(
'Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.'
)}
Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.
</Text>
<Text style={splashStyle.paragraph}>
{__(
'You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the problem continues, you may have to reinstall the app and restore your account.'
)}
You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the
problem continues, you may have to reinstall the app and restore your account.
</Text>
<Button
style={splashStyle.continueButton}
theme={'light'}
text={__('Continue anyway')}
text={'Continue anyway'}
onPress={this.handleContinueAnywayPressed}
/>
</View>
+7 -9
View File
@@ -11,7 +11,7 @@ import {
View,
} from 'react-native';
import { buildURI, parseURI } from 'lbry-redux';
import { getOrderBy } 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';
@@ -149,7 +149,7 @@ class SubscriptionsPage extends React.PureComponent {
<View style={subscriptionsStyle.container}>
<UriBar navigation={navigation} belowOverlay={this.state.showSortPicker} />
<View style={subscriptionsStyle.titleRow}>
<Text style={subscriptionsStyle.pageTitle}>{__('Channels you follow')}</Text>
<Text style={subscriptionsStyle.pageTitle}>Channels you follow</Text>
</View>
{!this.state.showingSuggestedSubs && hasSubscriptions && (
<View style={subscriptionsStyle.pickerRow}>
@@ -158,7 +158,7 @@ class SubscriptionsPage extends React.PureComponent {
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={subscriptionsStyle.tagSortText}>{__(currentSortByItem.label.split(' ')[0])}</Text>
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
@@ -167,7 +167,7 @@ class SubscriptionsPage extends React.PureComponent {
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showTimePicker: true })}
>
<Text style={subscriptionsStyle.tagSortText}>{__(timeItem.label)}</Text>
<Text style={subscriptionsStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
@@ -175,7 +175,7 @@ class SubscriptionsPage extends React.PureComponent {
<Link
style={subscriptionsStyle.suggestedLink}
text={__('Suggested')}
text={'Suggested'}
onPress={() => this.setState({ showModalSuggestedSubs: true })}
/>
</View>
@@ -207,9 +207,7 @@ class SubscriptionsPage extends React.PureComponent {
<View style={subscriptionsStyle.suggestedSubsContainer}>
{!hasSubscriptions && (
<View style={subscriptionsStyle.infoArea}>
<Text style={subscriptionsStyle.infoText}>
{__('You are not subscribed to any channels at the moment.')}
</Text>
<Text style={subscriptionsStyle.infoText}>You are not subscribed to any channels at the moment.</Text>
</View>
)}
@@ -220,7 +218,7 @@ class SubscriptionsPage extends React.PureComponent {
</Text>
<Button
style={subscriptionsStyle.button}
text={__('View my subscriptions')}
text={'View my subscriptions'}
onPress={() => this.setState({ showingSuggestedSubs: false })}
/>
</View>
+3 -3
View File
@@ -105,12 +105,12 @@ class TagPage extends React.PureComponent {
<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>
<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>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
@@ -118,7 +118,7 @@ class TagPage extends React.PureComponent {
<Link
style={discoverStyle.customizeLink}
text={this.isFollowingTag(tag) ? __('Unfollow') : __('Follow')}
text={this.isFollowingTag(tag) ? 'Unfollow' : 'Follow'}
onPress={this.handleFollowTagToggle}
/>
</View>
+2 -4
View File
@@ -51,12 +51,10 @@ class TransactionHistoryPage extends React.PureComponent {
{fetchingTransactions && (
<View style={walletStyle.loadingContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={walletStyle.loadingText}>{__('Loading transactions...')}</Text>
<Text style={walletStyle.loadingText}>Loading transactions...</Text>
</View>
)}
{!fetchingTransactions && transactions.length === 0 && (
<EmptyStateView message={__('No transactions to list.')} />
)}
{!fetchingTransactions && transactions.length === 0 && <EmptyStateView message={'No transactions to list.'} />}
<ScrollView style={walletStyle.transactionHistoryScroll}>
<View style={walletStyle.historyList}>
{!fetchingTransactions && transactions && transactions.length > 0 && (
+8 -8
View File
@@ -92,7 +92,7 @@ class TrendingPage extends React.PureComponent {
return (
<View style={discoverStyle.listHeader}>
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>{__('All Content')}</Text>
<Text style={discoverStyle.pageTitle}>All content</Text>
</View>
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
@@ -100,24 +100,24 @@ class TrendingPage extends React.PureComponent {
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{__(sortByItem.label.split(' ')[0])}</Text>
<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>
<Text style={discoverStyle.pickerLabel}>for</Text>
<TouchableOpacity
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showTrendingForPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{__(currentTrendingForItem.label.split(' ')[0])}</Text>
<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 && <Text style={discoverStyle.pickerLabel}>from</Text>}
{sortByTop && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{__(timeItem.label)}</Text>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
@@ -126,7 +126,7 @@ class TrendingPage extends React.PureComponent {
{TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name && (
<Link
style={discoverStyle.customizeLink}
text={__('Customize')}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
)}
@@ -170,7 +170,7 @@ class TrendingPage extends React.PureComponent {
)}
{showTrendingForPicker && (
<ModalPicker
title={__('Filter for')}
title={'Filter for'}
onOverlayPress={() => this.setState({ showTrendingForPicker: false })}
onItemSelected={this.handleTrendingForItemSelected}
selectedItem={currentTrendingForItem}
+4 -5
View File
@@ -1,8 +1,9 @@
import { connect } from 'react-redux';
import { doToast, doPopulateSharedUserState } from 'lbry-redux';
import { doToast } from 'lbry-redux';
import {
doCheckSync,
doGetSync,
doSetDefaultAccount,
doSyncApply,
doUserEmailNew,
doUserEmailToVerify,
@@ -14,7 +15,6 @@ import {
selectPhoneToVerify,
selectPhoneVerifyIsPending,
selectPhoneVerifyErrorMessage,
selectEmailAlreadyExists,
selectEmailNewErrorMessage,
selectEmailNewIsPending,
selectEmailToVerify,
@@ -33,7 +33,6 @@ import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Verification from './view';
const select = state => ({
emailAlreadyExists: selectEmailAlreadyExists(state),
emailToVerify: selectEmailToVerify(state),
emailNewErrorMessage: selectEmailNewErrorMessage(state),
emailNewPending: selectEmailNewIsPending(state),
@@ -56,12 +55,12 @@ const select = state => ({
const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)),
addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)),
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)),
populateSharedUserState: settings => dispatch(doPopulateSharedUserState(settings)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
@@ -49,7 +49,7 @@ class EmailVerifyPage extends React.PureComponent {
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');
}
}
@@ -65,7 +65,7 @@ class EmailVerifyPage extends React.PureComponent {
const { email } = this.state;
if (!email || email.trim().length === 0 || email.indexOf('@') === -1) {
return notify({
message: __('Please provide a valid email address to continue.'),
message: 'Please provide a valid email address to continue.',
});
}
@@ -89,7 +89,7 @@ class EmailVerifyPage extends React.PureComponent {
// resend verification email if there was one previously set (and it wasn't changed)
resendVerificationEmail(this.state.email);
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, '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.' });
};
onEditPressed = () => {
@@ -105,20 +105,16 @@ class EmailVerifyPage extends React.PureComponent {
};
render() {
const { emailAlreadyExists, emailNewPending } = this.props;
const { emailNewPending } = this.props;
return (
<View style={firstRunStyle.container}>
<Text style={rewardStyle.verificationTitle}>
{Constants.PHASE_COLLECTION === this.state.phase
? __('Email')
: emailAlreadyExists
? __('Sign In')
: __('Verify Email')}
{Constants.PHASE_COLLECTION === this.state.phase ? 'Email' : 'Verify Email'}
</Text>
{Constants.PHASE_COLLECTION === this.state.phase && (
<View>
<Text style={firstRunStyle.paragraph}>{__('Please provide an email address.')}</Text>
<Text style={firstRunStyle.paragraph}>Please provide an email address.</Text>
<TextInput
style={firstRunStyle.emailInput}
placeholder={this.state.placeholder}
@@ -142,7 +138,7 @@ class EmailVerifyPage extends React.PureComponent {
<Button
style={rewardStyle.verificationButton}
theme={'light'}
text={__('Continue')}
text={'Send verification email'}
onPress={this.onSendVerificationPressed}
/>
)}
@@ -158,22 +154,18 @@ class EmailVerifyPage extends React.PureComponent {
{Constants.PHASE_VERIFICATION === this.state.phase && (
<View>
<Text style={firstRunStyle.paragraph}>
{__('An email has been sent to')}
{'\n\n'}
{this.state.email}
{'\n\n'}
{emailAlreadyExists && __('Please click the link in the message to complete signing in.')}
{!emailAlreadyExists && __('Please click the link in the message to verify your email address')}
An email has been sent to <Text style={firstRunStyle.nowrap}>{this.state.email}</Text>. Please follow the
instructions in the message to verify your email address.
</Text>
<View style={rewardStyle.buttonContainer}>
<Button
style={rewardStyle.verificationButton}
theme={'light'}
text={__('Resend')}
text={'Resend'}
onPress={this.onResendPressed}
/>
<Link style={rewardStyle.verificationLink} text={__('Edit')} onPress={this.onEditPressed} />
<Link style={rewardStyle.verificationLink} text={'Edit'} onPress={this.onEditPressed} />
</View>
</View>
)}
@@ -5,7 +5,7 @@ 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'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
import rewardStyle from 'styles/reward';
@@ -20,22 +20,21 @@ class ManualVerifyPage extends React.PureComponent {
render() {
return (
<View style={firstRunStyle.container}>
<Text style={rewardStyle.verificationTitle}>{__('Manual Reward Verification')}</Text>
<Text style={rewardStyle.verificationTitle}>Manual Reward Verification</Text>
<Text style={firstRunStyle.spacedParagraph}>
{__(
'This account must undergo review before you can participate in the rewards program. This can take anywhere from several minutes to several days.'
)}
This account must undergo review before you can participate in the rewards program. This can take anywhere
from several minutes to several days.
</Text>
<Text style={firstRunStyle.spacedParagraph}>
{__('If you continue to see this message, please request to be verified on the')}{' '}
If you continue to see this message, please request to be verified on the{' '}
<Link
style={rewardStyle.underlinedTextLink}
href="https://discordapp.com/invite/Z3bERWA"
text={__('LBRY Discord server')}
text="LBRY Discord server"
/>
.
</Text>
<Text style={firstRunStyle.spacedParagraph}>{__('Please enjoy free content in the meantime!')}</Text>
<Text style={firstRunStyle.spacedParagraph}>Please enjoy free content in the meantime!</Text>
</View>
);
}
@@ -13,7 +13,7 @@ import {
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import CountryPicker from 'react-native-country-picker-modal';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Link from 'component/link';
@@ -75,7 +75,7 @@ class PhoneVerifyPage extends React.PureComponent {
notify({ message: String(phoneVerifyErrorMessage) });
this.setState({ codeVerifyStarted: false, phoneVerifyFailed: true });
} else {
notify({ message: __('Your phone number was successfully verified.') });
notify({ message: 'Your phone number was successfully verified.' });
this.setState({ codeVerifySuccessful: true, phoneVerifyFailed: false });
if (onPhoneVerifySuccessful) {
onPhoneVerifySuccessful();
@@ -103,7 +103,7 @@ class PhoneVerifyPage extends React.PureComponent {
if (!this.phoneInput.isValidNumber()) {
return notify({
message: __('Please provide a valid telephone number.'),
message: 'Please provide a valid telephone number.',
});
}
@@ -145,14 +145,14 @@ class PhoneVerifyPage extends React.PureComponent {
return (
<View style={firstRunStyle.container}>
<Text style={rewardStyle.verificationTitle}>
{this.state.phase === Constants.PHASE_VERIFICATION ? __('Verify Phone Number') : __('Phone Number')}
{this.state.phase === Constants.PHASE_VERIFICATION ? 'Verify ' : ''}Phone Number
</Text>
<View style={rewardStyle.phoneVerificationContainer}>
{this.state.phase === Constants.PHASE_COLLECTION && (
{this.state.phase == Constants.PHASE_COLLECTION && (
<View>
<Text style={[rewardStyle.bottomMarginMedium, firstRunStyle.paragraph]}>
{__('Please provide a phone number to prevent fraud.')}
Please provide a phone number to prevent fraud.
</Text>
<PhoneInput
ref={ref => {
@@ -169,7 +169,7 @@ class PhoneVerifyPage extends React.PureComponent {
<Button
style={[rewardStyle.verificationButton, rewardStyle.topMarginMedium]}
theme={'light'}
text={__('Send verification text')}
text={'Send verification text'}
onPress={this.onSendTextPressed}
/>
)}
@@ -187,7 +187,7 @@ class PhoneVerifyPage extends React.PureComponent {
{!phoneVerifyIsPending && !this.codeVerifyStarted && (
<View>
<Text style={[rewardStyle.bottomMarginSmall, firstRunStyle.paragraph]}>
{__('Please enter the verification code sent to %phone%', { phone })}.
Please enter the verification code sent to {phone}.
</Text>
<TextInput
style={rewardStyle.verificationCodeInput}
@@ -202,16 +202,16 @@ class PhoneVerifyPage extends React.PureComponent {
<Button
style={[rewardStyle.verificationButton, rewardStyle.topMarginSmall]}
theme={'light'}
text={__('Verify')}
text={'Verify'}
onPress={this.onVerifyPressed}
/>
<Link style={rewardStyle.verificationLink} text={__('Edit')} onPress={this.onEditPressed} />
<Link style={rewardStyle.verificationLink} text={'Edit'} onPress={this.onEditPressed} />
</View>
</View>
)}
{phoneVerifyIsPending && (
<View style={firstRunStyle.centered}>
<Text style={firstRunStyle.paragraph}>{__('Verifying your phone number...')}</Text>
<Text style={firstRunStyle.paragraph}>Verifying your phone number...</Text>
<ActivityIndicator
color={Colors.White}
size="small"
@@ -237,9 +237,9 @@ class PhoneVerifyPage extends React.PureComponent {
this.picker = picker;
}}
cca2={this.state.cca2}
filterable
filterable={true}
onChange={value => this.selectCountry(value)}
showCallingCode
showCallingCode={true}
translation="eng"
>
<View />
@@ -14,14 +14,10 @@ class SyncVerifyPage extends React.PureComponent {
state = {
checkSyncStarted: false,
password: null,
placeholder: __('password'),
placeholder: 'password',
syncApplyStarted: false,
syncApplyCompleted: false,
syncChecked: false,
revealPassword: false,
autoPassword: false,
autoLoginAttempted: false,
autoLoginFlow: true,
};
componentDidMount() {
@@ -41,17 +37,11 @@ class SyncVerifyPage extends React.PureComponent {
if (!hasSyncedWallet) {
// fresh account with no sync
const newPassword = this.state.password ? this.state.password : '';
if (newPassword.trim().length === 0) {
Lbry.account_encrypt({ new_password: newPassword }).then(() => {
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 ? this.state.password : '');
}
@@ -60,61 +50,49 @@ class SyncVerifyPage extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { getSyncIsPending, syncApplyIsPending, syncApplyErrorMessage } = nextProps;
const { getSync, hasSyncedWallet, navigation, notify, setClientSetting } = this.props;
const { getSync, hasSyncedWallet, navigation, notify, setClientSetting, setDefaultAccount } = this.props;
if (this.state.checkSyncStarted && !getSyncIsPending) {
this.setState({ syncChecked: true });
}
if (this.state.syncApplyStarted && !syncApplyIsPending) {
if (syncApplyErrorMessage && syncApplyErrorMessage.trim().length > 0) {
notify({ message: __(syncApplyErrorMessage), isError: true });
this.setState({ syncApplyStarted: false, autoLoginFlow: false });
notify({ message: syncApplyErrorMessage, isError: true });
this.setState({ syncApplyStarted: false });
} else {
// password successfully verified
this.setState({ syncApplyCompleted: true });
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(
Constants.KEY_WALLET_PASSWORD,
Constants.KEY_FIRST_RUN_PASSWORD,
this.state.password ? this.state.password : ''
);
}
this.finishSync(true);
setDefaultAccount(
() => this.finishSync(true),
err => {
// fail silently and still finish
this.finishSync();
}
);
}
}
}
componentDidUpdate() {
const { hasSyncedWallet } = this.props;
if (this.state.syncChecked && !this.state.autoPassword && !hasSyncedWallet) {
// new user sync, don't prompt for a password
this.setState({ password: '', autoPassword: true });
this.onEnableSyncPressed();
}
if (this.state.syncChecked && hasSyncedWallet && !this.state.autoLoginAttempted) {
this.setState({ autoLoginAttempted: true, password: '' }, () => this.onEnableSyncPressed());
}
}
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 {
Lbry.status().then(status => {
if (status.wallet.is_locked) {
Lbry.account_unlock({ password: this.state.password ? this.state.password : '' })
.then(() => navigation.goBack())
.catch(err => {
if (notifyUnlockFailed) {
notify({ message: __('The wallet could not be unlocked at this time. Please restart the app.') });
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' });
}
}
});
});
} else {
navigation.goBack();
}
@@ -131,16 +109,16 @@ class SyncVerifyPage extends React.PureComponent {
};
render() {
const { hasSyncedWallet, syncApplyIsPending, signInFlow } = this.props;
const { hasSyncedWallet, syncApplyIsPending } = this.props;
let paragraph;
if (!hasSyncedWallet) {
paragraph = (
<Text style={firstRunStyle.paragraph}>{__('Please enter a password to secure your account and wallet.')}</Text>
<Text style={firstRunStyle.paragraph}>Please enter a password to secure your account and wallet.</Text>
);
} else {
paragraph = (
<Text style={firstRunStyle.paragraph}>{__('Please enter the password you used to secure your wallet.')}</Text>
<Text style={firstRunStyle.paragraph}>Please enter the password you used to secure your wallet.</Text>
);
}
@@ -149,22 +127,13 @@ class SyncVerifyPage extends React.PureComponent {
content = (
<View style={firstRunStyle.centered}>
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
<Text style={firstRunStyle.paragraph}>{__('Retrieving your account information...')}</Text>
<Text style={firstRunStyle.paragraph}>Retrieving your account information...</Text>
</View>
);
} else if (this.state.autoLoginFlow && (syncApplyIsPending || this.state.syncApplyCompleted)) {
// first attempt at auto-login, only display activity indicator
} else {
content = (
<View>
<View style={firstRunStyle.centerInside}>
<ActivityIndicator size={'small'} color={Colors.White} />
</View>
</View>
);
} else if (hasSyncedWallet && this.state.autoLoginAttempted) {
content = (
<View>
<Text style={rewardStyle.verificationTitle}>{__('Wallet Sync')}</Text>
<Text style={rewardStyle.verificationTitle}>Wallet Sync</Text>
{paragraph}
<View style={firstRunStyle.passwordInputContainer}>
<TextInput
@@ -182,7 +151,7 @@ class SyncVerifyPage extends React.PureComponent {
}}
onBlur={() => {
if (!this.state.password || this.state.password.length === 0) {
this.setState({ placeholder: __('password') });
this.setState({ placeholder: 'password' });
}
}}
/>
@@ -198,8 +167,8 @@ class SyncVerifyPage extends React.PureComponent {
<View style={firstRunStyle.passwordWarning}>
<Text style={firstRunStyle.passwordWarningText}>
{hasSyncedWallet
? __('If you did not provide a password, please press Use LBRY to continue.')
: __('You can proceed without a password, but this is not recommended.')}
? 'If you did not provide a password, please press Use LBRY to continue.'
: 'You can proceed without a password, but this is not recommended.'}
</Text>
</View>
)}
@@ -214,7 +183,7 @@ class SyncVerifyPage extends React.PureComponent {
</View>
)}
<Text style={firstRunStyle.infoParagraph}>
{__('Note: for wallet security purposes, LBRY is unable to reset your password.')}
Note: for wallet security purposes, LBRY is unable to reset your password.
</Text>
<View style={rewardStyle.buttonContainer}>
@@ -222,11 +191,11 @@ class SyncVerifyPage extends React.PureComponent {
<Button
style={rewardStyle.verificationButton}
theme={'light'}
text={signInFlow ? __('Use LBRY') : __('Enable sync')}
text={'Enable sync'}
onPress={this.onEnableSyncPressed}
/>
)}
{(syncApplyIsPending || this.state.syncApplyCompleted) && (
{syncApplyIsPending && (
<View style={firstRunStyle.centerInside}>
<ActivityIndicator size={'small'} color={Colors.White} />
</View>
+7 -32
View File
@@ -1,11 +1,10 @@
import React from 'react';
import { Lbry, doPreferenceGet } from 'lbry-redux';
import { Lbry } from 'lbry-redux';
import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Icon from 'react-native-vector-icons/FontAwesome5';
import EmailVerifyPage from './internal/email-verify-page';
import ManualVerifyPage from './internal/manual-verify-page';
import PhoneVerifyPage from './internal/phone-verify-page';
@@ -20,7 +19,6 @@ class VerificationScreen extends React.PureComponent {
showSkip: false,
skipAccountConfirmed: false,
showBottomContainer: true,
signInFlow: false,
walletPassword: null,
isEmailVerificationPhase: false,
isEmailVerified: false,
@@ -29,9 +27,7 @@ class VerificationScreen extends React.PureComponent {
};
componentDidMount() {
const { user, navigation } = this.props;
const { signInFlow } = navigation.state.params;
this.setState({ signInFlow });
const { user } = this.props;
this.checkVerificationStatus(user);
NativeModules.Firebase.setCurrentScreen('Verification');
}
@@ -40,22 +36,8 @@ class VerificationScreen extends React.PureComponent {
this.setState({ isEmailVerificationPhase: value });
};
getUserSettings = () => {
const { populateSharedUserState } = this.props;
doPreferenceGet(
'shared',
preference => {
populateSharedUserState(preference);
},
error => {
/* failed */
}
);
};
checkVerificationStatus = user => {
const { deviceWalletSynced, getSync, navigation } = this.props;
const { deviceWalletSynced, navigation } = this.props;
const { syncFlow } = navigation.state.params;
this.setState(
@@ -75,13 +57,7 @@ class VerificationScreen extends React.PureComponent {
}
if (this.state.isEmailVerified && syncFlow && deviceWalletSynced) {
// retrieve user settings
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
navigation.goBack();
});
});
navigation.goBack();
}
} else {
if (this.state.isEmailVerified && !this.state.isIdentityVerified && !this.state.isRewardApproved) {
@@ -118,7 +94,6 @@ class VerificationScreen extends React.PureComponent {
addUserEmail,
checkSync,
emailNewErrorMessage,
emailAlreadyExists,
emailNewPending,
emailToVerify,
getSync,
@@ -126,6 +101,7 @@ class VerificationScreen extends React.PureComponent {
notify,
addUserPhone,
getSyncIsPending,
setDefaultAccount,
hasSyncedWallet,
setSyncIsPending,
syncApplyIsPending,
@@ -149,7 +125,6 @@ class VerificationScreen extends React.PureComponent {
page = (
<EmailVerifyPage
addUserEmail={addUserEmail}
emailAlreadyExists={emailAlreadyExists}
emailNewErrorMessage={emailNewErrorMessage}
emailNewPending={emailNewPending}
emailToVerify={emailToVerify}
@@ -187,13 +162,13 @@ class VerificationScreen extends React.PureComponent {
notify={notify}
setEmailVerificationPhase={this.setEmailVerificationPhase}
setClientSetting={setClientSetting}
setDefaultAccount={setDefaultAccount}
setSyncIsPending={setSyncIsPending}
syncApplyIsPending={syncApplyIsPending}
syncApplyErrorMessage={syncApplyErrorMessage}
syncApply={syncApply}
syncData={syncData}
syncHash={syncHash}
signInFlow={this.state.signInFlow}
/>
);
break;
@@ -209,7 +184,7 @@ class VerificationScreen extends React.PureComponent {
{!this.state.isEmailVerificationPhase && (
<TouchableOpacity style={firstRunStyle.closeButton} onPress={this.onCloseButtonPressed}>
<Icon name={'times'} size={16} style={firstRunStyle.closeButtonIcon} />
<Text style={firstRunStyle.closeButtonText}>x</Text>
</TouchableOpacity>
)}
</View>
+2 -2
View File
@@ -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'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import WalletPage from './view';
const select = state => ({
@@ -21,7 +21,7 @@ const select = state => ({
const perform = dispatch => ({
checkSync: () => dispatch(doCheckSync()),
getSync: (password, callback) => dispatch(doGetSync(password, callback)),
getSync: password => dispatch(doGetSync(password)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_WALLET)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+27 -8
View File
@@ -5,7 +5,6 @@ import WalletAddress from 'component/walletAddress';
import WalletBalance from 'component/walletBalance';
import WalletSend from 'component/walletSend';
import WalletRewardsDriver from 'component/walletRewardsDriver';
import WalletSignIn from 'component/walletSignIn';
import WalletSyncDriver from 'component/walletSyncDriver';
import Button from 'component/button';
import Link from 'component/link';
@@ -47,8 +46,10 @@ class WalletPage extends React.PureComponent {
const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword);
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword) {
getSync(walletPassword);
}
});
}
};
@@ -67,15 +68,33 @@ class WalletPage extends React.PureComponent {
understandsRisks,
setClientSetting,
navigation,
user,
} = this.props;
const signedIn = user && user.has_verified_email;
if (!signedIn && !understandsRisks) {
if (!understandsRisks) {
return (
<View style={walletStyle.container}>
<View>
<UriBar navigation={navigation} />
<WalletSignIn navigation={navigation} />
<View style={walletStyle.warning}>
<Text style={walletStyle.warningParagraph}>
This is beta software. You may lose any credits that you send to your wallet due to software bugs, deleted
files, or malicious third-party software. You should not use this wallet as your primary wallet.
</Text>
{!hasSyncedWallet && (
<Text style={walletStyle.warningParagraph}>
Since you are not using the LBRY sync service, you will lose all of your credits if you uninstall this
application. Instructions on how to enroll as well as how to backup your wallet manually are available
on the next page.
</Text>
)}
<Text style={walletStyle.warningText}>
If you understand the risks and you wish to continue, please tap the button below.
</Text>
</View>
<Button
text={'I understand the risks'}
style={[walletStyle.button, walletStyle.understand]}
onPress={() => setClientSetting(Constants.SETTING_ALPHA_UNDERSTANDS_RISKS, true)}
/>
</View>
);
}
-29
View File
@@ -1,5 +1,4 @@
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import { ACTIONS, batchActions, selectMyClaims } from 'lbry-redux';
export const doUpdatePublishFormState = publishFormValue => dispatch =>
dispatch({
@@ -22,31 +21,3 @@ export const doClearChannelFormState = () => dispatch =>
dispatch({
type: Constants.ACTION_CLEAR_CHANNEL_FORM_STATE,
});
export const doPendingPublishSuccess = pendingClaim => (dispatch, getState) => {
const state = getState();
const myClaims = selectMyClaims(state);
const { permanent_url: url } = pendingClaim;
const actions = [
{
type: ACTIONS.PUBLISH_SUCCESS,
},
];
// We have to fake a temp claim until the new pending one is returned by claim_list_mine
// We can't rely on claim_list_mine because there might be some delay before the new claims are returned
// Doing this allows us to show the pending claim immediately, it will get overwritten by the real one
const isMatch = claim => claim.claim_id === pendingClaim.claim_id;
const isEdit = myClaims.some(isMatch);
const myNewClaims = isEdit
? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim))
: myClaims.concat(pendingClaim);
actions.push({
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
data: {
claims: myNewClaims,
},
});
dispatch(batchActions(...actions));
};
+95
View File
@@ -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,
});
});
};
-11
View File
@@ -38,14 +38,3 @@ export function doSetTimeItem(item) {
});
};
}
export function doToggleFullscreenMode(mode) {
return dispatch => {
dispatch({
type: Constants.ACTION_FULLSCREEN_MODE_TOGGLED,
data: {
mode,
},
});
};
}
-6
View File
@@ -6,7 +6,6 @@ const defaultState = {
clientSettings: {},
sortByItemName: Constants.SORT_BY_HOT,
timeItemName: Constants.TIME_WEEK,
fullscreenMode: false,
};
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
@@ -30,11 +29,6 @@ reducers[Constants.ACTION_TIME_ITEM_CHANGED] = (state, action) =>
timeItemName: action.data.name,
});
reducers[Constants.ACTION_FULLSCREEN_MODE_TOGGLED] = (state, action) =>
Object.assign({}, state, {
fullscreenMode: action.data.mode,
});
export default function reducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
-5
View File
@@ -34,8 +34,3 @@ export const makeSelectClientSetting = setting =>
export const selectShowNsfw = makeSelectClientSetting(SETTINGS.SHOW_NSFW);
export const selectKeepDaemonRunning = makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING);
export const selectFullscreenMode = createSelector(
selectState,
state => state.fullscreenMode
);
-4
View File
@@ -172,10 +172,6 @@ const channelPageStyle = StyleSheet.create({
deleteButton: {
marginLeft: 8,
},
shareButton: {
marginLeft: 8,
marginRight: 8,
},
});
export default channelPageStyle;
-4
View File
@@ -11,10 +11,6 @@ const channelSelectorStyle = StyleSheet.create({
height: 52,
width: '100%',
},
channelPickerItem: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
bidRow: {
flex: 1,
flexDirection: 'row',
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff. Show more