all repos — underbbs @ 7a2eb99eb6d60d23c034f6255d5b52aea08e24d5

decentralized social media client

don't add redundant IDs to batch timers, close data channel properly
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZsfqnQAKCRBohAcXSWbK
832pAP4yzlMYKwh/UvOR37ffZ/2FczVnErgBHUd4N846BJqhHwD9G1RS6+KpJFTS
Z94xRXr5q59Q+Tq2861C9XzzSstNSAI=
=TQKQ
-----END PGP SIGNATURE-----
commit

7a2eb99eb6d60d23c034f6255d5b52aea08e24d5

parent

bb7d4e2f7d1a677d2675d7218f51e670eddb62f5

2 files changed, 8 insertions(+), 3 deletions(-)

jump to
M frontend/ts/batch-timer.tsfrontend/ts/batch-timer.ts

@@ -10,9 +10,11 @@ this._reqFn = reqFn;

} public queue(id: string, timeout: number){ - this._timer = new Date().getTime() + timeout; - this._batch.push(id); - setTimeout(this.checkBatch.bind(this), timeout); + if (!this._batch.includes(id)) { + this._timer = new Date().getTime() + timeout; + this._batch.push(id); + setTimeout(this.checkBatch.bind(this), timeout); + } } private checkBatch() {
M server/server.goserver/server.go

@@ -98,6 +98,7 @@ writeTimeout(ctx, time.Second*5, c, msg)

case <-ctx.Done(): fmt.Println("subscriber has disconnected") + close(s.data) return //ctx.Err() } }

@@ -108,6 +109,8 @@ s.msgs <- []byte("{ \"key\":\"" + s.key + "\" }")

// block on the data channel, serializing and passing the data to the subscriber listen([]chan models.SocketData{s.data}, s.msgs) + + fmt.Println("data listener is done!") if errors.Is(err, context.Canceled) { return