From 176aad5b3c3414cd4b89cceec09e81975a5f86f5 Mon Sep 17 00:00:00 2001 From: joeyak Date: Thu, 11 Apr 2019 21:50:20 -0400 Subject: [PATCH] Change timestamps to only show on chat and action messages closes #73 --- wasm/main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wasm/main.go b/wasm/main.go index 34d45a9..e85c709 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -71,7 +71,15 @@ func recieve(v []js.Value) { // on join or leave, update list of possible user names fallthrough case common.DTChat: - appendMessage(chat.Data.HTML()) + msg := chat.Data.HTML() + if d, ok := chat.Data.(common.DataMessage); ok { + if timestamp && (d.Type == common.MsgChat || d.Type == common.MsgAction) { + h, m, _ := time.Now().Clock() + msg = fmt.Sprintf(`%02d:%02d %s`, h, m, msg) + } + } + + appendMessage(msg) case common.DTCommand: d := chat.Data.(common.DataCommand) @@ -103,10 +111,6 @@ func recieve(v []js.Value) { } func appendMessage(msg string) { - if timestamp { - h, m, _ := time.Now().Clock() - msg = fmt.Sprintf(`%02d:%02d %s`, h, m, msg) - } js.Call("appendMessages", "
"+msg+"
") }