From f70e63195339b712a905ef279a5fe5d1d0ded29c Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 23 Feb 2022 14:29:14 +0800 Subject: [PATCH] Add "min channel age" setting --- flow-typed/Comment.js | 2 ++ static/app-strings.json | 2 ++ ui/page/settingsCreator/index.js | 2 ++ ui/page/settingsCreator/view.jsx | 47 ++++++++++++++++++++++++++++++++ ui/scss/component/section.scss | 3 +- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/flow-typed/Comment.js b/flow-typed/Comment.js index 05362f49c..b88277968 100644 --- a/flow-typed/Comment.js +++ b/flow-typed/Comment.js @@ -37,6 +37,7 @@ declare type PerChannelSettings = { min_tip_amount_comment?: number, min_tip_amount_super_chat?: number, slow_mode_min_gap?: number, + time_since_first_comment?: number, }; // todo: relate individual comments to their commentId @@ -318,6 +319,7 @@ declare type UpdateSettingsParams = { min_tip_amount_comment?: number, min_tip_amount_super_chat?: number, slow_mode_min_gap?: number, + time_since_first_comment?: number, }; declare type BlockWordParams = { diff --git a/static/app-strings.json b/static/app-strings.json index 2cab060bc..774583209 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2197,6 +2197,8 @@ "When do you want to go live?": "When do you want to go live?", "Anytime": "Anytime", "Scheduled Time": "Scheduled Time", + "Minimum channel age for comments": "Minimum channel age for comments", + "Channels with a lifespan lower than the specified duration will not be able to comment on your content.": "Channels with a lifespan lower than the specified duration will not be able to comment on your content.", "Set minimum channel age": "Set minimum channel age", "Note that the restriction can only be applied to channels created after Feb 8th, 2022.": "Note that the restriction can only be applied to channels created after Feb 8th, 2022.", "No limit": "No limit", diff --git a/ui/page/settingsCreator/index.js b/ui/page/settingsCreator/index.js index 0a5813069..09727fb4b 100644 --- a/ui/page/settingsCreator/index.js +++ b/ui/page/settingsCreator/index.js @@ -1,5 +1,6 @@ import { connect } from 'react-redux'; import SettingsCreatorPage from './view'; +import { doOpenModal } from 'redux/actions/app'; import { doCommentBlockWords, doCommentUnblockWords, @@ -35,6 +36,7 @@ const perform = (dispatch) => ({ commentModRemoveDelegate: (modChanId, modChanName, creatorChannelClaim) => dispatch(doCommentModRemoveDelegate(modChanId, modChanName, creatorChannelClaim)), commentModListDelegates: (creatorChannelClaim) => dispatch(doCommentModListDelegates(creatorChannelClaim)), + doOpenModal: (modal, props) => dispatch(doOpenModal(modal, props)), }); export default connect(select, perform)(SettingsCreatorPage); diff --git a/ui/page/settingsCreator/view.jsx b/ui/page/settingsCreator/view.jsx index b32da3d52..b5e34f802 100644 --- a/ui/page/settingsCreator/view.jsx +++ b/ui/page/settingsCreator/view.jsx @@ -1,5 +1,9 @@ // @flow import * as React from 'react'; +import humanizeDuration from 'humanize-duration'; +import * as ICONS from 'constants/icons'; +import * as MODALS from 'constants/modal_types'; +import Button from 'component/button'; import Card from 'component/common/card'; import TagsSearch from 'component/tagsSearch'; import Page from 'component/page'; @@ -36,6 +40,7 @@ type Props = { fetchCreatorSettings: (channelId: string) => void, updateCreatorSettings: (ChannelClaim, PerChannelSettings) => void, doToast: ({ message: string }) => void, + doOpenModal: (id: string, {}) => void, }; export default function SettingsCreatorPage(props: Props) { @@ -50,6 +55,7 @@ export default function SettingsCreatorPage(props: Props) { commentModListDelegates, fetchCreatorSettings, updateCreatorSettings, + doOpenModal, } = props; const [commentsEnabled, setCommentsEnabled] = React.useState(true); @@ -58,6 +64,7 @@ export default function SettingsCreatorPage(props: Props) { const [minTip, setMinTip] = React.useState(0); const [minSuper, setMinSuper] = React.useState(0); const [slowModeMin, setSlowModeMin] = React.useState(0); + const [minChannelAgeMinutes, setMinChannelAgeMinutes] = React.useState(0); const [lastUpdated, setLastUpdated] = React.useState(1); const pushSlowModeMinDebounced = React.useMemo(() => debounce(pushSlowModeMin, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps @@ -91,6 +98,7 @@ export default function SettingsCreatorPage(props: Props) { setMinTip(settings.min_tip_amount_comment || 0); setMinSuper(settings.min_tip_amount_super_chat || 0); setSlowModeMin(settings.slow_mode_min_gap || 0); + setMinChannelAgeMinutes(settings.time_since_first_comment || 0); doSetMutedWordTags(settings.words || []); } else { if (settings.comments_enabled !== undefined) { @@ -105,6 +113,9 @@ export default function SettingsCreatorPage(props: Props) { if (settings.slow_mode_min_gap !== undefined) { setSlowModeMin(settings.slow_mode_min_gap); } + if (settings.time_since_first_comment) { + setMinChannelAgeMinutes(settings.time_since_first_comment); + } if (settings.words) { doSetMutedWordTags(settings.words); } @@ -285,6 +296,41 @@ export default function SettingsCreatorPage(props: Props) { /> + +
+ 0 + ? humanizeDuration(minChannelAgeMinutes * 60 * 1000, { round: true }) + : __('No limit') + } + inputButton={ +
+
+ }}>Minimum %lbc% tip amount for comments @@ -386,6 +432,7 @@ export default function SettingsCreatorPage(props: Props) { // prettier-ignore const HELP = { SLOW_MODE: 'Minimum time gap in seconds between comments (affects livestream chat as well).', + CHANNEL_AGE: 'Channels with a lifespan lower than the specified duration will not be able to comment on your content.', MIN_TIP: 'Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.', MIN_SUPER: 'Enabling a minimum amount to hyperchat will force all TIPPED comments to have this value in order to be shown. This still allows regular comments to be posted.', MIN_SUPER_OFF: '(This settings is not applicable if all comments require a tip.)', diff --git a/ui/scss/component/section.scss b/ui/scss/component/section.scss index 9232cceb3..4c53776aa 100644 --- a/ui/scss/component/section.scss +++ b/ui/scss/component/section.scss @@ -340,7 +340,8 @@ //padding-left: var(--spacing-m); .button, - .checkbox { + .checkbox, + .section__actions { &:only-child { float: right; }