use singular if visitor count == 1. closes #34

This commit is contained in:
Danny van Kooten 2018-05-21 11:37:12 +02:00
parent 4806de98fe
commit 72c2952e15
1 changed files with 8 additions and 1 deletions

View File

@ -23,12 +23,19 @@ class Realtime extends Component {
clearInterval(this.interval);
}
@bind
setDocumentTitle() {
// update document title
let visitorText = this.state.count == 1 ? 'visitor' : 'visitors';
document.title = ( this.state.count > 0 ? `${this.state.count} current ${visitorText} — Fathom` : 'Fathom' );
}
@bind
fetchData() {
Client.request(`stats/site/realtime`)
.then((d) => {
this.setState({ count: d })
document.title = ( d > 0 ? d + ' current visitors — Fathom' : 'Fathom' );
this.setDocumentTitle();
})
.catch((e) => {
if(e.message == 401) {