From cf4339215e48ab847bf56017d3dcde8adeaeb3ba Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 01:45:43 -0500 Subject: [PATCH 1/6] Fixed spacing issue when compact mode is disabled Signed-off-by: Armored Dragon --- applications/armored-chat/index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/applications/armored-chat/index.html b/applications/armored-chat/index.html index 4d43bb3..9d2cd12 100644 --- a/applications/armored-chat/index.html +++ b/applications/armored-chat/index.html @@ -264,8 +264,10 @@
[NAME]
[TIMESTAMP]
-
[EMBEDS]
-
[CONTENT]
+
+
[EMBEDS]
+
[CONTENT]
+
From a883ec3c96d608cd891f8b0f77434f1cf467bf88 Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 02:01:41 -0500 Subject: [PATCH 2/6] Fix overflow & underflow issues in compact mode. Minor cleanup. Signed-off-by: Armored Dragon --- applications/armored-chat/index.css | 2 ++ applications/armored-chat/index.scss | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/armored-chat/index.css b/applications/armored-chat/index.css index 24d86e3..9cb556c 100644 --- a/applications/armored-chat/index.css +++ b/applications/armored-chat/index.css @@ -99,6 +99,8 @@ body .page .content.message-list .message .body .image-container img { } body .page .content.message-list .message .embeds { width: 100%; + word-wrap: anywhere; + overflow-x: hidden; overflow-x: hidden; } body .page .content.message-list .message .embeds a { diff --git a/applications/armored-chat/index.scss b/applications/armored-chat/index.scss index 2a01da4..1e7119d 100644 --- a/applications/armored-chat/index.scss +++ b/applications/armored-chat/index.scss @@ -107,15 +107,14 @@ body { img { width: auto; height: 100%; - - // max-width: 400px; - // max-height: 300px; } } } .embeds { width: 100%; + word-wrap: anywhere; + overflow-x: hidden; overflow-x: hidden; a { @@ -128,8 +127,6 @@ body { max-height: 300px; img { - // width: auto; - // height: 100%; max-width: 400px; max-height: 300px; } From 12d0f4e78bb53fefd0c413afc70483fb805c215a Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 04:03:22 -0500 Subject: [PATCH 3/6] Erase history + Set maximum history length Signed-off-by: Armored Dragon --- applications/armored-chat/armored_chat.js | 17 ++++++++++++----- applications/armored-chat/index.css | 12 ++++++++++-- applications/armored-chat/index.html | 22 ++++++++++++++++++++++ applications/armored-chat/index.scss | 17 +++++++++++++++-- 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/applications/armored-chat/armored_chat.js b/applications/armored-chat/armored_chat.js index d750dad..99cd0c1 100644 --- a/applications/armored-chat/armored_chat.js +++ b/applications/armored-chat/armored_chat.js @@ -147,15 +147,24 @@ switch (parsed.setting_name) { case "external_window": - console.log(parsed.setting_value); chat_overlay_window.presentationMode = parsed.setting_value ? Desktop.PresentationMode.NATIVE : Desktop.PresentationMode.VIRTUAL; break; + case "max_history": + let new_history = message_history.splice(0, message_history.length - settings.max_history); + Settings.setValue("ArmoredChat-Messages", new_history); + break; } break; case "initialized": _loadSettings(); break; + case "action": + switch (parsed.action) { + case "clear_history": + Settings.setValue("ArmoredChat-Messages", []); + break; + } } } // @@ -205,10 +214,9 @@ ); } function _loadSettings() { - console.log("Loading config"); settings = Settings.getValue("ArmoredChat-Config", settings); - console.log("\nSettings follow:"); - console.log(JSON.stringify(settings, " ", 4)); + + _emitEvent({ type: "setting_update", setting_name: "max_history", setting_value: Number(settings.max_history) }); // Compact chat if (settings.compact_chat) { @@ -224,7 +232,6 @@ // Refill the history with the saved messages message_history.forEach((message) => { delete message.action; - console.log(`Prefilling ${JSON.stringify(message)}`); _emitEvent({ type: "show_message", ...message }); }); } diff --git a/applications/armored-chat/index.css b/applications/armored-chat/index.css index 9cb556c..2af882b 100644 --- a/applications/armored-chat/index.css +++ b/applications/armored-chat/index.css @@ -125,11 +125,19 @@ body .page .content.settings .setting { padding: 0.5rem 0.25rem; box-sizing: border-box; } -body .page .content.settings .setting-toggle input { +body .page .content.settings .setting input { margin: auto 0 auto auto; - width: 20px; height: 20px; } +body .page .content.settings .setting-button input { + width: 100px; +} +body .page .content.settings .setting-value input { + width: 70px; +} +body .page .content.settings .setting-toggle input { + width: 20px; +} body .page .content.settings .setting:nth-child(even) { background-color: #1a1a1a; } diff --git a/applications/armored-chat/index.html b/applications/armored-chat/index.html index 9d2cd12..9421b79 100644 --- a/applications/armored-chat/index.html +++ b/applications/armored-chat/index.html @@ -64,6 +64,14 @@ External Window +
+ Erase history + +
+
+ Max history + +
@@ -179,6 +187,16 @@ _emitEvent({ type: "setting_update", setting_name: "external_window", setting_value: external_window }); }); + qs("#erase-history").addEventListener("click", () => { + let response = confirm("Are you sure you want to erase all messages?"); + if (response) _emitEvent({ type: "action", action: "clear_history" }); + // _emitEvent({ type: "setting_update", setting_name: "max_history", setting_value: compact_mode }); + }); + + qs("#max-history").addEventListener("change", () => { + _emitEvent({ type: "setting_update", setting_name: "max_history", setting_value: qs("#max-history").value }); + }); + // TODO: Limit embeds to 3. function _showMessage(message) { var target = message.channel + "-chat"; @@ -246,6 +264,10 @@ qs("#external-window-toggle").checked = true; external_window = true; break; + + case "max_history": + qs(`#max-history`).value = message.setting_value; + break; } } diff --git a/applications/armored-chat/index.scss b/applications/armored-chat/index.scss index 1e7119d..42df092 100644 --- a/applications/armored-chat/index.scss +++ b/applications/armored-chat/index.scss @@ -146,12 +146,25 @@ body { display: flex; padding: 0.5rem 0.25rem; box-sizing: border-box; + + input{ + margin: auto 0 auto auto; + height: 20px; + } + } + .setting-button{ + input { + width: 100px; + } + } + .setting-value{ + input { + width: 70px; + } } .setting-toggle { input { - margin: auto 0 auto auto; width: 20px; - height: 20px; } } .setting:nth-child(even) { From 2e30a977e658ae4c3884fafcf3a8ddfd9ab586b4 Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 04:16:04 -0500 Subject: [PATCH 4/6] Fix timestamps not being stored in message history. Signed-off-by: Armored Dragon --- applications/armored-chat/armored_chat.js | 8 +++++++- applications/armored-chat/index.html | 15 ++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/applications/armored-chat/armored_chat.js b/applications/armored-chat/armored_chat.js index 99cd0c1..ce20eb8 100644 --- a/applications/armored-chat/armored_chat.js +++ b/applications/armored-chat/armored_chat.js @@ -111,7 +111,13 @@ // Save message to our history let saved_message = message; delete saved_message.position; - message_history.push(message); + + saved_message.timeString = new Date().toLocaleTimeString(undefined, { hour12: false }); + saved_message.dateString = new Date().toLocaleDateString(undefined, { + month: "long", + day: "numeric", + }); + message_history.push(saved_message); if (message_history.length > settings.max_history) message_history.shift(); Settings.setValue("ArmoredChat-Messages", message_history); diff --git a/applications/armored-chat/index.html b/applications/armored-chat/index.html index 9421b79..193b915 100644 --- a/applications/armored-chat/index.html +++ b/applications/armored-chat/index.html @@ -235,11 +235,16 @@ // Update template data to message data message_clone.querySelector(".name").innerText = message.displayName; - message_clone.querySelector(".timestamp").innerText = new Date().toLocaleTimeString(undefined, { hour12: false }); - message_clone.querySelector(".timestamp").title = new Date().toLocaleDateString(undefined, { - month: "long", - day: "numeric", - }); + if (!message.timeString) { + message_clone.querySelector(".timestamp").innerText = new Date().toLocaleTimeString(undefined, { hour12: false }); + message_clone.querySelector(".timestamp").title = new Date().toLocaleDateString(undefined, { + month: "long", + day: "numeric", + }); + } else { + message_clone.querySelector(".timestamp").innerText = message.timeString; + message_clone.querySelector(".timestamp").title = message.dateString; + } message_clone.querySelector(".embeds").innerHTML = message_embeds; message_clone.querySelector(".body").innerText = message.message; From 8c66ea61b8b01591fdb1168098bd5b10ef70e801 Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 04:24:11 -0500 Subject: [PATCH 5/6] Workaround for app auto-starting unexpectedly. Signed-off-by: Armored Dragon --- applications/armored-chat/armored_chat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/armored-chat/armored_chat.js b/applications/armored-chat/armored_chat.js index ce20eb8..9d441db 100644 --- a/applications/armored-chat/armored_chat.js +++ b/applications/armored-chat/armored_chat.js @@ -69,7 +69,6 @@ visible: app_is_visible, // FIXME Invalid? presentationMode: Desktop.PresentationMode.VIRTUAL, }); - chat_overlay_window.visible = app_is_visible; // The "visible" field in the Desktop.createWindow does not seem to work. Force set it to false chat_overlay_window.closed.connect(toggleMainChatWindow); chat_overlay_window.sendToQml({ url: Script.resolvePath("./index.html") }); @@ -163,6 +162,8 @@ break; case "initialized": + // https://github.com/overte-org/overte/issues/824 + chat_overlay_window.visible = app_is_visible; // The "visible" field in the Desktop.createWindow does not seem to work. Force set it to the initial state (false) _loadSettings(); break; case "action": From da4b21585ce5315109f5b9e538a00699484db2f0 Mon Sep 17 00:00:00 2001 From: Armored Dragon Date: Sun, 17 Mar 2024 04:32:57 -0500 Subject: [PATCH 6/6] Fix toolbar icons Signed-off-by: Armored Dragon --- applications/armored-chat/armored_chat.js | 3 ++- .../armored-chat/img/{icon.png => icon_black.png} | Bin applications/armored-chat/img/icon_white.png | Bin 0 -> 778 bytes applications/metadata.js | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename applications/armored-chat/img/{icon.png => icon_black.png} (100%) create mode 100644 applications/armored-chat/img/icon_white.png diff --git a/applications/armored-chat/armored_chat.js b/applications/armored-chat/armored_chat.js index 9d441db..888eb09 100644 --- a/applications/armored-chat/armored_chat.js +++ b/applications/armored-chat/armored_chat.js @@ -33,7 +33,8 @@ ac_tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); app_button = ac_tablet.addButton({ - icon: Script.resolvePath("./img/icon.png"), + icon: Script.resolvePath("./img/icon_white.png"), + activeIcon: Script.resolvePath("./img/icon_black.png"), text: "CHAT", isActive: app_is_visible, }); diff --git a/applications/armored-chat/img/icon.png b/applications/armored-chat/img/icon_black.png similarity index 100% rename from applications/armored-chat/img/icon.png rename to applications/armored-chat/img/icon_black.png diff --git a/applications/armored-chat/img/icon_white.png b/applications/armored-chat/img/icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..e29bf9970640d90d418e1bcf168f3d2b819591e0 GIT binary patch literal 778 zcmV+l1NHogP)EX>4Tx04R}tkv&MmKpe$iTcs)$5j#k6$WWc^qD35Q6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UloF{2w)ifh#)R8Q=b#XG(5-GJ$!t6^ClDu?Zdk+{#50?g z&Uv3W%*v8Nd`>)R&;^Mfxh}i>#<}FMpJ#@RY-XM~Oe~bTSngt0HdNv`aa2(?%J=77 zRyc2QR;zW^z9)ZSsGzMZbDicGQdqkM+H?_h|#K%Vj@HPNe_R-@r&e=$yEU( z#{z0lAvu2VKlt6PS)877lR`K2d-P^xs+Wq|isK9c(_I@@V00006VoOIv00000008+zyMF)x010qNS#tmY z4c7nw4c7reD4Tcy000McNliru=mQZ69uX+!UB>_b0S8G$K~!ko?U*|b!Y~j-XCb1Y zf(lN=O}GLj2xxK#L`g-(o%mE7fM#eA3K5?Gvb-zJbe5ZW$;{d^AW71LNERfQBoFkX z1IY!+q6xr)el@TAwI={a00XB1Ihon;69Dgv^%Uo9x z%6yr-XpCx%3Lry?Np=A20E{yG-GBWDNVWlN9GC}yb)&{tWF%J(UZwXW=S`p2t14^j znfp?_`3lnztqyJe1wb70PXJ<>uK~m}Ujc||{su6EBuQa(1+-JEwmsQ(G5`Po07*qo IM6N<$f=@n5P5=M^ literal 0 HcmV?d00001 diff --git a/applications/metadata.js b/applications/metadata.js index 34015cf..8883f9e 100644 --- a/applications/metadata.js +++ b/applications/metadata.js @@ -321,7 +321,7 @@ var metadata = { "applications": "name": "Chat", "description": "Chat application", "jsfile": "armored-chat/armored_chat.js", - "icon": "armored-chat/img/icon.png", + "icon": "armored-chat/img/icon_black.png", "caption": "CHAT" }, {