Skip to content

Commit 68093ce

Browse files
authored
Merge pull request #19683 from allanjoseph98/ratingdiffs-fixes
Broadcast: Relay players fixes
2 parents 350add0 + b797910 commit 68093ce

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

modules/relay/src/main/RelayPlayer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private final class RelayPlayerApi(
246246
result <-
247247
if !atLeastOneGameFinished then fuccess(players)
248248
else
249-
val withScore = if tour.showScores then computeScores(players) else players
249+
val withScore = computeScoresAndPerformances(players, tour.showScores)
250250
for
251251
withRatingDiff <-
252252
if tour.showRatingDiffs then computeRatingDiffs(withScore) else fuccess(withScore)
@@ -311,11 +311,11 @@ private final class RelayPlayerApi(
311311
.withGame(game, player)
312312
)
313313

314-
private def computeScores(players: RelayPlayers): RelayPlayers =
314+
private def computeScoresAndPerformances(players: RelayPlayers, computeScores: Boolean): RelayPlayers =
315315
players.view
316316
.mapValues: p =>
317317
p.copy(
318-
score = p.games.foldMap(_.playerScore),
318+
score = computeScores.so(p.games.foldMap(_.playerScore)),
319319
performances = p.games
320320
.groupBy(_.fideTC)
321321
.foldLeft(Map.empty):

ui/analyse/css/study/relay/_player-tip.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
@extend %flex-center;
5252
gap: 0.5em;
5353
}
54+
.diffs {
55+
@extend %flex-column;
56+
}
5457
}
5558
}
5659
}

ui/analyse/src/study/relay/relayPlayers.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -404,22 +404,16 @@ export const playerLinkConfig = (ctrl: RelayPlayers, player: StudyPlayer, withTi
404404
export const fidePageLinkAttrs = (p: StudyPlayer, blank?: boolean): Attrs | undefined =>
405405
p.fideId ? { href: `/fide/${p.fideId}/redirect`, ...(blank ? { target: '_blank' } : {}) } : undefined;
406406

407-
const isRelayPlayer = (p: StudyPlayer | RelayPlayer): p is RelayPlayer => 'score' in p;
408-
409-
const renderPlayerTipHead = (ctrl: RelayPlayers, p: StudyPlayer | RelayPlayer): VNode =>
407+
const renderPlayerTipHead = (ctrl: RelayPlayers, p: RelayPlayer): VNode =>
410408
hl('div.tpp__player', [
411409
playerPhoto(p, ctrl, 'medium'),
412410
hl('div.tpp__player__info', [
413411
hl(`a.tpp__player__name`, playerLinkConfig(ctrl, p, false), [userTitle(p), p.name]),
414412
hl('div.tpp__player__details', [
415413
p.team && hl('a.tpp__player__team', matchOrResultsTeamLink(ctrl, p.team), p.team),
416-
hl('div', [
417-
playerFedFlag(p.fed),
418-
!!p.rating && isRelayPlayer(p) && !ctrl.hideResultsSinceRoundId() && ratingDiff(p),
419-
]),
420-
isRelayPlayer(p) &&
421-
!ctrl.hideResultsSinceRoundId() &&
422-
p.score !== undefined &&
414+
hl('div', [playerFedFlag(p.fed), !!p.rating && !ctrl.hideResultsSinceRoundId() && ratingDiff(p)]),
415+
!ctrl.hideResultsSinceRoundId() &&
416+
defined(p.score) &&
423417
hl('span', [i18n.broadcast.score, ' ', hl('strong', p.score)]),
424418
]),
425419
]),
@@ -524,10 +518,12 @@ const ratingDiff = (p: RelayPlayer | RelayPlayerGame, showIcons: boolean = false
524518
if (isRelayPlayerGame(p)) return hl('div.diff', showIcons && fideTCAttrs(p.fideTC), diffNode(p.ratingDiff));
525519
if (!p.ratingDiffs) return p.rating;
526520
const rds = Object.entries(p.ratingDiffs);
527-
return rds.map(([tc, diff]: [FideTC, number]) => {
528-
const node = hl('div.diff', [p.ratingsMap?.[tc], diffNode(diff)]);
529-
return rds.length === 1 ? node : hl('div.diff', fideTCAttrs(tc), node);
521+
const isMultiTc = rds.length > 1;
522+
const diffNodes = rds.map(([tc, diff]: [FideTC, number]) => {
523+
const node = [p.ratingsMap?.[tc], diffNode(diff)];
524+
return isMultiTc ? hl('div.diff', fideTCAttrs(tc), node) : node;
530525
});
526+
return isMultiTc ? hl('div.diffs', diffNodes) : hl('div.diff', diffNodes[0]);
531527
};
532528

533529
const diffNode = (rd?: number) =>

0 commit comments

Comments
 (0)