saner paging, fix resolving uri state, fix counts in channel results, fix search prefix
This commit is contained in:
parent
9e7800d6d7
commit
3735498785
8 changed files with 57 additions and 39 deletions
|
@ -20,7 +20,7 @@
|
|||
"electron-rebuild": "^1.5.11"
|
||||
},
|
||||
"lbrySettings": {
|
||||
"lbrynetDaemonVersion": "0.17.0rc13",
|
||||
"lbrynetDaemonVersion": "0.17.0rc16",
|
||||
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
|
||||
},
|
||||
"license": "MIT"
|
||||
|
|
|
@ -45,11 +45,12 @@ export function doResolveUris(uris) {
|
|||
let resolveInfo = {};
|
||||
lbry.resolve({ uris: urisToResolve }).then(result => {
|
||||
for (let [uri, uriResolveInfo] of Object.entries(result)) {
|
||||
const { claim, certificate } = uriResolveInfo || {
|
||||
claim: null,
|
||||
certificate: null,
|
||||
const { claim, certificate, claims_in_channel } = uriResolveInfo || {
|
||||
claim: undefined,
|
||||
claims_in_channel: undefined,
|
||||
certificate: undefined,
|
||||
};
|
||||
resolveInfo[uri] = { claim, certificate };
|
||||
resolveInfo[uri] = { claim, certificate, claims_in_channel };
|
||||
}
|
||||
|
||||
dispatch({
|
||||
|
|
|
@ -5,11 +5,13 @@ import { doNavigate } from "actions/navigation";
|
|||
import { selectCurrentPage } from "selectors/navigation";
|
||||
import batchActions from "util/batchActions";
|
||||
|
||||
export function doSearch(query) {
|
||||
export function doSearch(rawQuery) {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState();
|
||||
const page = selectCurrentPage(state);
|
||||
|
||||
const query = rawQuery.replace(/^lbry:\/\//, "");
|
||||
|
||||
if (!query) {
|
||||
return dispatch({
|
||||
type: types.SEARCH_CANCELLED,
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
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 { doResolveUri } from "actions/content";
|
||||
import { makeSelectTotalItemsForChannel } from "selectors/content";
|
||||
import { makeSelectIsUriResolving } from "selectors/content";
|
||||
import ChannelTile from "./view";
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
totalItems: makeSelectTotalItemsForChannel(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchClaimCount: uri => dispatch(doFetchClaimCountByChannel(uri)),
|
||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ChannelTile);
|
||||
|
|
|
@ -3,21 +3,21 @@ import { TruncatedText, BusyMessage } from "component/common.js";
|
|||
|
||||
class ChannelTile extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { uri, fetchClaimCount } = this.props;
|
||||
const { uri, resolveUri } = this.props;
|
||||
|
||||
fetchClaimCount(uri);
|
||||
resolveUri(uri);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { uri, fetchClaimCount } = this.props;
|
||||
const { uri, resolveUri } = this.props;
|
||||
|
||||
if (nextProps.uri != uri) {
|
||||
fetchClaimCount(uri);
|
||||
resolveUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigate, totalItems, uri } = this.props;
|
||||
const { claim, navigate, isResolvingUri, totalItems, uri } = this.props;
|
||||
|
||||
let onClick = () => navigate("/show", { uri });
|
||||
|
||||
|
@ -31,13 +31,15 @@ class ChannelTile extends React.PureComponent {
|
|||
</h3>
|
||||
</div>
|
||||
<div className="card__content card__subtext">
|
||||
{isNaN(totalItems) &&
|
||||
{isResolvingUri &&
|
||||
<BusyMessage message={__("Resolving channel")} />}
|
||||
{totalItems > 0 &&
|
||||
<span>
|
||||
This is a channel with over {totalItems} items inside of it.
|
||||
This is a channel with {totalItems}{" "}
|
||||
{totalItems === 1 ? " item" : " items"} inside of it.
|
||||
</span>}
|
||||
{totalItems === 0 &&
|
||||
{!isResolvingUri &&
|
||||
!totalItems &&
|
||||
<span className="empty">This is an empty channel.</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ const reducers = {};
|
|||
const defaultState = {
|
||||
playingUri: null,
|
||||
rewardedContentClaimIds: [],
|
||||
channelPages: {},
|
||||
channelClaimCounts: {},
|
||||
};
|
||||
|
||||
reducers[types.FETCH_FEATURED_CONTENT_STARTED] = function(state, action) {
|
||||
|
@ -48,31 +48,38 @@ reducers[types.RESOLVE_URIS_STARTED] = function(state, action) {
|
|||
});
|
||||
};
|
||||
|
||||
reducers[types.RESOLVE_URIS_COMPLETED] = function(state, action) {
|
||||
const { resolveInfo } = action.data;
|
||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||
|
||||
for (let [uri, { certificate, claims_in_channel }] of Object.entries(
|
||||
resolveInfo
|
||||
)) {
|
||||
if (certificate && !isNaN(claims_in_channel)) {
|
||||
channelClaimCounts[uri] = claims_in_channel;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
channelClaimCounts,
|
||||
resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]),
|
||||
});
|
||||
};
|
||||
|
||||
reducers[types.SET_PLAYING_URI] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
playingUri: action.data.uri,
|
||||
});
|
||||
};
|
||||
|
||||
// reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
|
||||
// const channelPages = Object.assign({}, state.channelPages);
|
||||
// const { uri, claims } = action.data;
|
||||
//
|
||||
// channelPages[uri] = totalPages;
|
||||
//
|
||||
// return Object.assign({}, state, {
|
||||
// channelPages,
|
||||
// });
|
||||
// };
|
||||
|
||||
reducers[types.FETCH_CHANNEL_CLAIM_COUNT_COMPLETED] = function(state, action) {
|
||||
const channelPages = Object.assign({}, state.channelPages);
|
||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||
const { uri, totalClaims } = action.data;
|
||||
|
||||
channelPages[uri] = Math.ceil(totalClaims / 10);
|
||||
channelClaimCounts[uri] = totalClaims;
|
||||
|
||||
return Object.assign({}, state, {
|
||||
channelPages,
|
||||
channelClaimCounts,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -29,20 +29,20 @@ export const makeSelectIsUriResolving = uri => {
|
|||
);
|
||||
};
|
||||
|
||||
export const selectChannelPages = createSelector(
|
||||
export const selectChannelClaimCounts = createSelector(
|
||||
_selectState,
|
||||
state => state.channelPages || {}
|
||||
state => state.channelClaimCounts || {}
|
||||
);
|
||||
|
||||
export const makeSelectTotalItemsForChannel = uri => {
|
||||
return createSelector(
|
||||
selectChannelPages,
|
||||
byUri => (byUri && byUri[uri]) * 10
|
||||
);
|
||||
return createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
|
||||
};
|
||||
|
||||
export const makeSelectTotalPagesForChannel = uri => {
|
||||
return createSelector(selectChannelPages, byUri => byUri && byUri[uri]);
|
||||
return createSelector(
|
||||
selectChannelClaimCounts,
|
||||
byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / 10)
|
||||
);
|
||||
};
|
||||
|
||||
export const selectRewardContentClaimIds = createSelector(
|
||||
|
|
|
@ -24,7 +24,11 @@ export const selectSearchUrisByQuery = createSelector(
|
|||
);
|
||||
|
||||
export const makeSelectSearchUris = query => {
|
||||
return createSelector(selectSearchUrisByQuery, byQuery => byQuery[query]);
|
||||
//replace statement below is kind of ugly, and repeated in doSearch action
|
||||
return createSelector(
|
||||
selectSearchUrisByQuery,
|
||||
byQuery => byQuery[query ? query.replace(/^lbry:\/\//, "") : query]
|
||||
);
|
||||
};
|
||||
|
||||
export const selectWunderBarAddress = createSelector(
|
||||
|
|
Loading…
Add table
Reference in a new issue