Commentron: incorporate 'setting.Get' into 'doFetchCreatorSettings'
## 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.
This commit is contained in:
parent
658e9bd1db
commit
e9a2f44899
12 changed files with 212 additions and 199 deletions
17
flow-typed/Comment.js
vendored
17
flow-typed/Comment.js
vendored
|
@ -58,7 +58,6 @@ declare type CommentsState = {
|
||||||
blockingByUri: {},
|
blockingByUri: {},
|
||||||
unBlockingByUri: {},
|
unBlockingByUri: {},
|
||||||
togglingForDelegatorMap: {[string]: Array<string>}, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
|
togglingForDelegatorMap: {[string]: Array<string>}, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
|
||||||
commentsDisabledChannelIds: Array<string>,
|
|
||||||
settingsByChannelId: { [string]: PerChannelSettings }, // ChannelID -> settings
|
settingsByChannelId: { [string]: PerChannelSettings }, // ChannelID -> settings
|
||||||
fetchingSettings: boolean,
|
fetchingSettings: boolean,
|
||||||
fetchingBlockedWords: boolean,
|
fetchingBlockedWords: boolean,
|
||||||
|
@ -222,10 +221,20 @@ declare type ModerationAmIParams = {
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type SettingsParams = {
|
declare type SettingsParams = {
|
||||||
channel_name: string,
|
channel_name?: string,
|
||||||
channel_id: string,
|
channel_id: string,
|
||||||
signature: string,
|
signature?: string,
|
||||||
signing_ts: string,
|
signing_ts?: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type SettingsResponse = {
|
||||||
|
words?: string,
|
||||||
|
comments_enabled: boolean,
|
||||||
|
min_tip_amount_comment: number,
|
||||||
|
min_tip_amount_super_chat: number,
|
||||||
|
slow_mode_min_gap: number,
|
||||||
|
curse_jar_amount: number,
|
||||||
|
filters_enabled?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type UpdateSettingsParams = {
|
declare type UpdateSettingsParams = {
|
||||||
|
|
|
@ -34,6 +34,7 @@ const Comments = {
|
||||||
setting_unblock_word: (params: BlockWordParams) => fetchCommentsApi('setting.UnBlockWord', params),
|
setting_unblock_word: (params: BlockWordParams) => fetchCommentsApi('setting.UnBlockWord', params),
|
||||||
setting_list_blocked_words: (params: SettingsParams) => fetchCommentsApi('setting.ListBlockedWords', params),
|
setting_list_blocked_words: (params: SettingsParams) => fetchCommentsApi('setting.ListBlockedWords', params),
|
||||||
setting_update: (params: UpdateSettingsParams) => fetchCommentsApi('setting.Update', params),
|
setting_update: (params: UpdateSettingsParams) => fetchCommentsApi('setting.Update', params),
|
||||||
|
setting_get: (params: SettingsParams) => fetchCommentsApi('setting.Get', params),
|
||||||
super_list: (params: SuperListParams) => fetchCommentsApi('comment.SuperChatList', params),
|
super_list: (params: SuperListParams) => fetchCommentsApi('comment.SuperChatList', params),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,30 +7,42 @@ import {
|
||||||
doSendTip,
|
doSendTip,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { doOpenModal, doSetActiveChannel } from 'redux/actions/app';
|
import { doOpenModal, doSetActiveChannel } from 'redux/actions/app';
|
||||||
import { doCommentCreate } from 'redux/actions/comments';
|
import { doCommentCreate, doFetchCreatorSettings } from 'redux/actions/comments';
|
||||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||||
import { makeSelectCommentsDisabledForUri } from 'redux/selectors/comments';
|
import { selectSettingsByChannelId } from 'redux/selectors/comments';
|
||||||
import { CommentCreate } from './view';
|
import { CommentCreate } from './view';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||||
commentsDisabledBySettings: makeSelectCommentsDisabledForUri(props.uri)(state),
|
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
channels: selectMyChannelClaims(state),
|
channels: selectMyChannelClaims(state),
|
||||||
isFetchingChannels: selectFetchingMyChannels(state),
|
isFetchingChannels: selectFetchingMyChannels(state),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
|
settingsByChannelId: selectSettingsByChannelId(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = (dispatch, ownProps) => ({
|
const perform = (dispatch, ownProps) => ({
|
||||||
createComment: (comment, claimId, parentId, txid, payment_intent_id, environment) =>
|
createComment: (comment, claimId, parentId, txid, payment_intent_id, environment) =>
|
||||||
dispatch(doCommentCreate(comment, claimId, parentId, ownProps.uri, ownProps.livestream, txid, payment_intent_id, environment)),
|
dispatch(
|
||||||
|
doCommentCreate(
|
||||||
|
comment,
|
||||||
|
claimId,
|
||||||
|
parentId,
|
||||||
|
ownProps.uri,
|
||||||
|
ownProps.livestream,
|
||||||
|
txid,
|
||||||
|
payment_intent_id,
|
||||||
|
environment
|
||||||
|
)
|
||||||
|
),
|
||||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||||
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
||||||
sendTip: (params, callback, errorCallback) => dispatch(doSendTip(params, false, callback, errorCallback, false)),
|
sendTip: (params, callback, errorCallback) => dispatch(doSendTip(params, false, callback, errorCallback, false)),
|
||||||
doToast: (options) => dispatch(doToast(options)),
|
doToast: (options) => dispatch(doToast(options)),
|
||||||
|
doFetchCreatorSettings: (channelClaimId) => dispatch(doFetchCreatorSettings(channelClaimId)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(CommentCreate);
|
export default connect(select, perform)(CommentCreate);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import ChannelThumbnail from 'component/channelThumbnail';
|
||||||
import UriIndicator from 'component/uriIndicator';
|
import UriIndicator from 'component/uriIndicator';
|
||||||
import Empty from 'component/common/empty';
|
import Empty from 'component/common/empty';
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
|
import { getChannelIdFromClaim } from 'util/claim';
|
||||||
|
|
||||||
let stripeEnvironment = 'test';
|
let stripeEnvironment = 'test';
|
||||||
// if the key contains pk_live it's a live key
|
// if the key contains pk_live it's a live key
|
||||||
|
@ -32,7 +33,6 @@ type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
claim: StreamClaim,
|
claim: StreamClaim,
|
||||||
createComment: (string, string, string, ?string, ?string, ?string) => Promise<any>,
|
createComment: (string, string, string, ?string, ?string, ?string) => Promise<any>,
|
||||||
commentsDisabledBySettings: boolean,
|
|
||||||
channels: ?Array<ChannelClaim>,
|
channels: ?Array<ChannelClaim>,
|
||||||
onDoneReplying?: () => void,
|
onDoneReplying?: () => void,
|
||||||
onCancelReplying?: () => void,
|
onCancelReplying?: () => void,
|
||||||
|
@ -50,12 +50,13 @@ type Props = {
|
||||||
sendTip: ({}, (any) => void, (any) => void) => void,
|
sendTip: ({}, (any) => void, (any) => void) => void,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
|
doFetchCreatorSettings: (channelId: string) => void,
|
||||||
|
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||||
};
|
};
|
||||||
|
|
||||||
export function CommentCreate(props: Props) {
|
export function CommentCreate(props: Props) {
|
||||||
const {
|
const {
|
||||||
createComment,
|
createComment,
|
||||||
commentsDisabledBySettings,
|
|
||||||
claim,
|
claim,
|
||||||
channels,
|
channels,
|
||||||
onDoneReplying,
|
onDoneReplying,
|
||||||
|
@ -71,6 +72,8 @@ export function CommentCreate(props: Props) {
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
sendTip,
|
sendTip,
|
||||||
doToast,
|
doToast,
|
||||||
|
doFetchCreatorSettings,
|
||||||
|
settingsByChannelId,
|
||||||
} = props;
|
} = props;
|
||||||
const buttonRef: ElementRef<any> = React.useRef();
|
const buttonRef: ElementRef<any> = React.useRef();
|
||||||
const {
|
const {
|
||||||
|
@ -92,6 +95,8 @@ export function CommentCreate(props: Props) {
|
||||||
const [tipError, setTipError] = React.useState();
|
const [tipError, setTipError] = React.useState();
|
||||||
const disabled = isSubmitting || !activeChannelClaim || !commentValue.length;
|
const disabled = isSubmitting || !activeChannelClaim || !commentValue.length;
|
||||||
const [shouldDisableReviewButton, setShouldDisableReviewButton] = React.useState();
|
const [shouldDisableReviewButton, setShouldDisableReviewButton] = React.useState();
|
||||||
|
const channelId = getChannelIdFromClaim(claim);
|
||||||
|
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||||
|
|
||||||
function handleCommentChange(event) {
|
function handleCommentChange(event) {
|
||||||
let commentValue;
|
let commentValue;
|
||||||
|
@ -275,7 +280,13 @@ export function CommentCreate(props: Props) {
|
||||||
setAdvancedEditor(!advancedEditor);
|
setAdvancedEditor(!advancedEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commentsDisabledBySettings) {
|
React.useEffect(() => {
|
||||||
|
if (!channelSettings && channelId) {
|
||||||
|
doFetchCreatorSettings(channelId);
|
||||||
|
}
|
||||||
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
|
if (channelSettings && !channelSettings.comments_enabled) {
|
||||||
return <Empty padded text={__('This channel has disabled comments on their page.')} />;
|
return <Empty padded text={__('This channel has disabled comments on their page.')} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimIsMine, selectFetchingMyChannels, selectMyChannelClaims } from 'lbry-redux';
|
import {
|
||||||
|
makeSelectClaimForUri,
|
||||||
|
makeSelectClaimIsMine,
|
||||||
|
selectFetchingMyChannels,
|
||||||
|
selectMyChannelClaims,
|
||||||
|
} from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectTopLevelCommentsForUri,
|
makeSelectTopLevelCommentsForUri,
|
||||||
makeSelectTopLevelTotalPagesForUri,
|
makeSelectTopLevelTotalPagesForUri,
|
||||||
|
@ -7,12 +12,11 @@ import {
|
||||||
selectIsFetchingReacts,
|
selectIsFetchingReacts,
|
||||||
makeSelectTotalCommentsCountForUri,
|
makeSelectTotalCommentsCountForUri,
|
||||||
selectOthersReactsById,
|
selectOthersReactsById,
|
||||||
makeSelectCommentsDisabledForUri,
|
|
||||||
selectMyReactionsByCommentId,
|
selectMyReactionsByCommentId,
|
||||||
makeSelectCommentIdsForUri,
|
makeSelectCommentIdsForUri,
|
||||||
|
selectSettingsByChannelId,
|
||||||
} from 'redux/selectors/comments';
|
} from 'redux/selectors/comments';
|
||||||
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
||||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
||||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||||
import CommentsList from './view';
|
import CommentsList from './view';
|
||||||
|
|
||||||
|
@ -24,12 +28,12 @@ const select = (state, props) => {
|
||||||
topLevelComments: makeSelectTopLevelCommentsForUri(props.uri)(state),
|
topLevelComments: makeSelectTopLevelCommentsForUri(props.uri)(state),
|
||||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
||||||
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
||||||
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
isFetchingComments: selectIsFetchingComments(state),
|
isFetchingComments: selectIsFetchingComments(state),
|
||||||
isFetchingReacts: selectIsFetchingReacts(state),
|
isFetchingReacts: selectIsFetchingReacts(state),
|
||||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
|
||||||
commentsDisabledBySettings: makeSelectCommentsDisabledForUri(props.uri)(state),
|
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
|
settingsByChannelId: selectSettingsByChannelId(state),
|
||||||
myReactsByCommentId: selectMyReactionsByCommentId(state),
|
myReactsByCommentId: selectMyReactionsByCommentId(state),
|
||||||
othersReactsById: selectOthersReactsById(state),
|
othersReactsById: selectOthersReactsById(state),
|
||||||
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
|
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||||
import Empty from 'component/common/empty';
|
import Empty from 'component/common/empty';
|
||||||
import debounce from 'util/debounce';
|
import debounce from 'util/debounce';
|
||||||
import { useIsMobile } from 'effects/use-screensize';
|
import { useIsMobile } from 'effects/use-screensize';
|
||||||
|
import { getChannelIdFromClaim } from 'util/claim';
|
||||||
|
|
||||||
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
||||||
|
|
||||||
|
@ -29,12 +30,12 @@ type Props = {
|
||||||
allCommentIds: any,
|
allCommentIds: any,
|
||||||
topLevelComments: Array<Comment>,
|
topLevelComments: Array<Comment>,
|
||||||
topLevelTotalPages: number,
|
topLevelTotalPages: number,
|
||||||
commentsDisabledBySettings: boolean,
|
|
||||||
fetchTopLevelComments: (string, number, number, number) => void,
|
fetchTopLevelComments: (string, number, number, number) => void,
|
||||||
fetchComment: (string) => void,
|
fetchComment: (string) => void,
|
||||||
fetchReacts: (Array<string>) => Promise<any>,
|
fetchReacts: (Array<string>) => Promise<any>,
|
||||||
resetComments: (string) => void,
|
resetComments: (string) => void,
|
||||||
uri: string,
|
uri: string,
|
||||||
|
claim: ?Claim,
|
||||||
claimIsMine: boolean,
|
claimIsMine: boolean,
|
||||||
myChannels: ?Array<ChannelClaim>,
|
myChannels: ?Array<ChannelClaim>,
|
||||||
isFetchingComments: boolean,
|
isFetchingComments: boolean,
|
||||||
|
@ -45,6 +46,7 @@ type Props = {
|
||||||
myReactsByCommentId: ?{ [string]: Array<string> }, // "CommentId:MyChannelId" -> reaction array (note the ID concatenation)
|
myReactsByCommentId: ?{ [string]: Array<string> }, // "CommentId:MyChannelId" -> reaction array (note the ID concatenation)
|
||||||
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
|
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
|
||||||
activeChannelId: ?string,
|
activeChannelId: ?string,
|
||||||
|
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||||
};
|
};
|
||||||
|
|
||||||
function CommentList(props: Props) {
|
function CommentList(props: Props) {
|
||||||
|
@ -57,7 +59,7 @@ function CommentList(props: Props) {
|
||||||
uri,
|
uri,
|
||||||
topLevelComments,
|
topLevelComments,
|
||||||
topLevelTotalPages,
|
topLevelTotalPages,
|
||||||
commentsDisabledBySettings,
|
claim,
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
myChannels,
|
myChannels,
|
||||||
isFetchingComments,
|
isFetchingComments,
|
||||||
|
@ -68,6 +70,7 @@ function CommentList(props: Props) {
|
||||||
myReactsByCommentId,
|
myReactsByCommentId,
|
||||||
othersReactsById,
|
othersReactsById,
|
||||||
activeChannelId,
|
activeChannelId,
|
||||||
|
settingsByChannelId,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const commentRef = React.useRef();
|
const commentRef = React.useRef();
|
||||||
|
@ -78,6 +81,8 @@ function CommentList(props: Props) {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const [expandedComments, setExpandedComments] = React.useState(!isMobile);
|
const [expandedComments, setExpandedComments] = React.useState(!isMobile);
|
||||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||||
|
const channelId = getChannelIdFromClaim(claim);
|
||||||
|
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||||
|
|
||||||
// Display comments immediately if not fetching reactions
|
// Display comments immediately if not fetching reactions
|
||||||
// If not, wait to show comments until reactions are fetched
|
// If not, wait to show comments until reactions are fetched
|
||||||
|
@ -279,7 +284,7 @@ function CommentList(props: Props) {
|
||||||
<>
|
<>
|
||||||
<CommentCreate uri={uri} />
|
<CommentCreate uri={uri} />
|
||||||
|
|
||||||
{!commentsDisabledBySettings && !isFetchingComments && hasNoComments && (
|
{channelSettings && channelSettings.comments_enabled && !isFetchingComments && hasNoComments && (
|
||||||
<Empty padded text={__('That was pretty deep. What do you think?')} />
|
<Empty padded text={__('That was pretty deep. What do you think?')} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const select = (state) => ({
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
commentBlockWords: (channelClaim, words) => dispatch(doCommentBlockWords(channelClaim, words)),
|
commentBlockWords: (channelClaim, words) => dispatch(doCommentBlockWords(channelClaim, words)),
|
||||||
commentUnblockWords: (channelClaim, words) => dispatch(doCommentUnblockWords(channelClaim, words)),
|
commentUnblockWords: (channelClaim, words) => dispatch(doCommentUnblockWords(channelClaim, words)),
|
||||||
fetchCreatorSettings: (channelClaimIds) => dispatch(doFetchCreatorSettings(channelClaimIds)),
|
fetchCreatorSettings: (channelClaimId) => dispatch(doFetchCreatorSettings(channelClaimId)),
|
||||||
updateCreatorSettings: (channelClaim, settings) => dispatch(doUpdateCreatorSettings(channelClaim, settings)),
|
updateCreatorSettings: (channelClaim, settings) => dispatch(doUpdateCreatorSettings(channelClaim, settings)),
|
||||||
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
||||||
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim)),
|
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim)),
|
||||||
|
|
|
@ -30,7 +30,7 @@ type Props = {
|
||||||
commentModAddDelegate: (string, string, ChannelClaim) => void,
|
commentModAddDelegate: (string, string, ChannelClaim) => void,
|
||||||
commentModRemoveDelegate: (string, string, ChannelClaim) => void,
|
commentModRemoveDelegate: (string, string, ChannelClaim) => void,
|
||||||
commentModListDelegates: (ChannelClaim) => void,
|
commentModListDelegates: (ChannelClaim) => void,
|
||||||
fetchCreatorSettings: (Array<string>) => void,
|
fetchCreatorSettings: (channelId: string) => void,
|
||||||
updateCreatorSettings: (ChannelClaim, PerChannelSettings) => void,
|
updateCreatorSettings: (ChannelClaim, PerChannelSettings) => void,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
};
|
};
|
||||||
|
@ -61,7 +61,32 @@ export default function SettingsCreatorPage(props: Props) {
|
||||||
const [slowModeMinGap, setSlowModeMinGap] = React.useState(0);
|
const [slowModeMinGap, setSlowModeMinGap] = React.useState(0);
|
||||||
const [lastUpdated, setLastUpdated] = React.useState(1);
|
const [lastUpdated, setLastUpdated] = React.useState(1);
|
||||||
|
|
||||||
function settingsToStates(settings: PerChannelSettings) {
|
/**
|
||||||
|
* Updates corresponding GUI states with the given PerChannelSettings values.
|
||||||
|
*
|
||||||
|
* @param settings
|
||||||
|
* @param fullSync If true, update all states and consider 'undefined' settings as "cleared/false";
|
||||||
|
* if false, only update defined settings.
|
||||||
|
*/
|
||||||
|
function settingsToStates(settings: PerChannelSettings, fullSync: boolean) {
|
||||||
|
const doSetMutedWordTags = (words: Array<string>) => {
|
||||||
|
const tagArray = Array.from(new Set(words));
|
||||||
|
setMutedWordTags(
|
||||||
|
tagArray
|
||||||
|
.filter((t) => t !== '')
|
||||||
|
.map((x) => {
|
||||||
|
return { name: x };
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (fullSync) {
|
||||||
|
setCommentsEnabled(settings.comments_enabled || false);
|
||||||
|
setMinTipAmountComment(settings.min_tip_amount_comment || 0);
|
||||||
|
setMinTipAmountSuperChat(settings.min_tip_amount_super_chat || 0);
|
||||||
|
setSlowModeMinGap(settings.slow_mode_min_gap || 0);
|
||||||
|
doSetMutedWordTags(settings.words || []);
|
||||||
|
} else {
|
||||||
if (settings.comments_enabled !== undefined) {
|
if (settings.comments_enabled !== undefined) {
|
||||||
setCommentsEnabled(settings.comments_enabled);
|
setCommentsEnabled(settings.comments_enabled);
|
||||||
}
|
}
|
||||||
|
@ -75,19 +100,13 @@ export default function SettingsCreatorPage(props: Props) {
|
||||||
setSlowModeMinGap(settings.slow_mode_min_gap);
|
setSlowModeMinGap(settings.slow_mode_min_gap);
|
||||||
}
|
}
|
||||||
if (settings.words) {
|
if (settings.words) {
|
||||||
const tagArray = Array.from(new Set(settings.words));
|
doSetMutedWordTags(settings.words);
|
||||||
setMutedWordTags(
|
}
|
||||||
tagArray
|
|
||||||
.filter((t) => t !== '')
|
|
||||||
.map((x) => {
|
|
||||||
return { name: x };
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSettings(newSettings: PerChannelSettings) {
|
function setSettings(newSettings: PerChannelSettings) {
|
||||||
settingsToStates(newSettings);
|
settingsToStates(newSettings, false);
|
||||||
updateCreatorSettings(activeChannelClaim, newSettings);
|
updateCreatorSettings(activeChannelClaim, newSettings);
|
||||||
setLastUpdated(Date.now());
|
setLastUpdated(Date.now());
|
||||||
}
|
}
|
||||||
|
@ -213,15 +232,15 @@ export default function SettingsCreatorPage(props: Props) {
|
||||||
|
|
||||||
if (activeChannelClaim && settingsByChannelId && settingsByChannelId[activeChannelClaim.claim_id]) {
|
if (activeChannelClaim && settingsByChannelId && settingsByChannelId[activeChannelClaim.claim_id]) {
|
||||||
const channelSettings = settingsByChannelId[activeChannelClaim.claim_id];
|
const channelSettings = settingsByChannelId[activeChannelClaim.claim_id];
|
||||||
settingsToStates(channelSettings);
|
settingsToStates(channelSettings, true);
|
||||||
}
|
}
|
||||||
}, [activeChannelClaim, settingsByChannelId, lastUpdated]);
|
}, [activeChannelClaim, settingsByChannelId, lastUpdated]);
|
||||||
|
|
||||||
// Re-sync list, mainly to correct any invalid settings.
|
// Re-sync list on first idle time; mainly to correct any invalid settings.
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (lastUpdated && activeChannelClaim) {
|
if (lastUpdated && activeChannelClaim) {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
fetchCreatorSettings([activeChannelClaim.claim_id]);
|
fetchCreatorSettings(activeChannelClaim.claim_id);
|
||||||
}, DEBOUNCE_REFRESH_MS);
|
}, DEBOUNCE_REFRESH_MS);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ export function doCommentList(
|
||||||
totalFilteredItems: total_filtered_items,
|
totalFilteredItems: total_filtered_items,
|
||||||
totalPages: total_pages,
|
totalPages: total_pages,
|
||||||
claimId: claimId,
|
claimId: claimId,
|
||||||
authorClaimId: authorChannelClaim ? authorChannelClaim.claim_id : undefined,
|
commenterClaimId: authorChannelClaim ? authorChannelClaim.claim_id : undefined,
|
||||||
uri: uri,
|
uri: uri,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1357,7 +1357,7 @@ export function doFetchCommentModAmIList(channelClaim: ChannelClaim) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
|
export const doFetchCreatorSettings = (channelId: string) => {
|
||||||
return async (dispatch: Dispatch, getState: GetState) => {
|
return async (dispatch: Dispatch, getState: GetState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
|
@ -1366,84 +1366,49 @@ export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
|
||||||
type: ACTIONS.COMMENT_FETCH_SETTINGS_STARTED,
|
type: ACTIONS.COMMENT_FETCH_SETTINGS_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
let channelSignatures = [];
|
let signedName;
|
||||||
|
|
||||||
if (myChannels) {
|
if (myChannels) {
|
||||||
for (const channelClaim of myChannels) {
|
const index = myChannels.findIndex((myChannel) => myChannel.claim_id === channelId);
|
||||||
if (channelClaimIds.length !== 0 && !channelClaimIds.includes(channelClaim.claim_id)) {
|
if (index > -1) {
|
||||||
continue;
|
signedName = await channelSignName(channelId, myChannels[index].name);
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const channelSignature = await Lbry.channel_sign({
|
|
||||||
channel_id: channelClaim.claim_id,
|
|
||||||
hexdata: toHex(channelClaim.name),
|
|
||||||
});
|
|
||||||
|
|
||||||
channelSignatures.push({ ...channelSignature, claim_id: channelClaim.claim_id, name: channelClaim.name });
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(
|
const cmd = signedName ? Comments.setting_list : Comments.setting_get;
|
||||||
channelSignatures.map((signatureData) =>
|
|
||||||
Comments.setting_list({
|
return cmd({
|
||||||
channel_name: signatureData.name,
|
channel_id: channelId,
|
||||||
channel_id: signatureData.claim_id,
|
channel_name: (signedName && signedName.name) || undefined,
|
||||||
signature: signatureData.signature,
|
signature: (signedName && signedName.signature) || undefined,
|
||||||
signing_ts: signatureData.signing_ts,
|
signing_ts: (signedName && signedName.signing_ts) || undefined,
|
||||||
})
|
})
|
||||||
)
|
.then((response: SettingsResponse) => {
|
||||||
)
|
|
||||||
.then((settings) => {
|
|
||||||
const settingsByChannelId = {};
|
|
||||||
|
|
||||||
for (let i = 0; i < channelSignatures.length; ++i) {
|
|
||||||
const channelId = channelSignatures[i].claim_id;
|
|
||||||
settingsByChannelId[channelId] = settings[i];
|
|
||||||
|
|
||||||
if (settings[i].words) {
|
|
||||||
settingsByChannelId[channelId].words = settings[i].words.split(',');
|
|
||||||
}
|
|
||||||
|
|
||||||
delete settingsByChannelId[channelId].channel_name;
|
|
||||||
delete settingsByChannelId[channelId].channel_id;
|
|
||||||
delete settingsByChannelId[channelId].signature;
|
|
||||||
delete settingsByChannelId[channelId].signing_ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED,
|
type: ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED,
|
||||||
data: settingsByChannelId,
|
data: {
|
||||||
|
channelId: channelId,
|
||||||
|
settings: response,
|
||||||
|
partialUpdate: !signedName,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// TODO: Use error codes when available.
|
|
||||||
// TODO: The "validation is disallowed" thing ideally should just be a
|
|
||||||
// success case that returns a null setting, instead of an error.
|
|
||||||
// As we are using 'Promise.all', if one channel fails, everyone
|
|
||||||
// fails. This forces us to remove the batch functionality of this
|
|
||||||
// function. However, since this "validation is disallowed" thing
|
|
||||||
// is potentially a temporary one to handle spammers, I retained
|
|
||||||
// the batch functionality for now.
|
|
||||||
if (err.message === 'validation is disallowed for non controlling channels') {
|
if (err.message === 'validation is disallowed for non controlling channels') {
|
||||||
const settingsByChannelId = {};
|
|
||||||
for (let i = 0; i < channelSignatures.length; ++i) {
|
|
||||||
const channelId = channelSignatures[i].claim_id;
|
|
||||||
// 'undefined' means "fetching or have not fetched";
|
|
||||||
// 'null' means "feature not available for this channel";
|
|
||||||
settingsByChannelId[channelId] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED,
|
type: ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED,
|
||||||
data: settingsByChannelId,
|
data: {
|
||||||
|
channelId: channelId,
|
||||||
|
settings: null,
|
||||||
|
partialUpdate: !signedName,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return;
|
} else {
|
||||||
}
|
devToast(dispatch, `Creator: ${err}`);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COMMENT_FETCH_SETTINGS_FAILED,
|
type: ACTIONS.COMMENT_FETCH_SETTINGS_FAILED,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1454,7 +1419,7 @@ export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
|
||||||
*
|
*
|
||||||
* @param channelClaim
|
* @param channelClaim
|
||||||
* @param settings
|
* @param settings
|
||||||
* @returns {function(Dispatch, GetState): Promise<R>|Promise<unknown>|*}
|
* @returns {function(Dispatch, GetState): any}
|
||||||
*/
|
*/
|
||||||
export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: PerChannelSettings) => {
|
export const doUpdateCreatorSettings = (channelClaim: ChannelClaim, settings: PerChannelSettings) => {
|
||||||
return async (dispatch: Dispatch, getState: GetState) => {
|
return async (dispatch: Dispatch, getState: GetState) => {
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { handleActions } from 'util/redux-utils';
|
||||||
import { BLOCK_LEVEL } from 'constants/comment';
|
import { BLOCK_LEVEL } from 'constants/comment';
|
||||||
import { isURIEqual } from 'lbry-redux';
|
import { isURIEqual } from 'lbry-redux';
|
||||||
|
|
||||||
|
const BTC_SATOSHIS = 100000000;
|
||||||
|
|
||||||
const defaultState: CommentsState = {
|
const defaultState: CommentsState = {
|
||||||
commentById: {}, // commentId -> Comment
|
commentById: {}, // commentId -> Comment
|
||||||
byId: {}, // ClaimID -> list of fetched comment IDs.
|
byId: {}, // ClaimID -> list of fetched comment IDs.
|
||||||
|
@ -41,7 +43,6 @@ const defaultState: CommentsState = {
|
||||||
blockingByUri: {},
|
blockingByUri: {},
|
||||||
unBlockingByUri: {},
|
unBlockingByUri: {},
|
||||||
togglingForDelegatorMap: {},
|
togglingForDelegatorMap: {},
|
||||||
commentsDisabledChannelIds: [],
|
|
||||||
settingsByChannelId: {}, // ChannelId -> PerChannelSettings
|
settingsByChannelId: {}, // ChannelId -> PerChannelSettings
|
||||||
fetchingSettings: false,
|
fetchingSettings: false,
|
||||||
fetchingBlockedWords: false,
|
fetchingBlockedWords: false,
|
||||||
|
@ -251,32 +252,8 @@ export default handleActions(
|
||||||
claimId,
|
claimId,
|
||||||
uri,
|
uri,
|
||||||
disabled,
|
disabled,
|
||||||
authorClaimId,
|
commenterClaimId,
|
||||||
} = action.data;
|
} = action.data;
|
||||||
const commentsDisabledChannelIds = [...state.commentsDisabledChannelIds];
|
|
||||||
|
|
||||||
if (disabled) {
|
|
||||||
if (!commentsDisabledChannelIds.includes(authorClaimId)) {
|
|
||||||
commentsDisabledChannelIds.push(authorClaimId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isLoadingByParentId = Object.assign({}, state.isLoadingByParentId);
|
|
||||||
if (parentId) {
|
|
||||||
isLoadingByParentId[parentId] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
commentsDisabledChannelIds,
|
|
||||||
isLoading: false,
|
|
||||||
isLoadingByParentId,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
const index = commentsDisabledChannelIds.indexOf(authorClaimId);
|
|
||||||
if (index > -1) {
|
|
||||||
commentsDisabledChannelIds.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const commentById = Object.assign({}, state.commentById);
|
const commentById = Object.assign({}, state.commentById);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
@ -289,14 +266,24 @@ export default handleActions(
|
||||||
const pinnedCommentsById = Object.assign({}, state.pinnedCommentsById);
|
const pinnedCommentsById = Object.assign({}, state.pinnedCommentsById);
|
||||||
const totalRepliesByParentId = Object.assign({}, state.totalRepliesByParentId);
|
const totalRepliesByParentId = Object.assign({}, state.totalRepliesByParentId);
|
||||||
const isLoadingByParentId = Object.assign({}, state.isLoadingByParentId);
|
const isLoadingByParentId = Object.assign({}, state.isLoadingByParentId);
|
||||||
|
const settingsByChannelId = Object.assign({}, state.settingsByChannelId);
|
||||||
|
|
||||||
if (!parentId) {
|
settingsByChannelId[commenterClaimId] = {
|
||||||
|
...(settingsByChannelId[commenterClaimId] || {}),
|
||||||
|
comments_enabled: !disabled,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (parentId) {
|
||||||
|
isLoadingByParentId[parentId] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!disabled) {
|
||||||
|
if (parentId) {
|
||||||
|
totalRepliesByParentId[parentId] = totalFilteredItems;
|
||||||
|
} else {
|
||||||
totalCommentsById[claimId] = totalItems;
|
totalCommentsById[claimId] = totalItems;
|
||||||
topLevelTotalCommentsById[claimId] = totalFilteredItems;
|
topLevelTotalCommentsById[claimId] = totalFilteredItems;
|
||||||
topLevelTotalPagesById[claimId] = totalPages;
|
topLevelTotalPagesById[claimId] = totalPages;
|
||||||
} else {
|
|
||||||
totalRepliesByParentId[parentId] = totalFilteredItems;
|
|
||||||
isLoadingByParentId[parentId] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const commonUpdateAction = (comment, commentById, commentIds, index) => {
|
const commonUpdateAction = (comment, commentById, commentIds, index) => {
|
||||||
|
@ -334,6 +321,7 @@ export default handleActions(
|
||||||
byId[claimId] ? byId[claimId].push(...commentIds) : (byId[claimId] = commentIds);
|
byId[claimId] ? byId[claimId].push(...commentIds) : (byId[claimId] = commentIds);
|
||||||
commentsByUri[uri] = claimId;
|
commentsByUri[uri] = claimId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
@ -347,9 +335,9 @@ export default handleActions(
|
||||||
byId,
|
byId,
|
||||||
commentById,
|
commentById,
|
||||||
commentsByUri,
|
commentsByUri,
|
||||||
commentsDisabledChannelIds,
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isLoadingByParentId,
|
isLoadingByParentId,
|
||||||
|
settingsByChannelId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1018,23 +1006,27 @@ export default handleActions(
|
||||||
fetchingSettings: false,
|
fetchingSettings: false,
|
||||||
}),
|
}),
|
||||||
[ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED]: (state: CommentsState, action: any) => {
|
[ACTIONS.COMMENT_FETCH_SETTINGS_COMPLETED]: (state: CommentsState, action: any) => {
|
||||||
// TODO: This is incorrect, as it could make 'settingsByChannelId' store
|
const { channelId, settings, partialUpdate } = action.data;
|
||||||
// only 1 channel with other channel's data purged. It works for now
|
const settingsByChannelId = Object.assign({}, state.settingsByChannelId);
|
||||||
// because the GUI only shows 1 channel's setting at a time, and *always*
|
|
||||||
// re-fetches to get latest data before displaying. Either rename this to
|
|
||||||
// 'activeChannelCreatorSettings', or append the new data properly.
|
|
||||||
const settingsByChannelId = Object.assign({}, action.data);
|
|
||||||
const BTC_SATOSHIS = 100000000;
|
|
||||||
|
|
||||||
const channelIds = Object.keys(settingsByChannelId);
|
if (partialUpdate) {
|
||||||
channelIds.forEach((ci) => {
|
settingsByChannelId[channelId] = {
|
||||||
if (settingsByChannelId[ci].min_tip_amount_comment) {
|
// The existing may contain additional Creator Settings (e.g. 'words')
|
||||||
settingsByChannelId[ci].min_tip_amount_comment /= BTC_SATOSHIS;
|
...(settingsByChannelId[channelId] || {}),
|
||||||
|
// Spread new settings.
|
||||||
|
...settings,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
settingsByChannelId[channelId] = settings;
|
||||||
|
if (settings.words) {
|
||||||
|
settingsByChannelId[channelId].words = settings.words.split(',');
|
||||||
}
|
}
|
||||||
if (settingsByChannelId[ci].min_tip_amount_super_chat) {
|
|
||||||
settingsByChannelId[ci].min_tip_amount_super_chat /= BTC_SATOSHIS;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
// Both partial and full update will always include these,
|
||||||
|
// so safe to always re-compute without accidentally double-converting.
|
||||||
|
settingsByChannelId[channelId].min_tip_amount_comment /= BTC_SATOSHIS;
|
||||||
|
settingsByChannelId[channelId].min_tip_amount_super_chat /= BTC_SATOSHIS;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
|
||||||
import { selectMutedChannels } from 'redux/selectors/blocked';
|
import { selectMutedChannels } from 'redux/selectors/blocked';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
|
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
|
||||||
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims, makeSelectClaimForUri } from 'lbry-redux';
|
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
|
||||||
|
|
||||||
const selectState = (state) => state.comments || {};
|
const selectState = (state) => state.comments || {};
|
||||||
|
|
||||||
|
@ -12,10 +12,6 @@ export const selectIsFetchingComments = createSelector(selectState, (state) => s
|
||||||
export const selectIsFetchingCommentsByParentId = createSelector(selectState, (state) => state.isLoadingByParentId);
|
export const selectIsFetchingCommentsByParentId = createSelector(selectState, (state) => state.isLoadingByParentId);
|
||||||
export const selectIsPostingComment = createSelector(selectState, (state) => state.isCommenting);
|
export const selectIsPostingComment = createSelector(selectState, (state) => state.isCommenting);
|
||||||
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
|
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
|
||||||
export const selectCommentsDisabledChannelIds = createSelector(
|
|
||||||
selectState,
|
|
||||||
(state) => state.commentsDisabledChannelIds
|
|
||||||
);
|
|
||||||
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
|
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
|
||||||
export const selectPinnedCommentsById = createSelector(selectState, (state) => state.pinnedCommentsById);
|
export const selectPinnedCommentsById = createSelector(selectState, (state) => state.pinnedCommentsById);
|
||||||
|
|
||||||
|
@ -426,15 +422,3 @@ export const makeSelectSuperChatTotalAmountForUri = (uri: string) =>
|
||||||
|
|
||||||
return superChatData.totalAmount;
|
return superChatData.totalAmount;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectCommentsDisabledForUri = (uri: string) =>
|
|
||||||
createSelector(selectCommentsDisabledChannelIds, makeSelectClaimForUri(uri), (commentsDisabledChannelIds, claim) => {
|
|
||||||
const channelClaim = !claim
|
|
||||||
? null
|
|
||||||
: claim.value_type === 'channel'
|
|
||||||
? claim
|
|
||||||
: claim.signing_channel && claim.is_channel_signature_valid
|
|
||||||
? claim.signing_channel
|
|
||||||
: null;
|
|
||||||
return channelClaim && channelClaim.claim_id && commentsDisabledChannelIds.includes(channelClaim.claim_id);
|
|
||||||
});
|
|
||||||
|
|
11
ui/util/claim.js
Normal file
11
ui/util/claim.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
export function getChannelIdFromClaim(claim: ?Claim) {
|
||||||
|
if (claim) {
|
||||||
|
if (claim.value_type === 'channel') {
|
||||||
|
return claim.claim_id;
|
||||||
|
} else if (claim.signing_channel) {
|
||||||
|
return claim.signing_channel.claim_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue