Skip to content

Commit

Permalink
Translate ban message
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jun 5, 2021
1 parent b9eeba2 commit 4e4b25d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
8 changes: 1 addition & 7 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ function nowPlaying(): readonly NowPlayingGame[] {
)
}

function currentBan(): Date | undefined {
const playban = session && session.playban
return playban && new Date(playban.date + playban.mins * 60000)
}

function isKidMode(): boolean {
return !!(session && session.kid)
}
Expand Down Expand Up @@ -370,8 +365,7 @@ export default {
lichessBackedProp,
setKidMode,
confirmEmail,
currentBan,
hasCurrentBan(): boolean {
return currentBan() !== undefined
return session?.playban !== undefined
},
}
1 change: 1 addition & 0 deletions src/styl/home.styl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
line-height 2em
> p
font-size 0.9em
text-align left
> ul
list-style initial
margin-left 2em
Expand Down
35 changes: 17 additions & 18 deletions src/ui/home/homeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import socket from '../../socket'
import { openExternalBrowser } from '../../utils/browse'
import { emptyFen } from '../../utils/fen'
import { hasNetwork } from '../../utils'
import i18n, { plural, formatNumber, fromNow } from '../../i18n'
import i18n, { plural, formatNumber, distanceToNowStrict } from '../../i18n'
import session from '../../session'
import { PongMessage, CorrespondenceSeek } from '../../lichess/interfaces'
import spinner from '../../spinner'
Expand Down Expand Up @@ -55,7 +55,8 @@ function offline(ctrl: HomeCtrl) {
}

function online(ctrl: HomeCtrl) {
const playbanEndsAt = session.currentBan()
const playban = session.get()?.playban
const playbanEndsAt = playban && new Date(playban.date + playban.mins * 60000)

return (
<div className="home">
Expand Down Expand Up @@ -350,31 +351,29 @@ function renderTimeline(ctrl: HomeCtrl) {
}

function renderPlayban(endsAt: Date) {
const seconds = (endsAt.valueOf() - Date.now()) / 1000
return (
<div className="home-playbanInfo">
<h2>Sorry :(</h2>
<p>We had to time you out for a {seconds < 3600 ? 'little ' : ''}while.</p>
<h2>{i18n('sorry')}</h2>
<p>{i18n('weHadToTimeYouOutForAWhile')}</p>
<br />
<p>The timeout expires <strong>{fromNow(endsAt)}</strong>.</p>
<h2>Why?</h2>
<p>{h.trust(i18n('timeoutExpires', `<strong>${distanceToNowStrict(endsAt)}</strong>`))}</p>
<h2>{i18n('why')}</h2>
<p>
We aim to provide a pleasant chess experience for everyone.
To that effect, we must ensure that all players follow good practices.
When a potential problem is detected, we display this message.
{i18n('pleasantChessExperience')}<br />
{i18n('goodPractice')}<br />
{i18n('potentialProblem')}
</p>
<h2>How to avoid this?</h2>
<h2>{i18n('howToAvoidThis')}</h2>
<ul>
<li>Play every game you start</li>
<li>Try to win (or at least draw) every game you play</li>
<li>Resign lost games (don't let the clock run down)</li>
<li>{i18n('playEveryGame')}</li>
<li>{i18n('tryToWin')}</li>
<li>{i18n('resignLostGames')}</li>
</ul>
<br />
<br />
<p>
We apologize for the temporary inconvenience,<br />
and wish you great games on lichess.org.<br />
Thank you for reading!
{i18n('temporaryInconvenience')}<br />
{i18n('wishYouGreatGames')}<br />
{i18n('thankYouForReading')}
</p>
</div>
)
Expand Down

0 comments on commit 4e4b25d

Please sign in to comment.