From 6297f8998173f8746e78c25d6c2b5771a681ae72 Mon Sep 17 00:00:00 2001 From: bakaneko Date: Wed, 15 Mar 2023 20:06:10 +0900 Subject: [PATCH] skip textarea if can't post new discussion --- resources/css/bem/beatmap-discussion-new.less | 3 ++ .../js/beatmap-discussions/new-discussion.tsx | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/resources/css/bem/beatmap-discussion-new.less b/resources/css/bem/beatmap-discussion-new.less index 866ffb45fb1..c12f727b1c2 100644 --- a/resources/css/bem/beatmap-discussion-new.less +++ b/resources/css/bem/beatmap-discussion-new.less @@ -72,7 +72,10 @@ } &__message { + .content-font(); + font-size: @font-size--title-small-2; flex: 1; + color: hsl(var(--hsl-f1)); } &__message-area { diff --git a/resources/js/beatmap-discussions/new-discussion.tsx b/resources/js/beatmap-discussions/new-discussion.tsx index 95092a6d0b2..acbb0be77c3 100644 --- a/resources/js/beatmap-discussions/new-discussion.tsx +++ b/resources/js/beatmap-discussions/new-discussion.tsx @@ -104,13 +104,15 @@ export class NewDiscussion extends React.Component { return localStorage.getItem(this.storageKey) ?? ''; } - private get textareaPlaceholder() { - if (core.currentUser == null) return; - + private get placeholderText() { if (this.canPost) { return trans(`beatmaps.discussions.message_placeholder.${this.props.mode}`, { version: this.props.currentBeatmap.version }); } + if (core.currentUser == null) { + return trans('beatmaps.discussions.require-login'); + } + if (core.currentUser.is_silenced) { return trans('beatmaps.discussions.message_placeholder_silenced'); } else if (this.props.beatmapset.discussion_locked || downloadLimited(this.props.beatmapset)) { @@ -385,15 +387,15 @@ export class NewDiscussion extends React.Component { } private renderTextarea() { - if (core.currentUser == null) return trans('beatmaps.discussions.require-login'); - - return ( + return this.canPost ? ( <> - + {this.canPost && ( + + )} { onChange={this.setMessage} onFocus={this.onFocus} onKeyDown={this.handleKeyDown} - placeholder={this.textareaPlaceholder} + placeholder={this.placeholderText} value={this.message} /> - ); + ) : this.placeholderText; } private renderTimestamp() {