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.",
"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.",
"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": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/react-native-exception-handler/-/react-native-exception-handler-2.9.0.tgz",
"integrity": "sha512-XRHhGH5aM4lSenX4zZBa07JaszJGXeF8cv1KY314Q4qJWOihKWLpkdvwqwsBieZ2iy8DPhdAVioQzw8JLD/Okw=="
"version": "2.10.8",
"resolved": "https://registry.npmjs.org/react-native-exception-handler/-/react-native-exception-handler-2.10.8.tgz",
"integrity": "sha512-ZN+jwpADRkCUNdad/50k0mZdMoICGrGdtaxgvRU+pNcWRRBAXJhuo4+jY0eQaoVpx1ghycGE6tBu9ka8gL2NOQ=="
},
"react-native-fast-image": {
"version": "7.0.2",
@ -10110,6 +10110,22 @@
"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": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-4.0.10.tgz",
@ -10316,9 +10332,9 @@
}
},
"redux-persist": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-6.0.0.tgz",
"integrity": "sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ=="
"version": "5.10.0",
"resolved": "https://registry.npmjs.org/redux-persist/-/redux-persist-5.10.0.tgz",
"integrity": "sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg=="
},
"redux-persist-filesystem-storage": {
"version": "2.1.0",

View file

@ -23,7 +23,7 @@
"@react-native-community/masked-view": "^0.1.5",
"react-native-camera": "^3.15.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-fs": "^2.13.3",
"react-native-gesture-handler": "1.5.2",
@ -36,6 +36,7 @@
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#7992ff945872f9bd00a3736d9ff1318f343abf47",
"react-native-webview": "^8.0.2",
"react-navigation": "^4.0.10",
"react-navigation-drawer": "^2.3.3",
"react-navigation-redux-helpers": "^3.0.2",

View file

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

View file

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

View file

@ -17,8 +17,8 @@ import {
TouchableOpacity,
TouchableWithoutFeedback,
View,
WebView,
} from 'react-native';
import { WebView } from 'react-native-webview';
import { NavigationEvents } from 'react-navigation';
import { navigateBack, navigateToUri, formatLbryUrlForWeb } from 'utils/helper';
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 => {
getSync(walletPassword, () => {
this.getUserSettings();
});
});
this.navigateToMain();
});
});
return;
}
@ -137,7 +137,7 @@ class SplashScreen extends React.PureComponent {
user,
} = this.props;
Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Lbry.resolve({ urls: 'lbry://one' }).then(() => {
// Leave the splash screen
balanceSubscribe();
blacklistedOutpointsSubscribe();
@ -149,9 +149,9 @@ class SplashScreen extends React.PureComponent {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => {
getSync(walletPassword, () => {
this.getUserSettings();
});
});
this.navigateToMain();
});
});
} else {
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
this.setState({ shouldAuthenticate: true });
@ -162,7 +162,7 @@ class SplashScreen extends React.PureComponent {
.catch(() => authenticate(appVersion, Platform.OS));
});
}
});
// });
};
handleAccountUnlockFailed() {
@ -200,8 +200,8 @@ class SplashScreen extends React.PureComponent {
Lbry.wallet_unlock({ password: password || '' }).then(unlocked => {
if (unlocked) {
this.setState({
message: __('Testing network'),
details: __('Waiting for name resolution'),
message: __('Authenticating'),
details: __('Waiting for authentication'),
});
this.finishSplashScreen();
} else {
@ -210,8 +210,8 @@ class SplashScreen extends React.PureComponent {
});
} else {
this.setState({
message: __('Testing network'),
details: __('Waiting for name resolution'),
message: __('Authenticating'),
details: __('Waiting for authentication'),
});
this.finishSplashScreen();
}
@ -315,8 +315,8 @@ class SplashScreen extends React.PureComponent {
this.setState(
{
accountUnlockFailed: false,
message: __('Testing network'),
details: __('Waiting for name resolution'),
message: __('Authenticating'),
details: __('Waiting for authentication'),
},
() => this.finishSplashScreen(),
);