aboutsummaryrefslogtreecommitdiff
path: root/xP/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-10 17:37:19 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-10 17:38:33 +0200
commit632ac992ab4a032a3415b99a419c0c88c22157e5 (patch)
tree3ded5c5a26320d1f460d64946150d77b44479478 /xP/public
parentd29e2cbfe82197319ab66ace6837bd3c1763dbad (diff)
downloadxK-632ac992ab4a032a3415b99a419c0c88c22157e5.tar.gz
xK-632ac992ab4a032a3415b99a419c0c88c22157e5.tar.xz
xK-632ac992ab4a032a3415b99a419c0c88c22157e5.zip
xC/xP: only send buffer stats in the initial sync
The client and frontends track these separately, there is no need for hard synchronization.
Diffstat (limited to 'xP/public')
-rw-r--r--xP/public/xP.js31
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