diff options
Diffstat (limited to 'xP/public/xP.js')
-rw-r--r-- | xP/public/xP.js | 31 |
1 files changed, 20 insertions, 11 deletions
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 |