Enable 'slow mode' in comments
## Issue Sub item in <6119 Creator Settings: beyond "Muted Words"> ## Changes - Removed the existing 5s min gap on livestreams. - Enabled the 'slow mode min gap' in Creator Settings This change now affects both comments in claims and livestream comments.
This commit is contained in:
parent
6761cd2aa6
commit
26efe9fd45
5 changed files with 15 additions and 29 deletions
|
@ -1445,6 +1445,7 @@
|
|||
"Unable to comment. This channel has blocked you.": "Unable to comment. This channel has blocked you.",
|
||||
"Unable to comment. Your channel has been blocked by an admin.": "Unable to comment. Your channel has been blocked by an admin.",
|
||||
"Unable to comment. The content owner has disabled comments.": "Unable to comment. The content owner has disabled comments.",
|
||||
"The creator has set a minimum time gap between comments. Try again later.": "The creator has set a minimum time gap between comments. Try again later.",
|
||||
"The comment contains contents that are blocked by %author%": "The comment contains contents that are blocked by %author%",
|
||||
"Your channel is still being setup, try again in a few moments.": "Your channel is still being setup, try again in a few moments.",
|
||||
"Unable to delete this comment, please try again later.": "Unable to delete this comment, please try again later.",
|
||||
|
@ -1916,7 +1917,7 @@
|
|||
"Suggestions": "Suggestions",
|
||||
"Add words to block": "Add words to block",
|
||||
"Enable comments for channel.": "Enable comments for channel.",
|
||||
"Minimum time gap in seconds for Slow Mode in livestream chat.": "Minimum time gap in seconds for Slow Mode in livestream chat.",
|
||||
"Minimum time gap in seconds between comments (affects livestream chat as well).": "Minimum time gap in seconds between comments (affects livestream chat as well).",
|
||||
"Minimum %lbc% tip amount for comments": "Minimum %lbc% tip amount for comments",
|
||||
"Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.": "Enabling a minimum amount to comment will force all comments, including livestreams, to have tips associated with them. This can help prevent spam.",
|
||||
"Minimum %lbc% tip amount for hyperchats": "Minimum %lbc% tip amount for hyperchats",
|
||||
|
|
|
@ -11,7 +11,6 @@ import { doCommentCreate } from 'redux/actions/comments';
|
|||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { makeSelectCommentsDisabledForUri } from 'redux/selectors/comments';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { CommentCreate } from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
|
@ -29,7 +28,6 @@ const perform = (dispatch, ownProps) => ({
|
|||
dispatch(doCommentCreate(comment, claimId, parentId, ownProps.uri, ownProps.livestream, txid)),
|
||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
||||
toast: (message) => dispatch(doToast({ message, isError: true })),
|
||||
sendTip: (params, callback, errorCallback) => dispatch(doSendTip(params, false, callback, errorCallback, false)),
|
||||
});
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ import ChannelThumbnail from 'component/channelThumbnail';
|
|||
import UriIndicator from 'component/uriIndicator';
|
||||
import Empty from 'component/common/empty';
|
||||
|
||||
const COMMENT_SLOW_MODE_SECONDS = 5;
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
claim: StreamClaim,
|
||||
|
@ -54,7 +52,6 @@ export function CommentCreate(props: Props) {
|
|||
parentId,
|
||||
activeChannelClaim,
|
||||
livestream,
|
||||
toast,
|
||||
claimIsMine,
|
||||
sendTip,
|
||||
justCommented,
|
||||
|
@ -72,7 +69,6 @@ export function CommentCreate(props: Props) {
|
|||
const [isReviewingSupportComment, setIsReviewingSupportComment] = React.useState();
|
||||
const [tipAmount, setTipAmount] = React.useState(1);
|
||||
const [commentValue, setCommentValue] = React.useState('');
|
||||
const [lastCommentTime, setLastCommentTime] = React.useState();
|
||||
const [advancedEditor, setAdvancedEditor] = usePersistedState('comment-editor-mode', false);
|
||||
const hasChannels = channels && channels.length;
|
||||
const disabled = isSubmitting || !activeChannelClaim || !commentValue.length;
|
||||
|
@ -107,15 +103,6 @@ export function CommentCreate(props: Props) {
|
|||
|
||||
function handleSubmit() {
|
||||
if (activeChannelClaim && commentValue.length) {
|
||||
const timeUntilCanComment = !lastCommentTime
|
||||
? 0
|
||||
: (lastCommentTime - Date.now()) / 1000 + COMMENT_SLOW_MODE_SECONDS;
|
||||
|
||||
if (livestream && !claimIsMine && timeUntilCanComment > 0) {
|
||||
toast(__('Slowmode is on. You can comment again in %time% seconds.', { time: Math.ceil(timeUntilCanComment) }));
|
||||
return;
|
||||
}
|
||||
|
||||
handleCreateComment();
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +150,6 @@ export function CommentCreate(props: Props) {
|
|||
|
||||
if (res && res.signature) {
|
||||
setCommentValue('');
|
||||
setLastCommentTime(Date.now());
|
||||
setIsReviewingSupportComment(false);
|
||||
setIsSupportComment(false);
|
||||
setCommentFailure(false);
|
||||
|
|
|
@ -265,18 +265,16 @@ export default function SettingsCreatorPage(props: Props) {
|
|||
checked={commentsEnabled}
|
||||
onChange={() => setSettings({ comments_enabled: !commentsEnabled })}
|
||||
/>
|
||||
{FEATURE_IS_READY && (
|
||||
<FormField
|
||||
name="slow_mode_min_gap"
|
||||
label={__('Minimum time gap in seconds for Slow Mode in livestream chat.')}
|
||||
min={0}
|
||||
step={1}
|
||||
type="number"
|
||||
placeholder="1"
|
||||
value={slowModeMinGap}
|
||||
onChange={(e) => setSettings({ slow_mode_min_gap: e.target.value })}
|
||||
/>
|
||||
)}
|
||||
<FormField
|
||||
name="slow_mode_min_gap"
|
||||
label={__('Minimum time gap in seconds between comments (affects livestream chat as well).')}
|
||||
min={0}
|
||||
step={1}
|
||||
type="number"
|
||||
placeholder="1"
|
||||
value={slowModeMinGap}
|
||||
onChange={(e) => setSettings({ slow_mode_min_gap: parseInt(e.target.value) })}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -340,6 +340,9 @@ export function doCommentCreate(
|
|||
case 'comments are disabled by the creator':
|
||||
toastMessage = __('Unable to comment. The content owner has disabled comments.');
|
||||
break;
|
||||
case 'the creator has a min gap between comments set.':
|
||||
toastMessage = __('The creator has set a minimum time gap between comments. Try again later.');
|
||||
break;
|
||||
default:
|
||||
const BLOCKED_WORDS_ERR_MSG = 'the comment contents are blocked by';
|
||||
if (error.message.startsWith(BLOCKED_WORDS_ERR_MSG)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue