mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
I think this the best solution so far, at the expense of a slight delay in scrolling if the network call stalls. - Added "fetching by ID" state so that we don't need to use the ugly N-retries method. - `scrollIntoView` doesn't work if the element is already in the viewport, and the `scrollBy` adjustment doesn't take into account the y-position restoration that we perform on certain type of pages. Use `window.scrollTo` instead and taking into account current scroll position.
54 lines
2.2 KiB
JavaScript
54 lines
2.2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
makeSelectClaimForUri,
|
|
makeSelectClaimIsMine,
|
|
selectFetchingMyChannels,
|
|
selectMyChannelClaims,
|
|
} from 'lbry-redux';
|
|
import {
|
|
makeSelectTopLevelCommentsForUri,
|
|
makeSelectTopLevelTotalPagesForUri,
|
|
selectIsFetchingComments,
|
|
selectIsFetchingCommentsById,
|
|
selectIsFetchingReacts,
|
|
makeSelectTotalCommentsCountForUri,
|
|
selectOthersReactsById,
|
|
selectMyReactionsByCommentId,
|
|
makeSelectCommentIdsForUri,
|
|
selectSettingsByChannelId,
|
|
makeSelectPinnedCommentsForUri,
|
|
} from 'redux/selectors/comments';
|
|
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
|
import CommentsList from './view';
|
|
|
|
const select = (state, props) => {
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
return {
|
|
myChannels: selectMyChannelClaims(state),
|
|
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
|
|
pinnedComments: makeSelectPinnedCommentsForUri(props.uri)(state),
|
|
topLevelComments: makeSelectTopLevelCommentsForUri(props.uri)(state),
|
|
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
|
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
|
claim: makeSelectClaimForUri(props.uri)(state),
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
isFetchingComments: selectIsFetchingComments(state),
|
|
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
|
isFetchingReacts: selectIsFetchingReacts(state),
|
|
fetchingChannels: selectFetchingMyChannels(state),
|
|
settingsByChannelId: selectSettingsByChannelId(state),
|
|
myReactsByCommentId: selectMyReactionsByCommentId(state),
|
|
othersReactsById: selectOthersReactsById(state),
|
|
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({
|
|
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
|
|
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
|
|
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
|
|
resetComments: (uri) => dispatch(doCommentReset(uri)),
|
|
});
|
|
|
|
export default connect(select, perform)(CommentsList);
|