Sfoglia il codice sorgente

Unseen counts

master
Roderic Day 5 anni fa
parent
commit
b1329df046
2 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. +0
    -1
      pico.html
  2. +11
    -0
      pico.js

+ 0
- 1
pico.html Vedi File

@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html>
<title>PicoChat!</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="https://unpkg.com/mithril/mithril.min.js"></script>
<script src="/pico.js" defer></script>

+ 11
- 0
pico.js Vedi File

@@ -21,6 +21,17 @@ listen('post', ({detail}) => State.posts.push(detail))
listen('peerInfo', (e) => onPeerInfo(e))
const doNotLog = new Set(['login', 'post', 'peerInfo'])

/*
*
* ALERTS
*
*/
State.unseen = 0
listen('post', () => {State.unseen += !document.hasFocus(); updateTitle()})
listen('focus', () => {State.unseen = 0; updateTitle()})
const updateTitle = () => {
document.title = `Pico.Chat` + (State.unseen ? ` (${State.unseen})` : ``)
}

/*
*

Loading…
Annulla
Salva