From ee6960dac5c11641cb1568643782158d85f15f59 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 15 Mar 2021 21:57:54 -0300 Subject: combining log messages (currently only seek!) --- socket.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'socket.js') diff --git a/socket.js b/socket.js index f70b95f..c1e4869 100644 --- a/socket.js +++ b/socket.js @@ -419,9 +419,19 @@ export function attachBackendToSocketClient(backend, client, { function logCommand(command) { const nickToMessage = nickname => `\x1b[32;1m${nickname}\x1b[0m` const itemToMessage = item => `\x1b[32m"${item.name}"\x1b[0m` + let senderNickname = command.sender === 'server' ? 'the server' : command.senderNickname + // TODO: This should use a unique sender ID, provided by the server and + // corresponding to the socket. This could be implemented into the UI! + // But also, right now users can totally pretend to be the server by... + // setting their nickname to "the server", which is silly. + const sender = senderNickname + let actionmsg = `sent ${command.code} (no action message specified)` + let code = command.code + let mayCombine = false let isVerbose = false + switch (command.code) { case 'clear-queue': actionmsg = 'cleared the queue' @@ -459,6 +469,7 @@ export function attachBackendToSocketClient(backend, client, { // TODO: the second value here should be the duration of the track // (this will make values like 0:0x:yy / 1:xx:yy appear correctly) actionmsg = `seeked to ${getTimeStringsFromSec(command.time, command.time).timeDone}` + mayCombine = true break case 'set-nickname': actionmsg = `updated their nickname (from ${nickToMessage(command.oldNickname)})` @@ -496,7 +507,13 @@ export function attachBackendToSocketClient(backend, client, { break } const text = `${nickToMessage(senderNickname)} ${actionmsg}` - backend.showLogMessage(text, isVerbose) + backend.showLogMessage({ + text, + code, + sender, + mayCombine, + isVerbose + }) } client.on('sent-command', command => { -- cgit 1.3.0-6-gf8a5