Skip to content

Commit

Permalink
skip textarea if can't post new discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
notbakaneko committed Mar 16, 2023
1 parent f1dea60 commit 6297f89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions resources/css/bem/beatmap-discussion-new.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
}

&__message {
.content-font();
font-size: @font-size--title-small-2;
flex: 1;
color: hsl(var(--hsl-f1));
}

&__message-area {
Expand Down
28 changes: 15 additions & 13 deletions resources/js/beatmap-discussions/new-discussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ export class NewDiscussion extends React.Component<Props> {
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)) {
Expand Down Expand Up @@ -385,15 +387,15 @@ export class NewDiscussion extends React.Component<Props> {
}

private renderTextarea() {
if (core.currentUser == null) return trans('beatmaps.discussions.require-login');

return (
return this.canPost ? (
<>
<MarkdownEditorSwitcher
id={0}
mode={this.mode}
onModeChange={this.handleModeChange}
/>
{this.canPost && (
<MarkdownEditorSwitcher
id={0}
mode={this.mode}
onModeChange={this.handleModeChange}
/>
)}
<MarkdownEditor
disabled={this.posting != null}
isTimeline={this.isTimeline}
Expand All @@ -402,11 +404,11 @@ export class NewDiscussion extends React.Component<Props> {
onChange={this.setMessage}
onFocus={this.onFocus}
onKeyDown={this.handleKeyDown}
placeholder={this.textareaPlaceholder}
placeholder={this.placeholderText}
value={this.message}
/>
</>
);
) : this.placeholderText;
}

private renderTimestamp() {
Expand Down

0 comments on commit 6297f89

Please sign in to comment.