Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nomination button disabled state with unresolved issues and discussion post editing #10907

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/js/beatmap-discussions/discussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class Discussion extends React.Component<Props> {
}

@computed
private get resolvedSystemPostId() {
private get resolvedStateChangedPostId() {
// TODO: handling resolved status in bundles....?
if (this.props.discussionsState == null) return -1;

Expand Down Expand Up @@ -236,7 +236,7 @@ export class Discussion extends React.Component<Props> {
post={post}
read={this.isRead(post)}
readonly={this.readonly}
resolved={post.id > this.resolvedSystemPostId}
resolvedStateChangedPostId={this.resolvedStateChangedPostId}
store={this.props.store}
type={type}
user={user}
Expand Down
4 changes: 2 additions & 2 deletions resources/js/beatmap-discussions/discussions-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ export default class DiscussionsState {
return this.nonDeletedDiscussions
.reduce((sum, discussion) => {
if (discussion.can_be_resolved && !discussion.resolved) {
if (discussion.beatmap_id == null) return sum++;
if (discussion.beatmap_id == null) return ++sum;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well just sum + 1 instead of dealing with subtlety of ++ operator. And it's not like the variable itself needs to be updated.


const beatmap = this.store.beatmaps.get(discussion.beatmap_id);
if (beatmap != null && beatmap.deleted_at == null) return sum++;
if (beatmap != null && beatmap.deleted_at == null) return ++sum;
}

return sum;
Expand Down
6 changes: 3 additions & 3 deletions resources/js/beatmap-discussions/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface Props {
post: BeatmapsetDiscussionMessagePostJson;
read: boolean;
readonly: boolean;
resolved: boolean;
resolvedStateChangedPostId: number;
store: BeatmapsetDiscussionsStore;
type: string;
user: UserJson;
Expand All @@ -50,7 +50,7 @@ interface Props {
@observer
export default class Post extends React.Component<Props> {
static defaultProps = {
resolved: false,
resolvedStateChangedPostId: -1,
};

@observable private canSave = true; // this isn't computed because Editor's onChange doesn't provide anything to react to.
Expand Down Expand Up @@ -85,7 +85,7 @@ export default class Post extends React.Component<Props> {
return this.isAdmin
|| (!downloadLimited(this.beatmapset)
&& this.isOwn
&& !this.props.resolved
&& this.props.post.id > this.props.resolvedStateChangedPostId
&& !this.beatmapset.discussion_locked
);
}
Expand Down
Loading