diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-03-15 21:32:30 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-03-15 21:32:30 -0300 |
commit | 609690e36a57fb7f6a1f272ede80e3714237c1e4 (patch) | |
tree | 8319142a7ed2518cd01765a2037509748c2199ae | |
parent | 53de9a079bcc91012be72518b58e5621019b3697 (diff) |
log 'status' commands as new "verbose" (dim) lines
-rw-r--r-- | backend.js | 4 | ||||
-rw-r--r-- | socket.js | 22 | ||||
-rw-r--r-- | ui.js | 23 |
3 files changed, 37 insertions, 12 deletions
diff --git a/backend.js b/backend.js index d222d10..205aad3 100644 --- a/backend.js +++ b/backend.js @@ -853,8 +853,8 @@ class Backend extends EventEmitter { return download(item, this.getRecordFor(item)) } - showLogMessage(text) { - this.emit('log message', text) + showLogMessage(text, isVerbose = false) { + this.emit('log message', text, isVerbose) } } diff --git a/socket.js b/socket.js index 284c767..69cadeb 100644 --- a/socket.js +++ b/socket.js @@ -420,7 +420,8 @@ function attachBackendToSocketClient(backend, client, { const nickToMessage = nickname => `\x1b[32;1m${nickname}\x1b[0m` const itemToMessage = item => `\x1b[32m"${item.name}"\x1b[0m` let fullmsg = '' // may be overridden - let actionmsg = `sent ${command.code}` // fallback + let actionmsg = `sent ${command.code} (no action message specified)` + let isVerbose = false switch (command.code) { case 'clear-queue': actionmsg = 'cleared the queue' @@ -476,13 +477,28 @@ function attachBackendToSocketClient(backend, client, { actionmsg = `removed ${itemToMessage(command.topItem)} from the queue` break case 'status': - return + isVerbose = true + switch (command.status) { + case 'ready-to-resume': + actionmsg = `is ready to play!` + break + case 'done-playing': + actionmsg = `has finished playing` + break + case 'sync-playback': + actionmsg = `synced playback with the server` + break + default: + actionmsg = `sent status "${command.status}"` + break + } + break } if (!fullmsg) { const nickname = command.sender === 'server' ? 'the server' : command.senderNickname fullmsg = `${nickToMessage(nickname)} ${actionmsg}` } - backend.showLogMessage(fullmsg) + backend.showLogMessage(fullmsg, isVerbose) } client.on('sent-command', command => { diff --git a/ui.js b/ui.js index 68cda91..3952c38 100644 --- a/ui.js +++ b/ui.js @@ -547,8 +547,8 @@ class AppElement extends FocusElement { } } - handleLogMessage(text) { - this.log.newLogMessage(text) + handleLogMessage(text, isVerbose) { + this.log.newLogMessage(text, isVerbose) } async handlePlayingDetails(track, oldTrack, queuePlayer) { @@ -4591,12 +4591,12 @@ class Log extends ListScrollForm { super('vertical') } - newLogMessage(text) { + newLogMessage(text, isVerbose = false) { if (this.inputs.length === 10) { this.removeInput(this.inputs[0]) } - const logMessage = new LogMessage(text) + const logMessage = new LogMessage(text, isVerbose) this.addInput(logMessage) this.fixLayout() this.scrollToEnd() @@ -4606,10 +4606,10 @@ class Log extends ListScrollForm { } class LogMessage extends FocusElement { - constructor(text) { + constructor(text, isVerbose = false) { super() - this.label = new LogMessageLabel(text) + this.label = new LogMessageLabel(text, isVerbose) this.addChild(this.label) } @@ -4628,6 +4628,12 @@ class LogMessage extends FocusElement { } class LogMessageLabel extends WrapLabel { + constructor(text, isVerbose = false) { + super(text) + + this.isVerbose = isVerbose + } + writeTextTo(writable) { const w = this.w const lines = this.getWrappedLines() @@ -4646,7 +4652,10 @@ class LogMessageLabel extends WrapLabel { set textAttributes(val) {} get textAttributes() { - return this.parent.isSelected ? [40] : [] + return [ + this.parent.isSelected ? 40 : null, + this.isVerbose ? 2 : null + ].filter(x => x !== null) } } |