diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-11 20:46:35 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-11 21:50:08 +0200 |
commit | 96fc12bc4c852f1343a120126f1f46ac7cca447d (patch) | |
tree | ca6135f3b7b495af480f1be9e5f39527f2982427 /xP | |
parent | 1493d9998bb526e6f13bd5de37ec4f790b3592b8 (diff) | |
download | xK-96fc12bc4c852f1343a120126f1f46ac7cca447d.tar.gz xK-96fc12bc4c852f1343a120126f1f46ac7cca447d.tar.xz xK-96fc12bc4c852f1343a120126f1f46ac7cca447d.zip |
xC/xP: send buffer type and server state
Also make PM highlighting behaviour consistent.
Diffstat (limited to 'xP')
-rw-r--r-- | xP/public/xP.css | 9 | ||||
-rw-r--r-- | xP/public/xP.js | 51 |
2 files changed, 51 insertions, 9 deletions
diff --git a/xP/public/xP.css b/xP/public/xP.css index 71bf602..b4ce13c 100644 --- a/xP/public/xP.css +++ b/xP/public/xP.css @@ -17,6 +17,10 @@ body { padding: .05em .3em; background: #eee; + display: flex; + justify-content: space-between; + align-items: baseline; + position: relative; border-top: 3px solid #ccc; border-bottom: 2px solid #888; @@ -39,11 +43,6 @@ body { bottom: -1px; background: #ccc; } -.title { - display: flex; - justify-content: space-between; - align-items: baseline; -} .middle { flex: auto; diff --git a/xP/public/xP.js b/xP/public/xP.js index ea4b288..ced93e9 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -193,6 +193,8 @@ let bufferCurrent = undefined let bufferLog = undefined let bufferAutoscroll = true +let servers = new Map() + function bufferResetStats(b) { b.newMessages = 0 b.newUnimportantMessages = 0 @@ -234,6 +236,8 @@ rpc.connect().then(result => { bufferLog = undefined bufferAutoscroll = true + servers.clear() + rpc.send({command: 'Hello', version: 1}) connecting = false m.redraw() @@ -250,6 +254,8 @@ rpc.addEventListener('Ping', event => { rpc.send({command: 'PingResponse', eventSeq: event.detail.eventSeq}) }) +// ~~~ Buffer events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + rpc.addEventListener('BufferUpdate', event => { let e = event.detail, b = buffers.get(e.bufferName) if (b === undefined) { @@ -260,7 +266,10 @@ rpc.addEventListener('BufferUpdate', event => { })) bufferResetStats(b) } + b.hideUnimportant = e.hideUnimportant + b.kind = e.context.kind + b.server = servers.get(e.context.serverName) }) rpc.addEventListener('BufferStats', event => { @@ -354,8 +363,8 @@ rpc.addEventListener('BufferLine', event => { } } - // TODO: Also highlight on unseen private messages, like xC does. - if (line.isHighlight) { + if (line.isHighlight || + (!visible && b.kind === 'PrivateMessage' && !line.isUnimportant)) { beep() if (!visible) b.highlighted = true @@ -368,6 +377,26 @@ rpc.addEventListener('BufferClear', event => { b.lines.length = 0 }) +// ~~~ Server events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +rpc.addEventListener('ServerUpdate', event => { + let e = event.detail, s = servers.get(e.serverName) + if (s === undefined) + servers.set(e.serverName, (s = {})) + s.state = e.state +}) + +rpc.addEventListener('ServerRename', event => { + let e = event.detail + servers.set(e.new, servers.get(e.serverName)) + servers.delete(e.serverName) +}) + +rpc.addEventListener('ServerRemove', event => { + let e = event.detail + servers.delete(e.serverName) +}) + // --- Colours ----------------------------------------------------------------- let palette = [ @@ -614,6 +643,21 @@ let BufferContainer = { }, } +let Status = { + view: vnode => { + let b = buffers.get(bufferCurrent) + if (b === undefined) + return m('.status', {}, 'Synchronizing...') + + let status = `${bufferCurrent}` + if (b.hideUnimportant) + status += `<H>` + if (b.server !== undefined) + status += ` (${b.server.state})` + return m('.status', {}, status) + }, +} + let Input = { counter: 0, stamp: textarea => { @@ -749,8 +793,7 @@ let Main = { return m('.xP', {}, [ m('.title', {}, [`xP (${state})`, m(Toolbar)]), m('.middle', {}, [m(BufferList), m(BufferContainer)]), - // TODO: Indicate hideUnimportant. - m('.status', {}, bufferCurrent), + m(Status), m(Input), ]) }, |