From b5d0885c23670542c248c6fdbf4d18b206f955d8 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 30 Sep 2023 14:53:43 -0700 Subject: [PATCH] Compact-style message display options --- src/App.vue | 42 ++++++++- src/components/MessageBox.vue | 162 +++++++++++++++++++++++++++++++++- src/lib/LocalStorage.js | 20 ++--- 3 files changed, 208 insertions(+), 16 deletions(-) diff --git a/src/App.vue b/src/App.vue index 49f59b0..49f6401 100644 --- a/src/App.vue +++ b/src/App.vue @@ -80,6 +80,11 @@ export default { ["x3", "3x larger chat room text"], ["x4", "4x larger chat room text"], ], + messageStyleSettings: [ + ["cards", "Card style (default)"], + ["compact", "Compact style (with display names)"], + ["compact2", "Compact style (usernames only)"], + ], imageDisplaySettings: [ ["show", "Always show images in chat"], ["collapse", "Collapse images in chat, clicking to expand (default)"], @@ -229,6 +234,7 @@ export default { historyScrollbox: null, autoscroll: true, // scroll to bottom on new messages fontSizeClass: "", // font size magnification + messageStyle: "cards", // message display style imageDisplaySetting: "collapse", // image show/hide setting scrollback: 1000, // scrollback buffer (messages to keep per channel) DMs: {}, @@ -361,6 +367,9 @@ export default { // Store the setting persistently. LocalStorage.set('fontSizeClass', this.fontSizeClass); }, + messageStyle() { + LocalStorage.set('messageStyle', this.messageStyle); + }, imageDisplaySetting() { LocalStorage.set('imageDisplaySetting', this.imageDisplaySetting); }, @@ -675,6 +684,10 @@ export default { this.fontSizeClass = settings.fontSizeClass; } + if (settings.messageStyle != undefined) { + this.messageStyle = settings.messageStyle; + } + if (settings.videoScale != undefined) { this.webcam.videoScale = settings.videoScale; } @@ -2896,6 +2909,25 @@ export default { +
+
+ +
+
+
+
+
+ +
+
+
+
+
+
@@ -3599,7 +3631,9 @@ export default {
-->
-
+
+ + + {{ prettyDate(msg.at) }} + + {{ nicknameForUsername(msg.username) }} (offline) (@{{ msg.username }}) @@ -3656,6 +3695,7 @@ export default { 0; }, + + // Compactify a message (remove paragraph breaks added by Markdown renderer) + compactMessage() { + return this.message.message.replace(/<\/p>\s*

/g, "

").replace(/<\/?p>/g, ""); + } }, methods: { openProfile() { @@ -154,12 +163,20 @@ export default { let hour = hours % 12 || 12; return `${(hour)}:${minutes} ${ampm}`; }, + + prettyDateCompact(date) { + if (date == undefined) return ''; + let hour = date.getHours(), + minutes = String(date.getMinutes()).padStart(2, '0'); + return `${hour}:${minutes}`; + }, } }