Skip to content

Commit 19fe9a3

Browse files
authored
Merge branch 'master' into feature/chat-wait-socket-connection-ready
2 parents 8dddfa2 + c3ac82d commit 19fe9a3

File tree

16 files changed

+174
-125
lines changed

16 files changed

+174
-125
lines changed

Diff for: app/Http/Controllers/ContestsController.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function judge($id)
3737
priv_check('ContestJudgeShow', $contest)->ensureCan();
3838

3939
$contestJson = json_item($contest, new ContestTransformer(), [
40+
'current_user_attributes',
4041
'entries.current_user_judge_vote.scores',
4142
'scoring_categories',
4243
]);

Diff for: app/Libraries/ImageProcessor.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@ public function process()
9191
}
9292

9393
$newHeight = $this->inputDim[0] * $this->targetDim[1] / $this->targetDim[0];
94-
$this->targetDim = $newHeight <= $this->inputDim[1]
94+
$targetDim = $newHeight <= $this->inputDim[1]
9595
? [
9696
$this->inputDim[0],
9797
$newHeight,
9898
] : [
9999
$this->inputDim[1] * $this->targetDim[0] / $this->targetDim[1],
100100
$this->inputDim[1],
101101
];
102+
$this->targetDim = array_map(fn ($d) => max(1, $d), $targetDim);
102103
}
103104

104105
$start = [0, 0];

Diff for: app/Models/Contest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function isJudged(): bool
134134

135135
public function isJudgingActive(): bool
136136
{
137-
return $this->isJudged() && $this->isVotingStarted() && !$this->show_votes;
137+
return $this->isJudged() && $this->isVotingOpen() && !$this->show_votes;
138138
}
139139

140140
public function isSubmittedBeatmaps(): bool

Diff for: app/Transformers/ContestTransformer.php

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class ContestTransformer extends TransformerAbstract
1515
{
1616
protected array $availableIncludes = [
17+
'current_user_attributes',
1718
'entries',
1819
'scoring_categories',
1920
'max_judging_score',
@@ -46,6 +47,13 @@ public function transform(Contest $contest)
4647
];
4748
}
4849

50+
public function includeCurrentUserAttributes(Contest $contest)
51+
{
52+
return $this->primitive([
53+
'can_judge' => priv_check('ContestJudge', $contest)->can(),
54+
]);
55+
}
56+
4957
public function includeEntries(Contest $contest)
5058
{
5159
return $this->collection($contest->entriesByType(Auth::user()), new ContestEntryTransformer());

Diff for: app/helpers.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ function db_unsigned_increment($column, $count)
389389
return DB::raw($value);
390390
}
391391

392-
function default_mode()
392+
function default_mode(): string
393393
{
394-
return optional(auth()->user())->playmode ?? 'osu';
394+
return Auth::user()?->playmode ?? 'osu';
395395
}
396396

397397
function flag_url($countryCode)

Diff for: resources/css/bem/contest-judge-entry.less

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
22
// See the LICENCE file in the repository root for full licence text.
33

