From 15cbdcfacad8660934b5fbea25b52563e4e352ba Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 29 Dec 2019 10:34:00 +0100 Subject: [PATCH] add reactotron. fix batch resolve functionality for search results. --- index.js | 4 ++ package-lock.json | 53 ++++++++++++++++++++++++++- package.json | 6 ++- reactotron.js | 8 ++++ src/component/fileListItem/view.js | 6 ++- src/component/relatedContent/index.js | 2 +- src/component/relatedContent/view.js | 4 +- src/page/search/index.js | 2 +- src/page/search/view.js | 16 ++++---- 9 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 reactotron.js diff --git a/index.js b/index.js index 84a5965..8b9ee54 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,7 @@ +if (__DEV__) { + import('./reactotron').then(() => console.log('Reactotron Configured')); +} + import LBRYApp from './src/index'; export default LBRYApp; diff --git a/package-lock.json b/package-lock.json index 3641599..95e7bf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7047,8 +7047,8 @@ } }, "lbry-redux": { - "version": "github:lbryio/lbry-redux#abe90e0665cfad3fb8853501ec058c5d1f0d9cc8", - "from": "github:lbryio/lbry-redux#abe90e0665cfad3fb8853501ec058c5d1f0d9cc8", + "version": "github:lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3", + "from": "github:lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3", "requires": { "proxy-polyfill": "0.1.6", "reselect": "^3.0.0", @@ -8569,6 +8569,12 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, + "mitt": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/mitt/-/mitt-1.1.3.tgz", + "integrity": "sha512-mUDCnVNsAi+eD6qA0HkRkwYczbLHJ49z17BGe2PYRhZL4wpZUFZGJHU7/5tmvohoma+Hdn0Vh/oJTiPEmgSruA==", + "dev": true + }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -10181,6 +10187,43 @@ "integrity": "sha512-kv5QlFFSZWo7OlJFNYbxRtY66JImuP2LcrFgyJfQaf85gSP+byzG21UbDQEYjU7f//ny8rwiEkO6py2Y+fEgAQ==", "dev": true }, + "reactotron-core-client": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/reactotron-core-client/-/reactotron-core-client-2.8.6.tgz", + "integrity": "sha512-xgg6dusfgQHC98f4iRH/Zak/PNvA46znupEd2U7DSCmmhZbfCpSSveKUsYok0OW0HiSCSvi41tNELj+QU6pRVQ==", + "dev": true + }, + "reactotron-react-native": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/reactotron-react-native/-/reactotron-react-native-4.0.2.tgz", + "integrity": "sha512-zY5m0TV9y52h31/Vvd/Zs3jneEKYWbJ6vGrBeZ/d6Z2gVvwI3su+7B2qh8s00KHStIF4MTg0MrKc0FYRFWmmoQ==", + "dev": true, + "requires": { + "mitt": "1.1.3", + "query-string": "6.8.1", + "reactotron-core-client": "2.8.6", + "rn-host-detect": "1.1.5" + }, + "dependencies": { + "query-string": { + "version": "6.8.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.8.1.tgz", + "integrity": "sha512-g6y0Lbq10a5pPQpjlFuojfMfV1Pd2Jw9h75ypiYPPia3Gcq2rgkKiIwbkS6JxH7c5f5u/B/sB+d13PU+g1eu4Q==", + "dev": true, + "requires": { + "decode-uri-component": "^0.2.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + } + } + } + }, + "reactotron-redux": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/reactotron-redux/-/reactotron-redux-3.1.2.tgz", + "integrity": "sha512-2ScTmE2+kxjKPc7+vsYuw+igkhd4tjoftn4ouugVudQCO7B5vXVyQwLkNv/feaFfFoPlCQSVeJVg7PdzDFOsEQ==", + "dev": true + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -10543,6 +10586,12 @@ } } }, + "rn-host-detect": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/rn-host-detect/-/rn-host-detect-1.1.5.tgz", + "integrity": "sha512-ufk2dFT3QeP9HyZ/xTuMtW27KnFy815CYitJMqQm+pgG3ZAtHBsrU8nXizNKkqXGy3bQmhEoloVbrfbvMJMqkg==", + "dev": true + }, "rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/package.json b/package.json index a4754ff..1299599 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "base-64": "^0.1.0", "@expo/vector-icons": "^8.1.0", "gfycat-style-urls": "^1.0.3", - "lbry-redux": "lbryio/lbry-redux#abe90e0665cfad3fb8853501ec058c5d1f0d9cc8", + "lbry-redux": "lbryio/lbry-redux#2c569a729bb40d45249ca38150b00922162b7ce3", "lbryinc": "lbryio/lbryinc#053ca52f4f7f9bf8eb62a3581b183671a475ad1c", "lodash": ">=4.17.11", "merge": ">=1.2.1", @@ -70,6 +70,8 @@ "metro-react-native-babel-preset": "^0.56.0", "prettier": "^1.11.1", "@react-native-community/eslint-config": "^0.0.5", - "react-devtools": "^3.6.3" + "react-devtools": "^3.6.3", + "reactotron-react-native": "4.0.2", + "reactotron-redux": "3.1.2" } } diff --git a/reactotron.js b/reactotron.js new file mode 100644 index 0000000..7de9b5f --- /dev/null +++ b/reactotron.js @@ -0,0 +1,8 @@ +import AsyncStorage from '@react-native-community/async-storage'; +import Reactotron from 'reactotron-react-native' + +Reactotron + .setAsyncStorageHandler(AsyncStorage) // AsyncStorage would either come from `react-native` or `@react-native-community/async-storage` depending on where you get it from + .configure() // controls connection & communication settings + .useReactNative() // add all built-in react native plugins + .connect(); // let's connect! \ No newline at end of file diff --git a/src/component/fileListItem/view.js b/src/component/fileListItem/view.js index 48d4aa0..32f87c0 100644 --- a/src/component/fileListItem/view.js +++ b/src/component/fileListItem/view.js @@ -42,13 +42,15 @@ class FileListItem extends React.PureComponent { componentDidMount() { const { claim, resolveUri, uri, batchResolve } = this.props; if (!claim && !batchResolve) { + console.log('resolving on componentDidMount?'); resolveUri(uri); } } componentDidUpdate() { - const { claim, resolveUri, uri } = this.props; - if (!claim && uri !== this.state.url) { + const { claim, resolveUri, uri, batchResolve } = this.props; + if (!claim && uri !== this.state.url && !batchResolve) { + console.log('resolving on componentDidUpdate?'); this.setState({ url: uri }, () => resolveUri(uri)); } } diff --git a/src/component/relatedContent/index.js b/src/component/relatedContent/index.js index 6cb46de..c7747e9 100644 --- a/src/component/relatedContent/index.js +++ b/src/component/relatedContent/index.js @@ -18,7 +18,7 @@ const select = (state, props) => ({ const perform = dispatch => ({ resolveUris: uris => dispatch(doResolveUris(uris)), - searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)), + searchRecommended: query => dispatch(doSearch(query, 20, undefined, true, false)), }); export default connect( diff --git a/src/component/relatedContent/view.js b/src/component/relatedContent/view.js index 639587c..64cd64e 100644 --- a/src/component/relatedContent/view.js +++ b/src/component/relatedContent/view.js @@ -38,8 +38,8 @@ export default class RelatedContent extends React.PureComponent { } componentDidUpdate() { - const { resolveUris, recommendedContent } = this.props; - if (!this.state.resolveStarted) { + const { isSearching, resolveUris, recommendedContent } = this.props; + if (!isSearching && !this.state.resolveStarted) { this.setState({ resolveStarted: true }, () => { if (recommendedContent && recommendedContent.length > 0) { // batch resolve the uris diff --git a/src/page/search/index.js b/src/page/search/index.js index b065d64..5e4a3a2 100644 --- a/src/page/search/index.js +++ b/src/page/search/index.js @@ -28,7 +28,7 @@ const select = state => ({ }); const perform = dispatch => ({ - search: query => dispatch(doSearch(query, numSearchResults)), + search: query => dispatch(doSearch(query, numSearchResults, null, false, false)), claimSearch: options => dispatch(doClaimSearch(options)), updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)), pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)), diff --git a/src/page/search/view.js b/src/page/search/view.js index 890fd47..10c71b1 100644 --- a/src/page/search/view.js +++ b/src/page/search/view.js @@ -59,6 +59,7 @@ class SearchPage extends React.PureComponent { claimSearchOptions: null, claimSearchRun: false, showTagResult: false, + resultsResolved: false, }); search(searchQuery); } @@ -110,6 +111,13 @@ class SearchPage extends React.PureComponent { componentDidUpdate() { const { isSearching, resolveUris, uris } = this.props; + if (!isSearching && !this.state.resultsResolved) { + this.setState({ resultsResolved: true }, () => { + if (uris && uris.length > 0) { + resolveUris(uris); + } + }); + } } getSearchQuery() { @@ -208,13 +216,7 @@ class SearchPage extends React.PureComponent { ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null} ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent(this.state.showTagResult) : null} renderItem={({ item }) => ( - + )} /> )}