fix merge conflicts

This commit is contained in:
Akinwale Ariwodola 2019-09-09 09:31:23 +01:00
commit 563a9135ce
14 changed files with 125 additions and 51 deletions

8
package-lock.json generated
View file

@ -5574,8 +5574,8 @@
} }
}, },
"lbry-redux": { "lbry-redux": {
"version": "github:lbryio/lbry-redux#053aead0d92b02fdd192ab5288104ad6688d549f", "version": "github:lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
"from": "github:lbryio/lbry-redux#053aead0d92b02fdd192ab5288104ad6688d549f", "from": "github:lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
"requires": { "requires": {
"proxy-polyfill": "0.1.6", "proxy-polyfill": "0.1.6",
"reselect": "^3.0.0", "reselect": "^3.0.0",
@ -5583,8 +5583,8 @@
} }
}, },
"lbryinc": { "lbryinc": {
"version": "github:lbryio/lbryinc#4c761084990557d379c85e1c998fcae7e5db143a", "version": "github:lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"from": "github:lbryio/lbryinc#4c761084990557d379c85e1c998fcae7e5db143a", "from": "github:lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"requires": { "requires": {
"reselect": "^3.0.0" "reselect": "^3.0.0"
} }

View file

@ -12,8 +12,8 @@
"base-64": "^0.1.0", "base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0", "@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3", "gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#40bbf6afbdc66806d2f1a810d125bb290999c18b", "lbry-redux": "lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
"lbryinc": "lbryio/lbryinc#4c761084990557d379c85e1c998fcae7e5db143a", "lbryinc": "lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"lodash": ">=4.17.11", "lodash": ">=4.17.11",
"merge": ">=1.2.1", "merge": ">=1.2.1",
"moment": "^2.22.1", "moment": "^2.22.1",

View file

@ -41,7 +41,7 @@ import {
} from 'lbryinc'; } from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { decode as atob } from 'base-64'; import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper'; import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage'; import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@ -420,7 +420,7 @@ class AppWithNavigationState extends React.Component {
); );
} }
} else { } else {
dispatchNavigateToUri(dispatch, nav, evt.url); dispatchNavigateToUri(dispatch, nav, transformUrl(evt.url));
} }
} }
}; };

View file

