marek-saji / okupando

Single-page application with single-task focus — checking if the toilet is occupied or not. Also a pun. 🚽🐼
ISC License
2 stars 4 forks source link

Refactor client code #10

Open marek-saji opened 5 years ago

marek-saji commented 5 years ago

static/index.mjs got fat and hard to follow.

Modes of operating

Progressive enhancement FTW.

ⓐ HTML page that refreshes itself with <meta http-equiv="refresh"> :link:

Served by the server.

ⓑ HTTP Long polling :link:

When user subscribes

When we are not using web push and we see free next time

ⓒ Push :link:

We enter this mode, when user user subscribes and JS detects that client has all the features we want and we successfully get notification permission.

Note: If there are subscribed clients, clients in mode ⓐ and ⓑ may be presented with status occupied, while subscribed clients get pushed about status being free.

After user subscribes

After push is received in Service Worker

Client state