Merge branch 'master' into miniboard-clock

* master:
  update moves tag
  update index tag
  keep the Lichess user online
  fix resign confirmation when keyboard moves are enabled
miniboard-clock
Thibault Duplessis 2020-08-17 11:24:22 +02:00
commit e804e86100
11 changed files with 29 additions and 27 deletions

View File

@ -7,6 +7,7 @@ import play.api.{ Configuration, Mode }
import scala.concurrent.duration._
import lila.common.config._
import lila.user.User
@Module
final class Env(
@ -41,6 +42,7 @@ final class Env(
swissEnv: lila.swiss.Env,
onlineApiUsers: lila.bot.OnlineApiUsers,
challengeEnv: lila.challenge.Env,
socketEnv: lila.socket.Env,
msgEnv: lila.msg.Env,
cacheApi: lila.memo.CacheApi,
mongoCacheApi: lila.memo.MongoCache.Api,
@ -83,7 +85,10 @@ final class Env(
)
if (mode == Mode.Prod) system.scheduler.scheduleOnce(5 seconds)(influxEvent.start())
system.scheduler.scheduleWithFixedDelay(20 seconds, 10 seconds) { () =>
system.scheduler.scheduleWithFixedDelay(1 minute, 1 minute) { () =>
lila.mon.bus.classifiers.update(lila.common.Bus.size)
// ensure the Lichess user is online
socketEnv.remoteSocket.onlineUserIds.getAndUpdate(_ + User.lichessId)
userEnv.repo.setSeenAt(User.lichessId)
}
}

View File

@ -49,9 +49,9 @@ final class RemoteSocket(
val baseHandler: Handler = {
case In.ConnectUser(userId) =>
onlineUserIds.getAndUpdate((x: UserIds) => x + userId)
onlineUserIds.getAndUpdate(_ + userId)
case In.DisconnectUsers(userIds) =>
onlineUserIds.getAndUpdate((x: UserIds) => x -- userIds)
onlineUserIds.getAndUpdate(_ -- userIds)
case In.NotifiedBatch(userIds) => notification ! lila.hub.actorApi.notify.NotifiedBatch(userIds)
case In.Lags(lags) =>
lags foreach (UserLagCache.put _).tupled

View File

@ -102,7 +102,7 @@
.rmoves {
margin-bottom: 1px;
.moves {
#{$moves-tag} {
display: none;
background: none;
}
@ -113,7 +113,7 @@
}
@include breakpoint($mq-short) {
& .rmoves .moves {
& .rmoves #{$moves-tag} {
display: flex;
}
}

View File

@ -6,6 +6,8 @@ $mq-col3: $mq-col3-uniboard;
$col1-player-clock-height: 50px;
$col1-moves-height: 2.5em;
$move-tag: "u8t";
$moves-tag: "bp0";
$index-tag: "i5z";
// app-layout
$col1-pocket-height: auto;

View File

@ -17,7 +17,7 @@
}
}
.moves {
#{$moves-tag} {
flex: 1 1 100%;
display: flex;
align-items: stretch;
@ -41,7 +41,7 @@
}
}
index,
#{$index-tag},
#{$move-tag},
.result-wrap {
display: flex;
@ -50,7 +50,7 @@
padding: 0 .3rem;
}
index {
#{$index-tag} {
padding-right: .15em;
}

View File

@ -2,7 +2,7 @@
@include breakpoint($mq-col2) {
background: $c-bg-box;
.moves {
#{$moves-tag} {
display: flex;
flex-flow: row wrap;
align-items: center;
@ -21,7 +21,7 @@
}
}
index {
#{$index-tag} {
/* Edge 18: flex: 0 0 calc(100% / 6); causes wrap */
flex: 0 0 16.666%;
display: flex;

View File

@ -22,21 +22,16 @@
text-align: center;
}
.moves,
.message {
flex: 0 0 auto;
}
.moves,
#{$moves-tag},
.message {
flex: 0 0 7.4rem;
}
.moves {
#{$moves-tag} {
@extend %zen;
}
index {
#{$index-tag} {
@extend %roboto;
}

View File

@ -23,14 +23,14 @@
.round__app {
@include breakpoint($mq-col2) {
@include breakpoint($mq-short) {
.rmoves .moves {
.rmoves #{$moves-tag} {
display: none;
}
}
@include breakpoint($mq-tall) {
.rmoves .moves {
.rmoves #{$moves-tag} {
display: flex;
}
}

View File

@ -553,9 +553,9 @@ export default class RoundController {
promotion.cancel(this);
};
resign = (v: boolean): void => {
resign = (v: boolean, immediately?: boolean): void => {
if (v) {
if (this.resignConfirm || !this.data.pref.confirmResign || this.keyboardMove) {
if (this.resignConfirm || !this.data.pref.confirmResign || immediately) {
this.socket.sendLoading('resign');
clearTimeout(this.resignConfirm);
} else {

View File

@ -24,7 +24,7 @@ window.lichess.keyboardMove = function(opts: any) {
v = v.replace(/0/g, 'O');
const foundUci = v.length >= 2 && sans && sanToUci(v, sans);
if (v == 'resign') {
opts.ctrl.resign(true);
opts.ctrl.resign(true, true);
clear();
}
else if (foundUci) {

View File

@ -10,7 +10,7 @@ import * as util from '../util';
import RoundController from '../ctrl';
import { Step, MaybeVNodes, RoundData } from '../interfaces';
const scrollMax = 99999, moveTag = 'u8t';
const scrollMax = 99999, moveTag = 'u8t', indexTag = 'i5z', indexTagUC = indexTag.toUpperCase(), movesTag = 'bp0';
const autoScroll = throttle(100, (movesEl: HTMLElement, ctrl: RoundController) =>
window.requestAnimationFrame(() => {
@ -84,7 +84,7 @@ function renderMoves(ctrl: RoundController): MaybeVNodes {
const els: MaybeVNodes = [], curPly = ctrl.ply;
for (let i = 0; i < pairs.length; i++) {
els.push(h('index', i + 1 + ''));
els.push(h(indexTag, i + 1 + ''));
els.push(renderMove(pairs[i][0], curPly, true));
els.push(renderMove(pairs[i][1], curPly, false));
}
@ -183,14 +183,14 @@ function col1Button(ctrl: RoundController, dir: number, icon: string, disabled:
export function render(ctrl: RoundController): VNode | undefined {
const d = ctrl.data,
col1 = window.lichess.isCol1(),
moves = ctrl.replayEnabledByPref() && h('div.moves', {
moves = ctrl.replayEnabledByPref() && h(movesTag, {
hook: util.onInsert(el => {
el.addEventListener('mousedown', e => {
let node = e.target as HTMLElement, offset = -2;
if (node.tagName !== moveTag.toUpperCase()) return;
while(node = node.previousSibling as HTMLElement) {
offset++;
if (node.tagName === 'INDEX') {
if (node.tagName === indexTagUC) {
ctrl.userJump(2 * parseInt(node.textContent || '') + offset);
ctrl.redraw();
break;