e9a2f44899
## General - `setting.List`: returns full creator settings. Requires signature (i.e. you own the channel) - `setting.Get`: returns a public subset of the creator settings. No signature required, and it is mainly used by the GUI to determine the constraints of a channel (e.g. comments enabled? min tip requirements? etc.). Does not include private settings like "blocked words list". `doFetchCreatorSettings` will handle both of these. Clients that uses the stashed results (`settingsByChannelId`) just needs to be aware the result might not contain everything, depending on whether you own the channel or not. ## Misc Related Changes - Finally fix the reducer for COMMENT_FETCH_SETTINGS_COMPLETED to not purge the data on each call. - Change `doFetchCreatorSettings` to operate on a single channel instead of multiple. We ended up not using the multple mode anyway, so it was wasteful code trying to batch the promises. - `commentsDisabledChannelIds` is no longer needed. Previously, this was created just to differentiate between Creator (full) and Channel (subset) settings. It's cleaner to just use one object, so eliminated this. - Remove unused 'commentingEnabled'. ## Aside - There are now 2 ways to know if a channel has disabled comments: (1) from `comment.list` and `setting.Get|List`. Both of them updates `settingsByChannelId`, so it'll still be a single place for the GUI to check against.
50 lines
2 KiB
JavaScript
50 lines
2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
makeSelectClaimForUri,
|
|
makeSelectClaimIsMine,
|
|
selectFetchingMyChannels,
|
|
selectMyChannelClaims,
|
|
} from 'lbry-redux';
|
|
import {
|
|
makeSelectTopLevelCommentsForUri,
|
|
makeSelectTopLevelTotalPagesForUri,
|
|
selectIsFetchingComments,
|
|
selectIsFetchingReacts,
|
|
makeSelectTotalCommentsCountForUri,
|
|
selectOthersReactsById,
|
|
selectMyReactionsByCommentId,
|
|
makeSelectCommentIdsForUri,
|
|
selectSettingsByChannelId,
|
|
} 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),
|
|
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),
|
|
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);
|