Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lichess-org/lila
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 17, 2024
2 parents 3051128 + 64904c1 commit dac363a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/core/src/main/userId.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ object userId:
given Conversion[Option[UserName], Option[UserStr]] = _.map(_.value)
given Conversion[UserId, UserStr] = _.value
def read(str: String): Option[UserStr] =
val clean = str.trim.takeWhile(' ' !=)
Option.when(UserName.historicalRegex.matches(clean))(UserStr(clean))
val trimmed = str.trim
Option.when(UserName.historicalRegex.matches(trimmed))(UserStr(trimmed))

// the prefix, or entirety, of a user name.
// "chess-" is a valid username prefix, but not a valid username
Expand Down
2 changes: 1 addition & 1 deletion modules/web/src/main/ui/help.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ object help:
row(voice("blindfold"), "Toggle blindfold mode"),
row(voice("clock"), "Read out clocks"),
row(voice("pieces"), "Read out pieces"),
row(voice("white pieces"), "Read out white pieces"),
row(voice("white-pieces"), "Read out white pieces"),
row(voice("next"), trans.puzzle.nextPuzzle()),
row(voice("upvote"), trans.puzzle.upVote()),
row(voice("solve"), showPuzzleSolution()),
Expand Down
9 changes: 7 additions & 2 deletions ui/voice/src/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function makeVoice(opts: {
tpe: 'move' | 'coords';
}): VoiceCtrl {
let keyupTimeout: number;
let shiftDown = false;
const mic = new Mic();
const enabled = storedBooleanProp('voice.on', false);
const showHelp = propWithEffect<boolean | 'list'>(false, opts.redraw);
Expand All @@ -57,15 +58,19 @@ export function makeVoice(opts: {
mic.setLang(lang());

document.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.key !== 'Shift') return;
if (e.key !== 'Shift' || shiftDown) return;
const start = mic.isListening || pushTalk();
shiftDown = true;
mic.stop();
window.speechSynthesis.cancel();
if (start) mic.start();
clearTimeout(keyupTimeout);
});

document.addEventListener('keyup', (e: KeyboardEvent) => {
if (e.key !== 'Shift' || !pushTalk()) return;
if (e.key !== 'Shift') return;
shiftDown = false;
if (!pushTalk()) return;
clearTimeout(keyupTimeout);
keyupTimeout = setTimeout(() => mic.stop(), 600);
});
Expand Down

0 comments on commit dac363a

Please sign in to comment.