a74dbe1e43
## New behavior: - If you have commented on a claim before, the channel selector will be clamped to that channel. - There might be more than 1 channel if commented in the past. - This includes blocked comments, i.e. if the creator blocked you, you will not see your comment, yet your channel-selector is clamped to the used channel. - EXCEPTION: you can use other channels if it's your own claim (for now). ## Approach - Run `comment.List` over all your channels on the specific content. This covers nested replies and pagination (sweet). - So, if the total is non-zero, mark that channel(s) as having commented on the claim. - Only fetch this once per content claim. - In the comment channel-selector, clamp the list to this value.
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
selectClaimForUri,
|
|
selectClaimIsMine,
|
|
selectHasChannels,
|
|
selectFetchingMyChannels,
|
|
makeSelectTagInClaimOrChannelForUri,
|
|
} from 'redux/selectors/claims';
|
|
import { CommentCreate } from './view';
|
|
import { DISABLE_SUPPORT_TAG } from 'constants/tags';
|
|
import { doCommentCreate, doFetchCreatorSettings, doCommentById } from 'redux/actions/comments';
|
|
import { doSendTip, doSendCashTip } from 'redux/actions/wallet';
|
|
import { doToast } from 'redux/actions/notifications';
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
|
import { selectMyCommentedChannelIdsForId, selectSettingsByChannelId } from 'redux/selectors/comments';
|
|
import { getChannelIdFromClaim } from 'util/claim';
|
|
import { doOpenModal } from 'redux/actions/app';
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
const select = (state, props) => {
|
|
const { uri } = props;
|
|
|
|
const claim = selectClaimForUri(state, uri);
|
|
const { claim_id: claimId, name, signing_channel: channel } = claim || {};
|
|
|
|
// setup variables for tip API
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
|
const tipChannelName = channel ? channel.name : name;
|
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
const { claim_id: activeChannelClaimId, name: activeChannelName, canonical_url: activeChannelUrl } =
|
|
activeChannelClaim || {};
|
|
|
|
return {
|
|
activeChannelClaimId,
|
|
activeChannelName,
|
|
activeChannelUrl,
|
|
hasChannels: selectHasChannels(state),
|
|
claimId,
|
|
channelClaimId,
|
|
tipChannelName,
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
|
isFetchingChannels: selectFetchingMyChannels(state),
|
|
settingsByChannelId: selectSettingsByChannelId(state),
|
|
supportDisabled: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_SUPPORT_TAG)(state),
|
|
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
|
|
myCommentedChannelIds: selectMyCommentedChannelIdsForId(state, claim?.claim_id),
|
|
};
|
|
};
|
|
|
|
const perform = {
|
|
doCommentCreate,
|
|
doFetchCreatorSettings,
|
|
doToast,
|
|
doCommentById,
|
|
doSendCashTip,
|
|
doSendTip,
|
|
doOpenModal,
|
|
};
|
|
|
|
export default connect(select, perform)(CommentCreate);
|