diff --git a/CHANGELOG.md b/CHANGELOG.md
index 123c53477..a856749b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
* Changed the File page to make it clearer how to to open the folder for a file
* The upgrade message is now friendlier and includes a link to the release notes.
* Improved Discover page load time by batching all URIs into one API call
+ * Local settings refactored and no longer intermixed with LBRY API library.
### Fixed
* Improve layout (and implementation) of the icon panel in file tiles and cards
diff --git a/ui/js/actions/search.js b/ui/js/actions/search.js
index 2d6be08ee..a83ce60bb 100644
--- a/ui/js/actions/search.js
+++ b/ui/js/actions/search.js
@@ -1,6 +1,5 @@
import * as types from "constants/action_types";
import lbryuri from "lbryuri";
-import lighthouse from "lighthouse";
import { doResolveUri } from "actions/content";
import { doNavigate } from "actions/navigation";
import { selectCurrentPage } from "selectors/navigation";
@@ -25,28 +24,41 @@ export function doSearch(query) {
if (page != "search") {
dispatch(doNavigate("search", { query: query }));
} else {
- lighthouse.search(query).then(results => {
- const actions = [];
+ fetch("https://lighthouse.lbry.io/search?s=" + query)
+ .then(response => {
+ return response.status === 200
+ ? Promise.resolve(response.json())
+ : Promise.reject(new Error(response.statusText));
+ })
+ .then(data => {
+ console.log(data);
+ let uris = [];
+ let actions = [];
- results.forEach(result => {
- const uri = lbryuri.build({
- channelName: result.channel_name,
- contentName: result.name,
- claimId: result.channel_id || result.claim_id,
+ data.forEach(result => {
+ const uri = lbryuri.build({
+ name: result.name,
+ claimId: result.claimId,
+ });
+ actions.push(doResolveUri(uri));
+ uris.push(uri);
});
- actions.push(doResolveUri(uri));
- });
- actions.push({
- type: types.SEARCH_COMPLETED,
- data: {
- query,
- results,
- },
+ actions.push({
+ type: types.SEARCH_COMPLETED,
+ data: {
+ query,
+ uris,
+ },
+ });
+ dispatch(batchActions(...actions));
+ })
+ .catch(err => {
+ console.log(err);
+ dispatch({
+ type: types.SEARCH_CANCELLED,
+ });
});
-
- dispatch(batchActions(...actions));
- });
}
};
}
diff --git a/ui/js/component/channelTile/index.js b/ui/js/component/channelTile/index.js
new file mode 100644
index 000000000..2e4c438f7
--- /dev/null
+++ b/ui/js/component/channelTile/index.js
@@ -0,0 +1,19 @@
+import React from "react";
+import { connect } from "react-redux";
+import { doFetchClaimCountByChannel } from "actions/content";
+import { makeSelectClaimForUri } from "selectors/claims";
+import { doNavigate } from "actions/navigation";
+import { makeSelectTotalItemsForChannel } from "selectors/content";
+import ChannelTile from "./view";
+
+const select = (state, props) => ({
+ claim: makeSelectClaimForUri(props.uri)(state),
+ totalItems: makeSelectTotalItemsForChannel(props.uri)(state),
+});
+
+const perform = dispatch => ({
+ fetchClaimCount: uri => dispatch(doFetchClaimCountByChannel(uri)),
+ navigate: (path, params) => dispatch(doNavigate(path, params)),
+});
+
+export default connect(select, perform)(ChannelTile);
diff --git a/ui/js/component/channelTile/view.jsx b/ui/js/component/channelTile/view.jsx
new file mode 100644
index 000000000..973d1dff5
--- /dev/null
+++ b/ui/js/component/channelTile/view.jsx
@@ -0,0 +1,50 @@
+import React from "react";
+import { TruncatedText, BusyMessage } from "component/common.js";
+
+class ChannelTile extends React.PureComponent {
+ componentDidMount() {
+ const { uri, fetchClaimCount } = this.props;
+
+ fetchClaimCount(uri);
+ }
+
+ componentWillReceiveProps(nextProps) {
+ const { uri, fetchClaimCount } = this.props;
+
+ if (nextProps.uri != uri) {
+ fetchClaimCount(uri);
+ }
+ }
+
+ render() {
+ const { navigate, totalItems, uri } = this.props;
+
+ let onClick = () => navigate("/show", { uri });
+
+ return (
+
+
+
{__("An updated version of LBRY is now available.")} diff --git a/ui/js/page/search/index.js b/ui/js/page/search/index.js index a6c571882..8426f3637 100644 --- a/ui/js/page/search/index.js +++ b/ui/js/page/search/index.js @@ -1,10 +1,6 @@ import React from "react"; import { connect } from "react-redux"; -import { - selectIsSearching, - selectSearchQuery, - selectCurrentSearchResults, -} from "selectors/search"; +import { selectIsSearching, selectSearchQuery } from "selectors/search"; import { doNavigate } from "actions/navigation"; import SearchPage from "./view"; diff --git a/ui/js/page/search/view.jsx b/ui/js/page/search/view.jsx index 0843b6141..e2ca65da2 100644 --- a/ui/js/page/search/view.jsx +++ b/ui/js/page/search/view.jsx @@ -3,7 +3,6 @@ import lbryuri from "lbryuri"; import FileTile from "component/fileTile"; import FileListSearch from "component/fileListSearch"; import { ToolTip } from "component/tooltip.js"; -import { BusyMessage } from "component/common.js"; class SearchPage extends React.PureComponent { render() { diff --git a/ui/js/reducers/search.js b/ui/js/reducers/search.js index ed500b987..c44c78cd2 100644 --- a/ui/js/reducers/search.js +++ b/ui/js/reducers/search.js @@ -1,7 +1,10 @@ import * as types from "constants/action_types"; const reducers = {}; -const defaultState = {}; +const defaultState = { + urisByQuery: {}, + searching: false, +}; reducers[types.SEARCH_STARTED] = function(state, action) { const { query } = action.data; @@ -12,17 +15,11 @@ reducers[types.SEARCH_STARTED] = function(state, action) { }; reducers[types.SEARCH_COMPLETED] = function(state, action) { - const { query, results } = action.data; - const oldResults = Object.assign({}, state.results); - const newByQuery = Object.assign({}, oldResults.byQuery); - newByQuery[query] = results; - const newResults = Object.assign({}, oldResults, { - byQuery: newByQuery, - }); + const { query, uris } = action.data; return Object.assign({}, state, { searching: false, - results: newResults, + urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris }), }); }; diff --git a/ui/js/selectors/content.js b/ui/js/selectors/content.js index 0818134de..8e083ca93 100644 --- a/ui/js/selectors/content.js +++ b/ui/js/selectors/content.js @@ -34,6 +34,13 @@ export const selectChannelPages = createSelector( state => state.channelPages || {} ); +export const makeSelectTotalItemsForChannel = uri => { + return createSelector( + selectChannelPages, + byUri => (byUri && byUri[uri]) * 10 + ); +}; + export const makeSelectTotalPagesForChannel = uri => { return createSelector(selectChannelPages, byUri => byUri && byUri[uri]); }; diff --git a/ui/js/selectors/search.js b/ui/js/selectors/search.js index 5c1d70489..09468a43c 100644 --- a/ui/js/selectors/search.js +++ b/ui/js/selectors/search.js @@ -18,21 +18,14 @@ export const selectIsSearching = createSelector( state => !!state.searching ); -export const selectSearchResults = createSelector( +export const selectSearchUrisByQuery = createSelector( _selectState, - state => state.results || {} + state => state.urisByQuery ); -export const selectSearchResultsByQuery = createSelector( - selectSearchResults, - results => results.byQuery || {} -); - -export const selectCurrentSearchResults = createSelector( - selectSearchQuery, - selectSearchResultsByQuery, - (query, byQuery) => byQuery[query] -); +export const makeSelectSearchUris = query => { + return createSelector(selectSearchUrisByQuery, byQuery => byQuery[query]); +}; export const selectWunderBarAddress = createSelector( selectCurrentPage,