From 4ed3809ffd589a2ff3aaaa562f80c99893342c51 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 6 Jan 2020 21:11:15 +0100 Subject: [PATCH] final fix for uri bar and some performance improvements --- lbry-app-strings.json | 7 +++- package-lock.json | 28 ++++++++++++---- package.json | 3 +- src/component/uriBar/view.js | 34 ++++++++++++++++---- src/index.js | 3 +- src/page/file/view.js | 2 +- src/page/splash/view.js | 62 ++++++++++++++++++------------------ 7 files changed, 91 insertions(+), 48 deletions(-) diff --git a/lbry-app-strings.json b/lbry-app-strings.json index 36cb121..1ccf34d 100644 --- a/lbry-app-strings.json +++ b/lbry-app-strings.json @@ -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?" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6a18e4d..38906d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index b0ed585..6a5c6d6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/component/uriBar/view.js b/src/component/uriBar/view.js index 94d41be..50c6adf 100644 --- a/src/component/uriBar/view.js +++ b/src/component/uriBar/view.js @@ -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} /> diff --git a/src/index.js b/src/index.js index 37b3502..68a7c79 100644 --- a/src/index.js +++ b/src/index.js @@ -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'); } diff --git a/src/page/file/view.js b/src/page/file/view.js index 5beb32d..9204b94 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -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'; diff --git a/src/page/splash/view.js b/src/page/splash/view.js index a298483..2cd731b 100644 --- a/src/page/splash/view.js +++ b/src/page/splash/view.js @@ -94,9 +94,9 @@ class SplashScreen extends React.PureComponent { NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => { getSync(walletPassword, () => { this.getUserSettings(); - this.navigateToMain(); }); }); + this.navigateToMain(); return; } @@ -137,32 +137,32 @@ class SplashScreen extends React.PureComponent { user, } = this.props; - Lbry.resolve({ urls: 'lbry://one' }).then(() => { - // Leave the splash screen - balanceSubscribe(); - blacklistedOutpointsSubscribe(); - filteredOutpointsSubscribe(); - checkSubscriptionsInit(); + // Lbry.resolve({ urls: 'lbry://one' }).then(() => { + // Leave the splash screen + balanceSubscribe(); + blacklistedOutpointsSubscribe(); + filteredOutpointsSubscribe(); + checkSubscriptionsInit(); - 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(); - }); + if (user && user.id && user.has_verified_email) { + // user already authenticated + NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(walletPassword => { + getSync(walletPassword, () => { + this.getUserSettings(); }); - } 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)); - }); - } - }); + }); + 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)); + }); + } + // }); }; 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(), );