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

Show or Hide broadcasts results #16650

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
af4b7b7
Add a toggle to show or hide boards results
yahya-lafhal Dec 23, 2024
3754004
Show or hide results on the relayGames
yahya-lafhal Dec 23, 2024
c2b74c8
Add i18n for the showResults toggle and a basic translation
yahya-lafhal Dec 23, 2024
afc3922
Use the correct i18n
yahya-lafhal Dec 23, 2024
3ccd763
Handle css for the new toggle like the others
yahya-lafhal Dec 23, 2024
e95b256
Fix formatting
yahya-lafhal Dec 23, 2024
66caa44
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 23, 2024
195faa9
Merge branch 'master' into show-hide-broadcasts-results
ornicar Dec 24, 2024
b99ca77
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 24, 2024
53cdfb3
Merge branch 'master' into show-hide-broadcasts-results
ornicar Dec 25, 2024
a9cceb3
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 28, 2024
b6624e4
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 28, 2024
fb32e17
Merge remote-tracking branch 'fork/show-hide-broadcasts-results' into…
yahya-lafhal Dec 28, 2024
36dc823
Merge remote-tracking branch 'upstream/master' into show-hide-broadca…
yahya-lafhal Dec 28, 2024
2f764de
Remove clocks from boards grid when selecting no results
yahya-lafhal Dec 28, 2024
f2e3bb1
Hide eval gauges when hiding results
yahya-lafhal Dec 28, 2024
6ca3a48
Make the show results toggle a stored prop
yahya-lafhal Dec 28, 2024
1f92f79
Merge remote-tracking branch 'upstream/master' into show-hide-broadca…
yahya-lafhal Dec 28, 2024
426fca5
Fix formatting
yahya-lafhal Dec 28, 2024
861775f
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 28, 2024
6d63e0b
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 31, 2024
72e9f3f
Send to initial position when clicking on a broadcast game with resul…
yahya-lafhal Dec 31, 2024
5d6027f
Fix formatting
yahya-lafhal Dec 31, 2024
5507443
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Dec 31, 2024
a9cb00b
Render empty previews with a note when setting results to off
yahya-lafhal Jan 1, 2025
e6faf8b
Fix ts formatting
yahya-lafhal Jan 1, 2025
7341cf5
Merge remote-tracking branch 'fork/show-hide-broadcasts-results' into…
yahya-lafhal Jan 1, 2025
6281168
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 1, 2025
2df749b
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 1, 2025
524d7c7
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 5, 2025
84be05c
Merge branch 'master' into show-hide-broadcasts-results
ornicar Jan 6, 2025
521bfff
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 6, 2025
52d13f5
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 7, 2025
5c5a09e
Merge branch 'master' into show-hide-broadcasts-results
ornicar Jan 7, 2025
6fcb718
redraw immediately when switching the broadcast results toggle
ornicar Jan 7, 2025
ea6002a
avoid flashing the current position when hiding the current broadcast…
ornicar Jan 7, 2025
79918a1
Merge branch 'master' into show-hide-broadcasts-results
yahya-lafhal Jan 8, 2025
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
1 change: 1 addition & 0 deletions modules/coreI18n/src/main/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,7 @@ object I18nKey:
val `allSyncMembersRemainOnTheSamePosition`: I18nKey = "study:allSyncMembersRemainOnTheSamePosition"
val `shareChanges`: I18nKey = "study:shareChanges"
val `playing`: I18nKey = "study:playing"
val `showResults`: I18nKey = "study:showResults"
val `showEvalBar`: I18nKey = "study:showEvalBar"
val `first`: I18nKey = "study:first"
val `previous`: I18nKey = "study:previous"
Expand Down
1 change: 1 addition & 0 deletions translation/source/study.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<string name="allSyncMembersRemainOnTheSamePosition">All SYNC members remain on the same position</string>
<string name="shareChanges">Share changes with spectators and save them on the server</string>
<string name="playing">Playing</string>
<string name="showResults">Results</string>
<string name="showEvalBar">Evaluation bars</string>
<string name="first">First</string>
<string name="previous">Previous</string>
Expand Down
2 changes: 2 additions & 0 deletions ui/@types/lichess/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4867,6 +4867,8 @@ interface I18n {
shareChanges: string;
/** Evaluation bars */
showEvalBar: string;
/** Results */
showResults: string;
/** Spectator */
spectator: string;
/** Start */
Expand Down
11 changes: 9 additions & 2 deletions ui/analyse/css/study/panel/_multiboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
}

