Skip to content

Commit aceee42

Browse files
committed
Merge branch 'master' into replay-embed
* master: remove lila-side ws redis monitoring which we hopefully won't need anymore tweak broadcast leaderboard style fix broadcast leaderboard display TS tweak New Crowdin updates (#11264) better type ui/puzzle don't use rejected promise for redirect
2 parents bedfab7 + 414b697 commit aceee42

File tree

8 files changed

+36
-44
lines changed

8 files changed

+36
-44
lines changed

modules/common/src/main/mon.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,6 @@ object mon {
486486
def teamBulk(teamId: String) = histogram("msg.bulk.team").withTag("id", teamId)
487487
def clasBulk(clasId: String) = histogram("msg.bulk.clas").withTag("id", clasId)
488488
}
489-
object ws {
490-
val inCounter = counter("ws.in")
491-
def in(chan: String, path: String) = inCounter.withTags(Map("chan" -> chan, "path" -> path))
492-
val siteInTellSriCounter = counter("ws.in.site-in.tell-sri")
493-
def siteInTellSri(typ: String) = siteInTellSriCounter.withTag("typ", typ)
494-
val outCounter = counter("ws.out")
495-
def out(chan: String, path: String) = outCounter.withTags(Map("chan" -> chan, "path" -> path))
496-
val outSuccessHistogram = histogram("ws.out.success")
497-
def outSuccess(chan: String, path: String) =
498-
outSuccessHistogram.withTags(Map("chan" -> chan, "path" -> path))
499-
}
500489
object puzzle {
501490
object selector {
502491
object user {

modules/socket/src/main/RemoteSocket.scala

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ final class RemoteSocket(
5858
// this shouldn't be necessary... ensure that users are known to be online
5959
onlineUserIds.getAndUpdate((x: UserIds) => x ++ lags.keys).unit
6060
case In.TellSri(sri, userId, typ, msg) =>
61-
lila.mon.ws.siteInTellSri(typ).increment()
6261
Bus.publish(TellSriIn(sri.value, userId, msg), s"remoteSocketIn:$typ")
6362
case In.TellUser(userId, typ, msg) =>
6463
Bus.publish(TellUserIn(userId, msg), s"remoteSocketIn:$typ")
@@ -121,8 +120,8 @@ final class RemoteSocket(
121120
}
122121

123122
final class StoppableSender(val conn: PubSub[String, String], channel: Channel) extends Sender {
124-
def apply(msg: String): Unit = if (!stopping) monitorAndSend(channel, msg)
125-
def sticky(_id: String, msg: String): Unit = apply(msg)
123+
def apply(msg: String) = if (!stopping) send(channel, msg).unit
124+
def sticky(_id: String, msg: String) = apply(msg)
126125
}
127126

128127
final class RoundRobinSender(val conn: PubSub[String, String], channel: Channel, parallelism: Int)
@@ -141,12 +140,11 @@ final class RemoteSocket(
141140

142141
private val send: Send = makeSender("site-out").apply _
143142

144-
def subscribe(channel: Channel, reader: In.Reader, monitor: Boolean = true)(handler: Handler): Funit =
143+
def subscribe(channel: Channel, reader: In.Reader)(handler: Handler): Funit =
145144
connectAndSubscribe(channel) { str =>
146145
RawMsg(str) match {
147146
case None => logger.error(s"Invalid $channel $str")
148147
case Some(msg) =>
149-
if (monitor) lila.mon.ws.in(channel, msg.path).increment()
150148
reader(msg) collect handler match {
151149
case Some(_) => // processed
152150
case None => logger.warn(s"Unhandled $channel $str")
@@ -158,11 +156,11 @@ final class RemoteSocket(
158156
handler: Handler
159157
): Funit =
160158
// subscribe to main channel
161-
subscribe(channel, reader, monitor = false)(handler) >> {
159+
subscribe(channel, reader)(handler) >> {
162160
// and subscribe to subchannels
163161
(0 to parallelism)
164162
.map { index =>
165-
subscribe(s"$channel:$index", reader, monitor = false)(handler)
163+
subscribe(s"$channel:$index", reader)(handler)
166164
}
167165
.sequenceFu
168166
.void
@@ -208,18 +206,7 @@ object RemoteSocket {
208206
def sticky(_id: String, msg: String): Unit
209207

210208
protected val conn: PubSub[String, String]
211-
protected def monitorAndSend(channel: Channel, msg: String) = {
212-
val path = msg.takeWhile(' ' !=)
213-
lila.mon.ws.out(channel, path).increment()
214-
conn.async
215-
.publish(channel, msg)
216-
.thenApply {
217-
new java.util.function.Function[java.lang.Long, Unit] {
218-
def apply(clients: java.lang.Long) = lila.mon.ws.outSuccess(channel, path).record(clients).unit
219-
}
220-
}
221-
.unit
222-
}
209+
protected def send(channel: Channel, msg: String) = conn.async.publish(channel, msg)
223210
}
224211

225212
object Protocol {

translation/dest/keyboardMove/hy-AM.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<string name="dropARookAtB4">Նավակը տեղափոխել b4 (Crazyhouse տարբերակում)</string>
1111
<string name="offerOrAcceptDraw">Առաջարկել կամ ընդունել ոչ-ոքի</string>
1212
<string name="readOutClocks">Իմանալ ժամացույցի ժամանակը</string>
13+
<string name="readOutOpponentName" comment="readOutOpponentName&#10;&#10;Press a button on the keyboard to hear the opponent's name aloud.">Արտաբերել մրցակցի անունը</string>
1314
<string name="otherCommands">Այլ հրահանգներ</string>
1415
<string name="tips">Խորհուրդներ</string>
1516
<string name="ifTheAboveMoveNotationIsUnfamiliar">Եթե վերը թվարկված քայլերն անհասկանալի են, դրանք ուսումնասիրեք այստեղ.</string>

translation/dest/puzzleTheme/vi-VN.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@
121121
<string name="zugzwangDescription">Đối phương bị giới hạn các nước mà họ có thể đi và tất cả các nước đi ấy đều hại họ.</string>
122122
<string name="healthyMix">Một sự kết hợp nhẹ nhàng</string>
123123
<string name="healthyMixDescription">Mỗi thứ một chút. Bạn không biết phải chờ đợi gì cả, vậy nên bạn sẽ sẵn sàng cho mọi thứ! Như một ván cờ thật vậy.</string>
124+
<string name="playerGames">Các ván đấu của những người chơi</string>
124125
</resources>

ui/analyse/css/study/relay/_tour.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
&:nth-child(3) {
5151
font-weight: bold;
5252
}
53-
&:nth-child(4) {
54-
// width: 2ch;
53+
&:last-child {
54+
padding-#{$end-direction}: 1.5em;
5555
}
5656
}
5757
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ const leaderboard = (players: LeadPlayer[]): VNode => {
6666
players.map(player =>
6767
h('tr', [
6868
h('th', player.name),
69-
h('td', player.rating),
70-
withRating ? h('td', player.score) : undefined,
69+
withRating ? h('td', player.rating) : undefined,
70+
h('td', player.score),
7171
h('td', player.played),
7272
])
7373
)

ui/puzzle/src/ctrl.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import * as speech from './speech';
22
import * as xhr from './xhr';
33
import computeAutoShapes from './autoShape';
44
import keyboard from './keyboard';
5-
import { PromotionCtrl } from 'chess/promotion';
65
import moveTest from './moveTest';
76
import PuzzleSession from './session';
87
import PuzzleStreak from './streak';
98
import throttle from 'common/throttle';
9+
import {
10+
Redraw,
11+
Vm,
12+
Controller,
13+
PuzzleOpts,
14+
PuzzleData,
15+
MoveTest,
16+
ThemeKey,
17+
NvuiPlugin,
18+
ReplayEnd,
19+
} from './interfaces';
1020
import { Api as CgApi } from 'chessground/api';
1121
import { build as treeBuild, ops as treeOps, path as treePath, TreeWrapper } from 'tree';
1222
import { Chess, normalizeMove } from 'chessops/chess';
@@ -20,7 +30,7 @@ import { makeSanAndPlay } from 'chessops/san';
2030
import { parseFen, makeFen } from 'chessops/fen';
2131
import { parseSquare, parseUci, makeSquare, makeUci, opposite } from 'chessops/util';
2232
import { pgnToTree, mergeSolution } from './moveTree';
23-
import { Redraw, Vm, Controller, PuzzleOpts, PuzzleData, MoveTest, ThemeKey, NvuiPlugin } from './interfaces';
33+
import { PromotionCtrl } from 'chess/promotion';
2434
import { Role, Move, Outcome } from 'chessops/types';
2535
import { storedBooleanProp } from 'common/storage';
2636
import { fromNodeList } from 'tree/dist/path';
@@ -325,28 +335,30 @@ export default function (opts: PuzzleOpts, redraw: Redraw): Controller {
325335
if (res.round?.ratingDiff) session.setRatingDiff(data.puzzle.id, res.round.ratingDiff);
326336
}
327337
if (win) speech.success();
328-
if (res.replayComplete) vm.next.reject('replay complete');
329-
else vm.next.resolve(res.next);
338+
vm.next.resolve(data.replay && res.replayComplete ? data.replay : res.next);
330339
if (streak && win) streak.onComplete(true, res.next);
331340
redraw();
332341
}
333342

343+
const isPuzzleData = (d: PuzzleData | ReplayEnd): d is PuzzleData => 'puzzle' in d;
344+
334345
function nextPuzzle(): void {
335346
if (streak && vm.lastFeedback != 'win') return;
336347

337348
ceval.stop();
338-
vm.next.promise.then(initiate).then(redraw).catch(redirectToDashboard);
349+
vm.next.promise.then(n => {
350+
if (isPuzzleData(n)) {
351+
initiate(n);
352+
redraw();
353+
} else lichess.redirect(`/training/dashboard/${n.days}`);
354+
});
339355

340356
if (!streak && !data.replay) {
341357
const path = `/training/${data.angle.key}`;
342358
if (location.pathname != path) history.replaceState(null, '', path);
343359
}
344360
}
345361

346-
function redirectToDashboard() {
347-
if (data.replay) lichess.redirect(`/training/dashboard/${data.replay.days}`);
348-
}
349-
350362
function instanciateCeval(): void {
351363
if (ceval) ceval.destroy();
352364
ceval = cevalCtrl({

ui/puzzle/src/interfaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export interface NvuiPlugin {
8888
render(ctrl: Controller): VNode;
8989
}
9090

91+
export type ReplayEnd = PuzzleReplay;
92+
9193
export interface Vm {
9294
path: Tree.Path;
9395
nodeList: Tree.Node[];
@@ -96,7 +98,7 @@ export interface Vm {
9698
pov: Color;
9799
mode: 'play' | 'view' | 'try';
98100
round?: PuzzleRound;
99-
next: Deferred<PuzzleData>;
101+
next: Deferred<PuzzleData | ReplayEnd>;
100102
justPlayed?: Key;
101103
resultSent: boolean;
102104
lastFeedback: 'init' | 'fail' | 'win' | 'good' | 'retry';

0 commit comments

Comments
 (0)