From a7f3d7a6fa7a25db951e4d588d83a0df32d44082 Mon Sep 17 00:00:00 2001 From: miko Date: Fri, 15 Nov 2024 19:52:40 +0200 Subject: [PATCH] Add `c:disable-comments` control tag --- ui/component/channelEdit/view.jsx | 2 ++ ui/component/tagsSearch/view.jsx | 8 ++++++-- ui/constants/tags.js | 2 ++ .../internal/streamClaimPage/index.js | 8 +++++++- .../streamClaimPage/internal/markdownPost/index.js | 13 +++++++++++-- .../streamClaimPage/internal/markdownPost/view.jsx | 6 +++--- .../streamClaimPage/internal/videoPlayers/index.js | 12 ++++++++++-- .../streamClaimPage/internal/videoPlayers/view.jsx | 6 +++--- .../internal/streamClaimPage/view.jsx | 6 +++--- ui/redux/selectors/livestream.js | 9 +++++++-- 10 files changed, 54 insertions(+), 18 deletions(-) diff --git a/ui/component/channelEdit/view.jsx b/ui/component/channelEdit/view.jsx index 11d9a6c74b..0dfc072445 100644 --- a/ui/component/channelEdit/view.jsx +++ b/ui/component/channelEdit/view.jsx @@ -1,6 +1,7 @@ // @flow import * as MODALS from 'constants/modal_types'; import * as ICONS from 'constants/icons'; +import * as TAGS from 'constants/tags'; import React from 'react'; import classnames from 'classnames'; import { FormField } from 'component/common/form'; @@ -482,6 +483,7 @@ function ChannelForm(props: Props) { disableAutoFocus limitSelect={MAX_TAG_SELECT} tagsPassedIn={params.tags || []} + excludedControlTags={[TAGS.DISABLE_COMMENTS_TAG]} label={__('Selected Tags')} onRemove={(clickedTag) => { const newTags = params.tags.slice().filter((tag) => tag.name !== clickedTag.name); diff --git a/ui/component/tagsSearch/view.jsx b/ui/component/tagsSearch/view.jsx index a9062b8ed9..ec2946934f 100644 --- a/ui/component/tagsSearch/view.jsx +++ b/ui/component/tagsSearch/view.jsx @@ -44,6 +44,7 @@ type Props = { user: User, disableControlTags?: boolean, help?: string, + excludedControlTags?: Array, }; const UNALLOWED_TAGS = ['lbry-first']; @@ -78,6 +79,7 @@ export default function TagsSearch(props: Props) { limitShow = 5, disableControlTags, help, + excludedControlTags = [], } = props; const [newTag, setNewTag] = useState(''); const doesTagMatch = (name) => { @@ -112,8 +114,10 @@ export default function TagsSearch(props: Props) { }); } + const FILTERED_CONTROL_TAGS = CONTROL_TAGS.filter((tag) => !excludedControlTags.includes(tag)); + const controlTagLabels = {}; - CONTROL_TAGS.map((t) => { + FILTERED_CONTROL_TAGS.map((t) => { let label; if (t === DISABLE_SUPPORT_TAG) { label = __('Disable Tipping and Boosting'); @@ -283,7 +287,7 @@ export default function TagsSearch(props: Props) { onSelect && ( // onSelect ensures this does not appear on TagFollow - {CONTROL_TAGS.map((t) => ( + {FILTERED_CONTROL_TAGS.map((t) => ( { const claimId = claim.claim_id; + const commentSettingDisabled = selectCommentsDisabledSettingForChannelId(state, channelId); + return { commentsListTitle: selectCommentsListTitleForUri(state, uri), costInfo: selectCostInfoForUri(state, uri), @@ -37,7 +42,8 @@ const select = (state, props) => { isMature: selectClaimIsNsfwForUri(state, uri), linkedCommentId: urlParams.get(LINKED_COMMENT_QUERY_PARAM), renderMode: makeSelectFileRenderModeForUri(uri)(state), - commentSettingDisabled: selectCommentsDisabledSettingForChannelId(state, channelId), + commentsDisabled: + commentSettingDisabled || makeSelectTagInClaimOrChannelForUri(uri, TAGS.DISABLE_COMMENTS_TAG)(state), threadCommentId: urlParams.get(THREAD_COMMENT_QUERY_PARAM), isProtectedContent: Boolean(selectProtectedContentTagForUri(state, uri)), contentUnlocked: claimId && selectNoRestrictionOrUserIsMemberForContentClaimId(state, claimId), diff --git a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/index.js b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/index.js index 0badd416ac..2705281616 100644 --- a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/index.js +++ b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/index.js @@ -2,8 +2,14 @@ import { connect } from 'react-redux'; import { LINKED_COMMENT_QUERY_PARAM, THREAD_COMMENT_QUERY_PARAM } from 'constants/comment'; +import * as TAGS from 'constants/tags'; + import { selectCommentsDisabledSettingForChannelId } from 'redux/selectors/comments'; -import { selectClaimIsNsfwForUri, selectClaimForUri } from 'redux/selectors/claims'; +import { + selectClaimIsNsfwForUri, + selectClaimForUri, + makeSelectTagInClaimOrChannelForUri, +} from 'redux/selectors/claims'; import { selectNoRestrictionOrUserIsMemberForContentClaimId } from 'redux/selectors/memberships'; import { getChannelIdFromClaim } from 'util/claim'; @@ -18,12 +24,15 @@ const select = (state, props) => { const claimId = claim.claim_id; + const commentSettingDisabled = selectCommentsDisabledSettingForChannelId(state, getChannelIdFromClaim(claim)); + return { isMature: selectClaimIsNsfwForUri(state, uri), linkedCommentId: urlParams.get(LINKED_COMMENT_QUERY_PARAM), threadCommentId: urlParams.get(THREAD_COMMENT_QUERY_PARAM), contentUnlocked: claimId && selectNoRestrictionOrUserIsMemberForContentClaimId(state, claimId), - commentSettingDisabled: selectCommentsDisabledSettingForChannelId(state, getChannelIdFromClaim(claim)), + commentsDisabled: + commentSettingDisabled || makeSelectTagInClaimOrChannelForUri(uri, TAGS.DISABLE_COMMENTS_TAG)(state), }; }; diff --git a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/view.jsx b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/view.jsx index 700a265152..0f90f8bb7b 100644 --- a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/view.jsx +++ b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/markdownPost/view.jsx @@ -14,7 +14,7 @@ type Props = { isMature: boolean, linkedCommentId?: string, threadCommentId?: string, - commentSettingDisabled: ?boolean, + commentsDisabled: ?boolean, contentUnlocked: boolean, }; @@ -26,7 +26,7 @@ export default function MarkdownPostPage(props: Props) { isMature, linkedCommentId, threadCommentId, - commentSettingDisabled, + commentsDisabled, contentUnlocked, } = props; @@ -47,7 +47,7 @@ export default function MarkdownPostPage(props: Props) {
- {commentSettingDisabled ? ( + {commentsDisabled ? ( ) : contentUnlocked ? ( diff --git a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/index.js b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/index.js index 721b3815c9..f7f5a5c4a6 100644 --- a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/index.js +++ b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/index.js @@ -2,11 +2,16 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import * as SETTINGS from 'constants/settings'; +import * as TAGS from 'constants/tags'; import { getChannelIdFromClaim } from 'util/claim'; import { LINKED_COMMENT_QUERY_PARAM, THREAD_COMMENT_QUERY_PARAM } from 'constants/comment'; -import { selectClaimIsNsfwForUri, selectClaimForUri } from 'redux/selectors/claims'; +import { + selectClaimIsNsfwForUri, + selectClaimForUri, + makeSelectTagInClaimOrChannelForUri, +} from 'redux/selectors/claims'; import { makeSelectFileInfoForUri } from 'redux/selectors/file_info'; import { selectClientSetting } from 'redux/selectors/settings'; import { @@ -32,6 +37,8 @@ const select = (state, props) => { const claimId = claim.claim_id; + const commentSettingDisabled = selectCommentsDisabledSettingForChannelId(state, channelId); + return { commentsListTitle: selectCommentsListTitleForUri(state, uri), fileInfo: makeSelectFileInfoForUri(uri)(state), @@ -41,7 +48,8 @@ const select = (state, props) => { threadCommentId: urlParams.get(THREAD_COMMENT_QUERY_PARAM), playingCollectionId, position: selectContentPositionForUri(state, uri), - commentSettingDisabled: selectCommentsDisabledSettingForChannelId(state, channelId), + commentsDisabled: + commentSettingDisabled || makeSelectTagInClaimOrChannelForUri(uri, TAGS.DISABLE_COMMENTS_TAG)(state), videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE), contentUnlocked: claimId && selectNoRestrictionOrUserIsMemberForContentClaimId(state, claimId), isAutoplayCountdownForUri: selectIsAutoplayCountdownForUri(state, uri), diff --git a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/view.jsx b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/view.jsx index 2d67a1274b..38c32eb863 100644 --- a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/view.jsx +++ b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/internal/videoPlayers/view.jsx @@ -34,7 +34,7 @@ type Props = { location: { search: string }, playingCollectionId: ?string, position: number, - commentSettingDisabled: ?boolean, + commentsDisabled: ?boolean, videoTheaterMode: boolean, contentUnlocked: boolean, isAutoplayCountdownForUri: ?boolean, @@ -52,7 +52,7 @@ export default function VideoPlayersPage(props: Props) { linkedCommentId, threadCommentId, videoTheaterMode, - commentSettingDisabled, + commentsDisabled, audioVideoDuration, commentsListTitle, isUriPlaying, @@ -139,7 +139,7 @@ export default function VideoPlayersPage(props: Props) { {contentUnlocked && - (commentSettingDisabled ? ( + (commentsDisabled ? ( ) : isMobile && !isLandscapeRotated ? ( diff --git a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/view.jsx b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/view.jsx index fd7a69ae93..5881508c95 100644 --- a/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/view.jsx +++ b/ui/page/claim/internal/claimPageComponent/internal/streamClaimPage/view.jsx @@ -30,7 +30,7 @@ type Props = { isMature: boolean, linkedCommentId?: string, renderMode: string, - commentSettingDisabled: ?boolean, + commentsDisabled: ?boolean, threadCommentId?: string, isProtectedContent?: boolean, contentUnlocked: boolean, @@ -51,7 +51,7 @@ const StreamClaimPage = (props: Props) => { isMature, linkedCommentId, renderMode, - commentSettingDisabled, + commentsDisabled, threadCommentId, isProtectedContent, contentUnlocked, @@ -190,7 +190,7 @@ const StreamClaimPage = (props: Props) => {
- {commentSettingDisabled ? ( + {commentsDisabled ? ( ) : isMobile && !isLandscapeRotated ? ( diff --git a/ui/redux/selectors/livestream.js b/ui/redux/selectors/livestream.js index ebe83d10d9..c89374fc67 100644 --- a/ui/redux/selectors/livestream.js +++ b/ui/redux/selectors/livestream.js @@ -5,6 +5,8 @@ import { createSelector } from 'reselect'; import { createCachedSelector } from 're-reselect'; import { LIVESTREAM_STARTS_SOON_BUFFER, LIVESTREAM_STARTED_RECENTLY_BUFFER } from 'constants/livestream'; +import * as TAGS from 'constants/tags'; + import { selectMyClaims, selectPendingClaims, @@ -14,6 +16,7 @@ import { selectClaimReleaseInFutureForUri, selectClaimReleaseInPastForUri, selectClaimIdForUri, + makeSelectTagInClaimOrChannelForUri, } from 'redux/selectors/claims'; import { selectCommentsDisabledSettingForChannelId } from 'redux/selectors/comments'; @@ -306,6 +309,8 @@ export const selectChatCommentsDisabledForUri = (state: State, uri: string) => { const channelId = selectChannelClaimIdForUri(state, uri); if (!channelId) return channelId; - const commentsDisabled = selectCommentsDisabledSettingForChannelId(state, channelId); - return commentsDisabled; + const commentSettingDisabled = selectCommentsDisabledSettingForChannelId(state, channelId); + const commentsDisabled = makeSelectTagInClaimOrChannelForUri(uri, TAGS.DISABLE_COMMENTS_TAG)(state); + + return commentSettingDisabled || commentsDisabled; };