final fix for uri bar and some performance improvements

This commit is contained in:
Akinwale Ariwodola 2020-01-06 21:11:15 +01:00
parent 3f0ed7988a
commit 4ed3809ffd
7 changed files with 91 additions and 48 deletions

View file

@ -243,5 +243,10 @@
"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.", "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.",
"Redeem": "Redeem", "Redeem": "Redeem",
"Please confirm that you want to use LBRY without creating an account.": "Please confirm that you want to use LBRY without creating an account.", "Please confirm that you want to use LBRY without creating an account.": "Please confirm that you want to use LBRY without creating an account.",
"You sent %amount% LBC as a tip, Mahalo!": "You sent %amount% LBC as a tip, Mahalo!" "You sent %amount% LBC as a tip, Mahalo!": "You sent %amount% LBC as a tip, Mahalo!",
"%follower% follower": "%follower% follower",
"Authenticating": "Authenticating",
"Waiting for authentication": "Waiting for authentication",
"Delete file": "Delete file",
"Are you sure you want to remove this file from your device?": "Are you sure you want to remove this file from your device?"
} }

28
package-lock.json generated
View file

@ -9845,9 +9845,9 @@
} }
}, },
"react-native-exception-handler": { "react-native-exception-handler": {
"version": "2.9.0", "version": "2.10.8",
"resolved": "https://registry.npmjs.org/react-native-exception-handler/-/react-native-exception-handler-2.9.0.tgz", "resolved": "https://registry.npmjs.org/react-native-exception-handler/-/react-native-exception-handler-2.10.8.tgz",
"integrity": "sha512-XRHhGH5aM4lSenX4zZBa07JaszJGXeF8cv1KY314Q4qJWOihKWLpkdvwqwsBieZ2iy8DPhdAVioQzw8JLD/Okw==" "integrity": "sha512-ZN+jwpADRkCUNdad/50k0mZdMoICGrGdtaxgvRU+pNcWRRBAXJhuo4+jY0eQaoVpx1ghycGE6tBu9ka8gL2NOQ=="
}, },
"react-native-fast-image": { "react-native-fast-image": {
"version": "7.0.2", "version": "7.0.2",
@ -10110,6 +10110,22 @@
"shaka-player": "^2.4.4" "shaka-player": "^2.4.4"
} }
}, },
"react-native-webview": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-8.0.2.tgz",
"integrity": "sha512-Higfj0CCPM9N76S3rQsKHKS8Rw5QA7h7UENrREmMarEN/2saZJ+ko0aIVYOlEJ4P9ZhhRLNH/3mWvzmT4spncw==",
"requires": {
"escape-string-regexp": "2.0.0",
"invariant": "2.2.4"
},
"dependencies": {
"escape-string-regexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w=="
}
}
},
"react-navigation": { "react-navigation": {
"version": "4.0.10", "version": "4.0.10",
"resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-4.0.10.tgz", "resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-4.0.10.tgz",
@ -10316,9 +10332,9 @@
} }
}, },
"redux-persist": { "redux-persist": {
"version": "6.0.0", "version": "5.10.0",
"resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-6.0.0.tgz", "resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-5.10.0.tgz",
"integrity": "sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ==" "integrity": "sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg=="
}, },
"redux-persist-filesystem-storage": { "redux-persist-filesystem-storage": {
"version": "2.1.0", "version": "2.1.0",

View file

@ -23,7 +23,7 @@
"@react-native-community/masked-view": "^0.1.5", "@react-native-community/masked-view": "^0.1.5",
"react-native-camera": "^3.15.0", "react-native-camera": "^3.15.0",
"react-native-country-picker-modal": "^1.10.0", "react-native-country-picker-modal": "^1.10.0",
"react-native-exception-handler": "2.9.0", "react-native-exception-handler": "2.10.8",
"react-native-fast-image": "^7.0.2", "react-native-fast-image": "^7.0.2",
"react-native-fs": "^2.13.3", "react-native-fs": "^2.13.3",
"react-native-gesture-handler": "1.5.2", "react-native-gesture-handler": "1.5.2",
@ -36,6 +36,7 @@
"react-native-super-grid": "^3.0.4", "react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0", "react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47", "react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47",
"react-native-webview": "^8.0.2",
"react-navigation": "^4.0.10", "react-navigation": "^4.0.10",
"react-navigation-drawer": "^2.3.3", "react-navigation-drawer": "^2.3.3",
"react-navigation-redux-helpers": "^3.0.2", "react-navigation-redux-helpers": "^3.0.2",

View file

@ -25,11 +25,13 @@ class UriBar extends React.PureComponent {
inputText: null, inputText: null,
focused: false, focused: false,
keyboardHeight: 0, keyboardHeight: 0,
selection: undefined,
}; };
componentDidMount() { componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow); this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide); this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
this.setState({ selection: { start: 0, end: 0 } });
} }
componentWillUnmount() { componentWillUnmount() {
@ -51,6 +53,7 @@ class UriBar extends React.PureComponent {
} }
handleChangeText = text => { handleChangeText = text => {
this.setState({ selection: undefined });
const newValue = text || ''; const newValue = text || '';
clearTimeout(this.changeTextTimeout); clearTimeout(this.changeTextTimeout);
const { updateSearchQuery, onSearchSubmitted, showUriBarSuggestions, navigation } = this.props; const { updateSearchQuery, onSearchSubmitted, showUriBarSuggestions, navigation } = this.props;
@ -59,7 +62,7 @@ class UriBar extends React.PureComponent {
this.changeTextTimeout = -1; this.changeTextTimeout = -1;
if (!showUriBarSuggestions) { if (!showUriBarSuggestions) {
/* this.changeTextTimeout = setTimeout(() => { this.changeTextTimeout = setTimeout(() => {
if (text.trim().length === 0) { if (text.trim().length === 0) {
// don't do anything if the text is empty // don't do anything if the text is empty
return; return;
@ -73,7 +76,7 @@ class UriBar extends React.PureComponent {
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: text } }); navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: text } });
} }
} }
}, UriBar.INPUT_TIMEOUT); */ }, UriBar.INPUT_TIMEOUT);
} }
this.setState({ inputText: newValue, currentValue: newValue }); this.setState({ inputText: newValue, currentValue: newValue });
}; };
@ -153,6 +156,26 @@ class UriBar extends React.PureComponent {
} }
}; };
handleFocus = () => {
this.setState(
{
focused: true,
},
() => {
this.setState({
selection: { start: 0, end: this.state.currentValue ? this.state.currentValue.length : 0 },
});
},
);
};
handleBlur = () => {
this.setState({
focused: false,
selection: { start: 0, end: 0 },
});
};
onSearchPageBlurred() { onSearchPageBlurred() {
this.setState({ currenValueSet: false }); this.setState({ currenValueSet: false });
} }
@ -246,8 +269,7 @@ class UriBar extends React.PureComponent {
}} }}
autoCorrect={false} autoCorrect={false}
style={uriBarStyle.uriText} style={uriBarStyle.uriText}
selection={!this.state.focused ? { start: 0, end: 0 } : null} selection={this.state.selection}
selectTextOnFocus
placeholder={__('Search movies, music, and more')} placeholder={__('Search movies, music, and more')}
underlineColorAndroid={'transparent'} underlineColorAndroid={'transparent'}
numberOfLines={1} numberOfLines={1}
@ -256,8 +278,8 @@ class UriBar extends React.PureComponent {
returnKeyType={'go'} returnKeyType={'go'}
inlineImageLeft={'baseline_search_black_24'} inlineImageLeft={'baseline_search_black_24'}
inlineImagePadding={16} inlineImagePadding={16}
onFocus={() => this.setState({ focused: true })} onFocus={this.handleFocus}
onBlur={() => this.setState({ focused: false })} onBlur={this.handleBlur}
onChangeText={this.handleChangeText} onChangeText={this.handleChangeText}
onSubmitEditing={this.handleSubmitEditing} onSubmitEditing={this.handleSubmitEditing}
/> />

View file

@ -58,7 +58,6 @@ window.__ = __;
const globalExceptionHandler = (error, isFatal) => { const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) { if (error && NativeModules.Firebase) {
console.log(error);
NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
} }
}; };
@ -201,7 +200,7 @@ const store = createStore(
); );
window.store = store; window.store = store;
const persistor = persistStore(store, persistOptions, err => { const persistor = persistStore(store, null, err => {
if (err) { if (err) {
console.log('Unable to load saved SETTINGS'); console.log('Unable to load saved SETTINGS');
} }

View file

@ -17,8 +17,8 @@ import {
TouchableOpacity, TouchableOpacity,
TouchableWithoutFeedback, TouchableWithoutFeedback,
View, View,
WebView,
} from 'react-native'; } from 'react-native';
import { WebView } from 'react-native-webview';
import { NavigationEvents } from 'react-navigation'; import { NavigationEvents } from 'react-navigation';
import { navigateBack, navigateToUri, formatLbryUrlForWeb } from 'utils/helper'; import { navigateBack, navigateToUri, formatLbryUrlForWeb } from 'utils/helper';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';

View file

@ -94,9 +94,9 @@ class SplashScreen extends React.PureComponent {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => { getSync(walletPassword, () => {
this.getUserSettings(); this.getUserSettings();
this.navigateToMain();
}); });
}); });
this.navigateToMain();
return; return;
} }
@ -137,32 +137,32 @@ class SplashScreen extends React.PureComponent {
user, user,
} = this.props; } = this.props;
Lbry.resolve({ urls: 'lbry://one' }).then(() => { // Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Leave the splash screen // Leave the splash screen
balanceSubscribe(); balanceSubscribe();
blacklistedOutpointsSubscribe(); blacklistedOutpointsSubscribe();
filteredOutpointsSubscribe(); filteredOutpointsSubscribe();
checkSubscriptionsInit(); checkSubscriptionsInit();
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_WALLET_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => { getSync(walletPassword, () => {
this.getUserSettings(); this.getUserSettings();
this.navigateToMain();
});
}); });
} else { });
NativeModules.VersionInfo.getAppVersion().then(appVersion => { this.navigateToMain();
this.setState({ shouldAuthenticate: true }); } else {
NativeModules.Firebase.getMessagingToken() NativeModules.VersionInfo.getAppVersion().then(appVersion => {
.then(firebaseToken => { this.setState({ shouldAuthenticate: true });
authenticate(appVersion, Platform.OS, firebaseToken); NativeModules.Firebase.getMessagingToken()
}) .then(firebaseToken => {
.catch(() => authenticate(appVersion, Platform.OS)); authenticate(appVersion, Platform.OS, firebaseToken);
}); })
} .catch(() => authenticate(appVersion, Platform.OS));
}); });
}
// });
}; };
handleAccountUnlockFailed() { handleAccountUnlockFailed() {
@ -200,8 +200,8 @@ class SplashScreen extends React.PureComponent {
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => { Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
if (unlocked) { if (unlocked) {
this.setState({ this.setState({
message: __('Testing network'), message: __('Authenticating'),
details: __('Waiting for name resolution'), details: __('Waiting for authentication'),
}); });
this.finishSplashScreen(); this.finishSplashScreen();
} else { } else {
@ -210,8 +210,8 @@ class SplashScreen extends React.PureComponent {
}); });
} else { } else {
this.setState({ this.setState({
message: __('Testing network'), message: __('Authenticating'),
details: __('Waiting for name resolution'), details: __('Waiting for authentication'),
}); });
this.finishSplashScreen(); this.finishSplashScreen();
} }
@ -315,8 +315,8 @@ class SplashScreen extends React.PureComponent {
this.setState( this.setState(
{ {
accountUnlockFailed: false, accountUnlockFailed: false,
message: __('Testing network'), message: __('Authenticating'),
details: __('Waiting for name resolution'), details: __('Waiting for authentication'),
}, },
() => this.finishSplashScreen(), () => this.finishSplashScreen(),
); );