.playing,
.eval {
.eval,
.results {
cursor: pointer;
}

.playing input,
.eval input {
.eval input,
.results input {
vertical-align: middle;
margin-inline-end: 3px;
}
Expand Down Expand Up @@ -164,3 +166,8 @@
border-radius: 4px 0 0 4px;
}
}

.empty-boards-note {
margin-bottom: 0.5em;
color: var(--c-font-dim);
}
73 changes: 54 additions & 19 deletions ui/analyse/src/study/multiBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { type StudyChapters, gameLinkAttrs, gameLinksListener } from './studyCha
import { playerFed } from './playerBars';
import { userTitle } from 'common/userLink';
import { h } from 'snabbdom';
import { storage } from 'common/storage';
import { storage, storedBooleanProp, StoredProp } from 'common/storage';
import { Chessground as makeChessground } from 'chessground';

export class MultiBoardCtrl {
playing: Toggle;
showResults: StoredProp<boolean>;
teamSelect: Prop<string> = prop('');
page: number = 1;
maxPerPageStorage = storage.make('study.multiBoard.maxPerPage');
Expand All @@ -28,6 +29,7 @@ export class MultiBoardCtrl {
readonly redraw: () => void,
) {
this.playing = toggle(false, this.redraw);
this.showResults = storedBooleanProp('study.showResults', true);
if (this.initialTeamSelect) this.onChapterChange(this.initialTeamSelect);
}

Expand Down Expand Up @@ -102,16 +104,24 @@ export function view(ctrl: MultiBoardCtrl, study: StudyCtrl): MaybeVNode {
ctrl.multiCloudEval &&
h('label.eval', [renderEvalToggle(ctrl.multiCloudEval), i18n.study.showEvalBar]),
renderPlayingToggle(ctrl),
renderShowResultsToggle(ctrl),
]),
]),
!ctrl.showResults()
? h(
'div.empty-boards-note',
{ attrs: { 'data-icon': licon.InfoCircle } },
' Since you chose to hide the results, all the preview boards are empty to avoid spoilers.',
)
: undefined,
h(
'div.now-playing',
{
hook: {
insert: gameLinksListener(study.chapterSelect),
},
},
pager.currentPageResults.map(makePreview(baseUrl, study.vm.chapterId, cloudEval)),
pager.currentPageResults.map(makePreview(baseUrl, study.vm.chapterId, cloudEval, ctrl.showResults())),
),
]);
}
Expand Down Expand Up @@ -176,6 +186,15 @@ const renderPlayingToggle = (ctrl: MultiBoardCtrl): MaybeVNode =>
i18n.study.playing,
]);

const renderShowResultsToggle = (ctrl: MultiBoardCtrl): MaybeVNode =>
h('label.results', [
h('input', {
attrs: { type: 'checkbox', checked: ctrl.showResults() },
hook: bind('change', e => ctrl.showResults((e.target as HTMLInputElement).checked), ctrl.redraw),
}),
i18n.study.showResults,
]);

