Skip to content

Commit

Permalink
release: 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
i007c committed Oct 13, 2024
1 parent 3c6fa5e commit 60ebda1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.2
0.2.3
19 changes: 6 additions & 13 deletions app/pages/dash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default () => {
timer: number
online: boolean
now: number
focus: boolean
act(): void
}
const [state, setState] = createStore<State>({
Expand All @@ -29,32 +28,26 @@ export default () => {
socket_status: 'offline',
online: false,
timer: 5,
focus: true,
now: 0,
act() {
if (!this.focus) return
if (this.online) {
if (!this.socket || this.socket.readyState != WebSocket.OPEN) {
return connect()
}
} else return
if (!state.socket || state.socket.readyState != WebSocket.OPEN) {
connect()
}

Object.values(state.sites)
.filter(site => site.online)
.forEach(site => this.socket.send(site.id.toString()))
.forEach(site => state.socket.send(site.id.toString()))
},
})

onMount(() => {
window.onfocus = () => setState({ focus: true })
window.onblur = () => setState({ focus: false })
window.onfocus = () => setState({ timer: 0 })

setState(
produce(s => {
setInterval(() => {
s.now = ~~(new Date().getTime() / 1e3)
if (!s.socket || s.socket.readyState != WebSocket.OPEN)
return
if (!s.online) return
if (s.timer <= 0) {
s.act()
s.timer = 5
Expand Down

0 comments on commit 60ebda1

Please sign in to comment.