4-
@margin: 10px;
5-
64
.contest-judge-entry {
7-
margin-bottom: 20px;
8-
max-width: 500px;
9-
105
&__button {
116
display: flex;
127
justify-content: flex-end;
@@ -17,6 +12,7 @@
1712
display: flex;
1813
flex-direction: column;
1914
gap: 10px;
15+
max-width: 500px;
2016
}
2117

2218
&__category {
@@ -76,7 +72,7 @@
7672
}
7773

7874
&__title {
79-
margin-bottom: @margin;
75+
margin-bottom: 10px;
8076
font-size: @font-size--large;
8177
font-weight: bold;
8278
color: hsl(var(--hsl-l1));

Diff for: resources/css/bem/contest-judge.less

+18-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
.contest-judge {
5-
.default-gutter-v2();
5+
display: flex;
6+
flex-direction: column;
7+
gap: 15px;
68
font-size: @font-size--title-small;
7-
padding-top: 15px;
8-
padding-bottom: $padding-top;
9+
background-color: hsl(var(--hsl-b5));
910

10-
&--header {
11+
&__header {
12+
.default-gutter-v2();
1113
background-color: hsl(var(--hsl-d3));
14+
padding-top: 15px;
15+
padding-bottom: $padding-top;
1216
}
1317

14-
&--items {
15-
background-color: hsl(var(--hsl-b5));
18+
&__items {
19+
.default-gutter-v2();
20+
flex-direction: column;
21+
gap: 20px;
22+
margin-bottom: $gap;
23+
}
24+
25+
&__switch {
26+
font-weight: normal;
27+
margin: 0;
1628
}
1729
}

Diff for: resources/css/bem/sort.less

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@
5555
});
5656
}
5757

58-
&--contest-judge {
59-
margin: 0;
60-
padding: 0;
61-
}
62-
6358
&--title {
6459
padding: 0;
6560
}

Diff for: resources/js/chat/conversation-view.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ export default class ConversationView extends React.Component<Props> {
4646
let currentGroup: Message[] = [];
4747
let unreadMarkerShown = false;
4848
let currentDay: string;
49+
const messages = this.messages;
4950

50-
each(channel.messages, (message: Message, key: number) => {
51+
each(messages, (message: Message, key: number) => {
5152
// check if the last read indicator needs to be shown
5253
if (!unreadMarkerShown
5354
&& typeof message.messageId === 'number'
@@ -84,7 +85,7 @@ export default class ConversationView extends React.Component<Props> {
8485
currentGroup.push(message);
8586
}
8687

87-
if (key === channel.messages.length - 1) {
88+
if (key === messages.length - 1) {
8889
conversationStack.push(<MessageGroup key={currentGroup[0].uuid} messages={currentGroup} />);
8990
}
9091
});
@@ -97,6 +98,12 @@ export default class ConversationView extends React.Component<Props> {
9798
return core.dataStore.chatState.selectedChannel;
9899
}
99100

101+
private get messages() {
102+
const channel = this.currentChannel;
103+
if (channel == null) return [];
104+
return channel.messages.filter((message) => !core.currentUserModel.blocks.has(message.senderId));
105+
}
106+
100107
constructor(props: Props) {
101108
super(props);
102109

Diff for: resources/js/contest-judge/entry.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export default class Entry extends React.Component<Props> {
4444

4545
@computed
4646
private get canSubmit() {
47-
return !this.commentTooLong
47+
return this.store.canJudge
48+
&& !this.commentTooLong
4849
&& this.currentVote.scores.size === this.store.scoringCategories.length
4950
&& (this.currentVote.comment !== this.initialVote.comment
5051
|| this.store.scoringCategories.some((category) => (
@@ -83,6 +84,7 @@ export default class Entry extends React.Component<Props> {
8384
>
8485
<TextareaAutosize
8586
className='input-text'
87+
disabled={!this.store.canJudge}
8688
maxRows={20}
8789
onChange={this.handleCommentChange}
8890
rows={6}
@@ -133,6 +135,7 @@ export default class Entry extends React.Component<Props> {
133135
<input
134136
className='contest-judge-entry__slider'
135137
data-category-id={category.id}
138+
disabled={!this.store.canJudge}
136139
max={category.max_value}
137140
onChange={this.handleRangeInputChange}
138141
type='range'

Diff for: resources/js/contest-judge/main.tsx

+18-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { action, makeObservable, observable } from 'mobx';
55
import { observer } from 'mobx-react';
66
import * as React from 'react';
77
import ContestJudgeStore from 'stores/contest-judge-store';
8-
import { classWithModifiers } from 'utils/css';
98
import { trans } from 'utils/lang';
109
import Entry from './entry';
1110

@@ -35,12 +34,15 @@ export default class Main extends React.Component<Props> {
3534

3635
render() {
3736
return (
38-
<>
39-
<div className='contest-judge contest-judge--header'>
37+
<div className='contest-judge'>
38+
<div className='contest-judge__header'>
4039
{this.renderShowJudgedToggle()}
40+
{!this.props.store.canJudge && (
41+
<div>{trans('authorization.contest.judging_not_active')}</div>
42+
)}
4143
</div>
4244

43-
<div className='contest-judge contest-judge--items'>
45+
<div className='contest-judge__items'>
4446
{this.filteredEntries.map((entry) => (
4547
<Entry
4648
key={entry.id}
@@ -49,27 +51,24 @@ export default class Main extends React.Component<Props> {
4951
/>
5052
))}
5153
</div>
52-
</>
54+
</div>
5355
);
5456
}
5557

5658
private renderShowJudgedToggle() {
57-
const iconClass = this.hideJudged
58-
? 'fas fa-check-square'
59-
: 'far fa-square';
60-
6159
return (
62-
<button
63-
className={classWithModifiers('sort__item', ['button', 'contest-judge'])}
64-
onClick={this.toggleShowJudged}
65-
type='button'
66-
>
67-
<span className='sort__item-icon'>
68-
<span className={iconClass} />
69-
</span>
70-
60+
<label className='contest-judge__switch'>
61+
<div className='osu-switch-v2'>
62+
<input
63+
checked={this.hideJudged}
64+
className='osu-switch-v2__input'
65+
onChange={this.toggleShowJudged}
66+
type='checkbox'
67+
/>
68+
<span className='osu-switch-v2__content' />
69+
</div>
7170
{trans('contest.judge.hide_judged')}
72-
</button>
71+
</label>
7372
);
7473
}
7574

Diff for: resources/js/interfaces/contest-json.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import ContestEntryJson, { ContestEntryJsonForResults } from './contest-entry-js
55
import ContestScoringCategoryJson from './contest-scoring-category-json';
66

77
interface ContestJsonAvailableIncludes {
8+
current_user_attributes: {
9+
can_judge: boolean;
10+
};
811
entries: ContestEntryJson[];
912
max_judging_score: number;
1013
max_total_score: number;
@@ -26,4 +29,4 @@ export type ContestJsonForResults = ContestJsonDefaultAttributes
2629
};
2730

2831
export type ContestJsonForStore = ContestJsonDefaultAttributes
29-
& Required<Pick<ContestJsonAvailableIncludes, 'entries' | 'scoring_categories'>>;
32+
& Required<Pick<ContestJsonAvailableIncludes, 'current_user_attributes' | 'entries' | 'scoring_categories'>>;

Diff for: resources/js/mp-history/game.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { div, span, strong } from 'react-dom-factories'
77
import { formatNumber } from 'utils/html'
88
import { trans, transExists } from 'utils/lang'
99
import GameHeader from './game-header'
10-
import { Score } from './score'
10+
import Score from './score'
1111

1212
el = React.createElement
1313

Diff for: resources/js/mp-history/score.coffee

-80
This file was deleted.

0 commit comments

Comments
 (0)