const previewToCgConfig = (cp: ChapterPreview): CgConfig => ({
fen: cp.fen,
lastMove: uciToMove(cp.lastMove),
Expand All @@ -184,48 +203,64 @@ const previewToCgConfig = (cp: ChapterPreview): CgConfig => ({
});

const makePreview =
(roundPath: string, current: ChapterId, cloudEval?: MultiCloudEval) => (preview: ChapterPreview) => {
(roundPath: string, current: ChapterId, cloudEval?: MultiCloudEval, showResults?: boolean) =>
(preview: ChapterPreview) => {
const orientation = preview.orientation || 'white';
const baseConfig = {
coordinates: false,
viewOnly: true,
orientation,
drawable: {
enabled: false,
visible: false,
},
};
return h(
`a.mini-game.is2d.chap-${preview.id}`,
{
class: { active: preview.id === current },
attrs: gameLinkAttrs(roundPath, preview),
},
[
boardPlayer(preview, CgOpposite(orientation)),
boardPlayer(preview, CgOpposite(orientation), showResults),
h('span.cg-gauge', [
cloudEval && verticalEvalGauge(preview, cloudEval),
showResults ? cloudEval && verticalEvalGauge(preview, cloudEval) : undefined,
h(
'span.mini-game__board',
h('span.cg-wrap', {
hook: {
insert(vnode) {
const el = vnode.elm as HTMLElement;
vnode.data!.cg = makeChessground(el, {
...previewToCgConfig(preview),
coordinates: false,
viewOnly: true,
orientation,
drawable: {
enabled: false,
visible: false,
},
});
vnode.data!.cg = showResults
? makeChessground(el, {
...previewToCgConfig(preview),
...baseConfig,
})
: makeChessground(el, {
fen: '8/8/8/8/8/8/8/8',
...baseConfig,
});
vnode.data!.fen = preview.fen;
},
postpatch(old, vnode) {
if (old.data!.fen !== preview.fen) {
old.data!.cg?.set(previewToCgConfig(preview));
}
// In this case, showResults was set to true but the cg fen is still on the initial pos
if (showResults && old.data!.cg.fen != old.data!.cg.getFen()) {
old.data!.cg.set(previewToCgConfig(preview));
}
vnode.data!.fen = preview.fen;
vnode.data!.cg = old.data!.cg;
const el = vnode.elm as HTMLElement;
vnode.data!.cg = showResults
? old.data!.cg
: makeChessground(el, { fen: '8/8/8/8/8/8/8/8', ...baseConfig });
},
},
}),
),
]),
boardPlayer(preview, orientation),
boardPlayer(preview, orientation, showResults),
],
);
};
Expand Down Expand Up @@ -300,12 +335,12 @@ const computeTimeLeft = (preview: ChapterPreview, color: Color): number | undefi
} else return;
};

const boardPlayer = (preview: ChapterPreview, color: Color) => {
const boardPlayer = (preview: ChapterPreview, color: Color, showResults?: boolean) => {
const outcome = preview.status && preview.status !== '*' ? preview.status : undefined;
const player = preview.players?.[color],
score = outcome?.split('-')[color === 'white' ? 0 : 1];
return h('span.mini-game__player', [
player && renderUser(player),
score ? h('span.mini-game__result', score) : renderClock(preview, color),
showResults ? (score ? h('span.mini-game__result', score) : renderClock(preview, color)) : undefined,
]);
};
5 changes: 3 additions & 2 deletions ui/analyse/src/study/relay/relayGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => {
const chapters = study.chapters.list.all();
const cloudEval = study.multiCloudEval?.thisIfShowEval();
const roundPath = relay.roundPath();
const showResults = study.multiBoard.showResults();
return h(
'div.relay-games',
{
Expand Down Expand Up @@ -45,7 +46,7 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => {
class: { 'relay-game--current': c.id === study.data.chapter.id },
},
[
cloudEval && verticalEvalGauge(c, cloudEval),
showResults ? cloudEval && verticalEvalGauge(c, cloudEval) : undefined,
h(
'span.relay-game__players',
players.map((p, i) => {
Expand All @@ -58,7 +59,7 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => {
playerFed(p.fed),
h('span.name', [userTitle(p), p.name]),
]),
h(s === '1' ? 'good' : s === '0' ? 'bad' : 'status', [s]),
showResults ? h(s === '1' ? 'good' : s === '0' ? 'bad' : 'status', [s]) : null,
]
: [h('span.mini-game__user', h('span.name', 'Unknown player'))],
);
Expand Down
4 changes: 3 additions & 1 deletion ui/analyse/src/study/studyCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ export default class StudyCtrl {
} else {
nextPath = sameChapter
? prevPath
: this.data.chapter.relayPath || this.chapters.localPaths[this.vm.chapterId] || treePath.root;
: this.relay && !this.multiBoard.showResults()
? treePath.root
: this.data.chapter.relayPath || this.chapters.localPaths[this.vm.chapterId] || treePath.root;
}

// path could be gone (because of subtree deletion), go as far as possible
Expand Down
Loading