@ -3,6 +3,7 @@ import { normalizeURI, parseURI } from 'lbry-redux';
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native'; import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
import { navigateToUri, formatBytes } from 'utils/helper'; import { navigateToUri, formatBytes } from 'utils/helper';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime'; import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia'; import FileItemMedia from 'component/fileItemMedia';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
@ -12,6 +13,10 @@ import ProgressBar from 'component/progressBar';
import fileListStyle from 'styles/fileList'; import fileListStyle from 'styles/fileList';
class FileListItem extends React.PureComponent { class FileListItem extends React.PureComponent {
state = {
url: null,
};
getStorageForFileInfo = fileInfo => { getStorageForFileInfo = fileInfo => {
if (!fileInfo.completed) { if (!fileInfo.completed) {
const written = formatBytes(fileInfo.written_bytes); const written = formatBytes(fileInfo.written_bytes);
@ -41,9 +46,21 @@ class FileListItem extends React.PureComponent {
} }
} }
componentDidUpdate() {
const { claim, resolveUri, uri } = this.props;
if (!claim && uri !== this.state.url) {
this.setState({ url: uri }, () => resolveUri(uri));
}
}
defaultOnPress = () => { defaultOnPress = () => {
const { autoplay, navigation, uri, shortUrl } = this.props; const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
if (featuredResult && !claim) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
} else {
navigateToUri(navigation, shortUrl || uri, { autoplay }); navigateToUri(navigation, shortUrl || uri, { autoplay });
}
}; };
onPressHandler = () => { onPressHandler = () => {
@ -111,7 +128,7 @@ class FileListItem extends React.PureComponent {
// shouldHide = 'channel' === claim.value_type; // shouldHide = 'channel' === claim.value_type;
} }
if (shouldHide || (!isResolvingUri && !claim) || (featuredResult && !isResolvingUri && !claim && !title && !name)) { if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
return null; return null;
} }
@ -130,7 +147,7 @@ class FileListItem extends React.PureComponent {
style={fileListStyle.thumbnail} style={fileListStyle.thumbnail}
duration={duration} duration={duration}
resizeMode="cover" resizeMode="cover"
title={title || name} title={title || name || normalizeURI(uri).substring(7)}
thumbnail={thumbnail} thumbnail={thumbnail}
/> />
{selected && ( {selected && (
@ -167,6 +184,13 @@ class FileListItem extends React.PureComponent {
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />} {isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
</View> </View>
)} )}
{featuredResult && !isResolving && !claim && (
<View style={fileListStyle.titleContainer}>
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
</View>
)}
{channel && !hideChannel && ( {channel && !hideChannel && (
<Link <Link
style={fileListStyle.publisher} style={fileListStyle.publisher}

View file

@ -2,7 +2,7 @@
import React from 'react'; import React from 'react';
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux'; import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { navigateToUri } from 'utils/helper'; import { navigateToUri, transformUrl } from 'utils/helper';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import UriBarItem from './internal/uri-bar-item'; import UriBarItem from './internal/uri-bar-item';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
@ -109,12 +109,19 @@ class UriBar extends React.PureComponent {
handleSubmitEditing = () => { handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props; const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
if (this.state.inputText) { if (this.state.inputText) {
let inputText = this.state.inputText; let inputText = this.state.inputText,
if (inputText.startsWith('lbry://') && isURIValid(inputText)) { inputTextIsUrl = false;
if (inputText.startsWith('lbry://')) {
const transformedUrl = transformUrl(inputText);
// if it's a URI (lbry://...), open the file page // if it's a URI (lbry://...), open the file page
const uri = normalizeURI(inputText); if (transformedUrl && isURIValid(transformedUrl)) {
navigateToUri(navigation, uri); inputTextIsUrl = true;
} else { navigateToUri(navigation, transformedUrl);
}
}
// couldn't parse the inputText as a URL for some reason, so do a search instead
if (!inputTextIsUrl) {
updateSearchQuery(inputText); updateSearchQuery(inputText);
// Not a URI, default to a search request // Not a URI, default to a search request
if (onSearchSubmitted) { if (onSearchSubmitted) {

View file

@ -46,7 +46,7 @@ const perform = dispatch => ({
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
}); });

View file

@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
isEmailVerified: false, isEmailVerified: false,
skipAccountConfirmed: false, skipAccountConfirmed: false,
showBottomContainer: false, showBottomContainer: false,
walletPassword: null, walletPassword: '',
syncApplyStarted: false, syncApplyStarted: false,
}; };
@ -86,12 +86,25 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true }); this.setState({ showBottomContainer: true });
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword); NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
} setDefaultAccount(
setDefaultAccount(); () => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
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.',
});
}
);
} }
} }
@ -253,7 +266,7 @@ class FirstRunScreen extends React.PureComponent {
}; };
onWalletPasswordChanged = password => { onWalletPasswordChanged = password => {
this.setState({ walletPassword: password }); this.setState({ walletPassword: password !== null ? password : '' });
}; };
onWalletViewLayout = () => { onWalletViewLayout = () => {

View file

@ -19,6 +19,7 @@ import {
isNameValid, isNameValid,
buildURI, buildURI,
normalizeURI, normalizeURI,
parseURI,
regexInvalidURI, regexInvalidURI,
CLAIM_VALUES, CLAIM_VALUES,
LICENSES, LICENSES,
@ -123,6 +124,7 @@ class PublishPage extends React.PureComponent {
tags: [], tags: [],
selectedChannel: null, selectedChannel: null,
uploadedThumbnailUri: null, uploadedThumbnailUri: null,
vanityUrlSet: false,
// other // other
publishStarted: false, publishStarted: false,
@ -179,9 +181,16 @@ class PublishPage extends React.PureComponent {
// Check if this is an edit action // Check if this is an edit action
if (navigation.state.params) { if (navigation.state.params) {
const { editMode, claimToEdit } = navigation.state.params; const { editMode, claimToEdit, vanityUrl } = navigation.state.params;
if (editMode) { if (editMode) {
this.prepareEdit(claimToEdit); this.prepareEdit(claimToEdit);
} else if (vanityUrl) {
const { claimName } = parseURI(vanityUrl);
this.setState({
name: claimName,
hasEditedContentAddress: true,
vanityUrlSet: true,
});
} }
} }
}); });
@ -233,6 +242,7 @@ class PublishPage extends React.PureComponent {
title, title,
currentThumbnailUri: thumbnailUrl, currentThumbnailUri: thumbnailUrl,
uploadedThumbnailUri: thumbnailUrl, uploadedThumbnailUri: thumbnailUrl,
vanityUrlSet: false,
}, },
() => { () => {
this.handleNameChange(name); this.handleNameChange(name);
@ -379,7 +389,7 @@ class PublishPage extends React.PureComponent {
{ {
currentMedia: media, currentMedia: media,
title: null, // no title autogeneration (user will fill this in) title: null, // no title autogeneration (user will fill this in)
name: this.formatNameForTitle(name), name: this.state.hasEditedContentAddress ? this.state.name : this.formatNameForTitle(name),
currentPhase: Constants.PHASE_DETAILS, currentPhase: Constants.PHASE_DETAILS,
}, },
() => this.handleNameChange(this.state.name) () => this.handleNameChange(this.state.name)
@ -425,6 +435,8 @@ class PublishPage extends React.PureComponent {
tags: [], tags: [],
selectedChannel: null, selectedChannel: null,
uploadedThumbnailUri: null, uploadedThumbnailUri: null,
vanityUrlSet: false,
}, },
() => { () => {
// reset thumbnail // reset thumbnail

View file

@ -101,13 +101,7 @@ class SearchPage extends React.PureComponent {
const { currentUri } = this.state; const { currentUri } = this.state;
return ( return (
<FileListItem <FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
uri={currentUri}
featuredResult
style={searchStyle.featuredResultItem}
navigation={navigation}
onPress={() => navigateToUri(navigation, this.state.currentUri)}
/>
); );
}; };

View file

@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
import { ActivityIndicator, 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 { NavigationActions, StackActions } from 'react-navigation';
import { decode as atob } from 'base-64'; import { decode as atob } from 'base-64';
import { navigateToUri } from 'utils/helper'; import { navigateToUri, transformUrl } from 'utils/helper';
import moment from 'moment'; import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage'; import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button'; import Button from 'component/button';
@ -81,7 +81,7 @@ class SplashScreen extends React.PureComponent {
}); });
} }
} else { } else {
navigateToUri(navigation, launchUrl); navigateToUri(navigation, transformUrl(launchUrl));
} }
} }
}; };
@ -130,7 +130,7 @@ class SplashScreen extends React.PureComponent {
if (user && user.id && user.has_verified_email) { if (user && user.id && user.has_verified_email) {
// user already authenticated // user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) { if (walletPassword) {
getSync(walletPassword); getSync(walletPassword);
} }
this.navigateToMain(); this.navigateToMain();
@ -166,14 +166,14 @@ class SplashScreen extends React.PureComponent {
// For now, automatically unlock the wallet if a password is set so that downloads work // 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 => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
if (password && password.trim().length > 0) { if (password) {
this.setState({ this.setState({
message: 'Unlocking account', message: 'Unlocking account',
details: 'Decrypting wallet', details: 'Decrypting wallet',
}); });
// unlock the wallet and then finish the splash screen // unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password }) Lbry.account_unlock({ password: password || '' })
.then(() => { .then(() => {
this.setState({ this.setState({
message: testingNetwork, message: testingNetwork,

View file

@ -29,7 +29,7 @@ import {
} from 'lbryinc'; } from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import Constants from 'constants'; import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Verification from './view'; import Verification from './view';
const select = state => ({ const select = state => ({
@ -54,13 +54,13 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)), addUserEmail: email => dispatch(doUserEmailNew(email)),
addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)), addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)),
getSync: password => dispatch(doGetSync(password)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)), verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)), setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),

View file

@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
import Button from 'component/button'; import Button from 'component/button';
import Link from 'component/link'; import Link from 'component/link';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Constants from 'constants'; import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import firstRunStyle from 'styles/firstRun'; import firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward'; import rewardStyle from 'styles/reward';
@ -62,11 +62,29 @@ class SyncVerifyPage extends React.PureComponent {
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) { if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password); NativeModules.UtilityModule.setSecureValue(
Constants.KEY_FIRST_RUN_PASSWORD,
this.state.password ? this.state.password : ''
);
} }
setDefaultAccount(); setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
navigation.goBack();
// unlock the wallet
Lbry.account_unlock({ password: this.state.password ? this.state.password : '' })
.then(() => navigation.goBack())
.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.',
});
}
);
} }
} }
} }

View file

@ -47,7 +47,7 @@ class WalletPage extends React.PureComponent {
const { deviceWalletSynced, getSync, user } = this.props; const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) { if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) { if (walletPassword) {
getSync(walletPassword); getSync(walletPassword);
} }
}); });

View file

@ -1,5 +1,5 @@
import { NavigationActions, StackActions } from 'react-navigation'; import { NavigationActions, StackActions } from 'react-navigation';
import { buildURI, isURIValid } from 'lbry-redux'; import { buildURI, isURIValid, normalizeURI } from 'lbry-redux';
import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer'; import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
@ -246,6 +246,12 @@ export function getOrderBy(item) {
return orderBy; return orderBy;
} }
// replace occurrences of ':' with '#' in a url (entered in the URI bar)
export function transformUrl(url) {
const start = 'lbry://'.length;
return normalizeURI(url.substring(start).replace(/:/g, '#'));
}
// i18n placeholder until we find a good react-native i18n module // i18n placeholder until we find a good react-native i18n module
export function __(str) { export function __(str) {
return str; return str;