aboutsummaryrefslogtreecommitdiff
path: root/xP/public
diff options
context:
space:
mode:
Diffstat (limited to 'xP/public')
-rw-r--r--xP/public/xP.css9
-rw-r--r--xP/public/xP.js51
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),
])
},