From 632ac992ab4a032a3415b99a419c0c88c22157e5 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 10 Sep 2022 17:37:19 +0200 Subject: xC/xP: only send buffer stats in the initial sync The client and frontends track these separately, there is no need for hard synchronization. --- xP/public/xP.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'xP') diff --git a/xP/public/xP.js b/xP/public/xP.js index 8820b69..7f64473 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -136,6 +136,12 @@ let bufferCurrent = undefined let bufferLog = undefined let bufferAutoscroll = true +function resetBufferStats(b) { + b.newMessages = 0 + b.newUnimportantMessages = 0 + b.highlighted = false +} + let connecting = true rpc.connect().then(result => { buffers.clear() @@ -162,15 +168,21 @@ rpc.addEventListener('Ping', event => { rpc.addEventListener('BufferUpdate', event => { let e = event.detail, b = buffers.get(e.bufferName) if (b === undefined) { - buffers.set(e.bufferName, { - lines: [], - newMessages: e.newMessages, - newUnimportantMessages: e.newUnimportantMessages, - highlighted: e.highlighted, - }) + buffers.set(e.bufferName, (b = {lines: []})) + resetBufferStats(b) } }) +rpc.addEventListener('BufferStats', event => { + let e = event.detail, b = buffers.get(e.bufferName) + if (b === undefined) + return + + b.newMessages = e.newMessages, + b.newUnimportantMessages = e.newUnimportantMessages + b.highlighted = e.highlighted +}) + rpc.addEventListener('BufferRename', event => { let e = event.detail buffers.set(e.new, buffers.get(e.bufferName)) @@ -184,11 +196,8 @@ rpc.addEventListener('BufferRemove', event => { rpc.addEventListener('BufferActivate', event => { let old = buffers.get(bufferCurrent) - if (old !== undefined) { - old.newMessages = 0 - old.newUnimportantMessages = 0 - old.highlighted = false - } + if (old !== undefined) + resetBufferStats(old) let e = event.detail, b = buffers.get(e.bufferName) bufferCurrent = e.bufferName -- cgit v1.2.3-70-g09d2