From 50d7aea39df46f709f99efb4bb41ba838acce941 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 11 Jun 2023 20:33:26 -0700 Subject: [PATCH] Chat style updates --- web/static/css/bulma-prefers-dark.css | 5 + web/static/js/BareRTC.js | 31 +++-- web/templates/chat.html | 191 +++++++++++++++----------- 3 files changed, 134 insertions(+), 93 deletions(-) diff --git a/web/static/css/bulma-prefers-dark.css b/web/static/css/bulma-prefers-dark.css index bd36ab0..39f9e93 100644 --- a/web/static/css/bulma-prefers-dark.css +++ b/web/static/css/bulma-prefers-dark.css @@ -33,6 +33,11 @@ background-color: rgba(0, 0, 0, 0.86) !important; } + .notification.is-success.is-light { + background-color: #232e29 !important; + color: #56cf98 !important; + } + /* end nonshy custom overrides */ html { diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index eabebd3..3449975 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -215,6 +215,9 @@ const app = Vue.createApp({ window.addEventListener("click", () => { this.setupSounds(); }); + window.addEventListener("keydown", () => { + this.setupSounds(); + }); for (let channel of this.config.channels) { this.initHistory(channel.ID); @@ -488,25 +491,29 @@ const app = Vue.createApp({ // User logged in or out. onPresence(msg) { // TODO: make a dedicated leave event + let isLeave = false; if (msg.message.indexOf("has exited the room!") > -1) { // Clean up data about this user. this.onUserExited(msg); this.playSound("Leave"); + isLeave = true; } else { this.playSound("Enter"); } - // Push it to the history of all public channels. - for (let channel of this.config.channels) { - this.pushHistory({ - channel: channel.ID, - action: msg.action, - username: msg.username, - message: msg.message, - }); + // Push it to the history of all public channels (not leaves). + if (!isLeave) { + for (let channel of this.config.channels) { + this.pushHistory({ + channel: channel.ID, + action: msg.action, + username: msg.username, + message: msg.message, + }); + } } - // Push also to any DM channels for this user. + // Push also to any DM channels for this user (leave events do push to DM thread for visibility). let channel = "@" + msg.username; if (this.channels[channel] != undefined) { this.pushHistory({ @@ -896,6 +903,9 @@ const app = Vue.createApp({ if (nick) { return nick; } + } else if (this.whoMap[username] == undefined && username !== 'ChatServer' && username !== 'ChatClient') { + // User is not even logged in! Add this note to their name + username += " (offline)"; } return username; }, @@ -1468,6 +1478,9 @@ const app = Vue.createApp({ // allow it to set up the AudioContext. If we've successfully set one up before, exit // this function immediately. if (this.config.sounds.audioContext) { + if (this.config.sounds.audioContext.state === 'suspended') { + this.config.sounds.audioContext.resume(); + } return; } diff --git a/web/templates/chat.html b/web/templates/chat.html index b6ddf74..b367714 100644 --- a/web/templates/chat.html +++ b/web/templates/chat.html @@ -5,7 +5,7 @@ - + {{.Config.Title}} @@ -733,97 +733,120 @@ -
-
-
- -
- - - + +
+ + +
+ -
-
-
- -
-
- [[prettyDate(msg.at)]] -
- - -
-
- - - @[[msg.username]] - - @[[msg.username]] - - internal -
-
-
-
- - - @[[msg.username]] - - @[[msg.username]] - - internal -
- -
- - -
-
- - -
+
+ [[ msg.username ]] [[msg.message]]
+
- -
- [[msg.message]] -
+ +
+
+ +
+
+
+ +
+
+ [[prettyDate(msg.at)]] +
+
+ + +
+
+ + + @[[msg.username]] + + @[[msg.username]] + + internal +
+
+
+
+ + + @[[msg.username]] + + @[[msg.username]] + + internal +
+ +
+ + +
+
+ + +
+
+
+
+ + +
+ [[msg.message]] +
+
+