From 7d789acaa6a4ebdd413225da29440f9010e28140 Mon Sep 17 00:00:00 2001 From: armored-dragon Date: Thu, 19 Dec 2024 04:41:49 -0600 Subject: [PATCH] Actually fix notifications. --- scripts/system/domainChat/domainChat.js | 16 +++--- scripts/system/domainChat/domainChat.qml | 10 ++-- .../qml_widgets/TemplateChatMessage.qml | 9 ++-- .../qml_widgets/TemplateNotification.qml | 52 ++++++------------- 4 files changed, 32 insertions(+), 55 deletions(-) diff --git a/scripts/system/domainChat/domainChat.js b/scripts/system/domainChat/domainChat.js index 57fe1241c4..780879f8c1 100644 --- a/scripts/system/domainChat/domainChat.js +++ b/scripts/system/domainChat/domainChat.js @@ -32,12 +32,8 @@ Controller.keyPressEvent.connect(keyPressEvent); Messages.subscribe("chat"); Messages.messageReceived.connect(receivedMessage); - AvatarManager.avatarAddedEvent.connect((sessionId) => { - _avatarAction("connected", sessionId); - }); - AvatarManager.avatarRemovedEvent.connect((sessionId) => { - _avatarAction("left", sessionId); - }); + AvatarManager.avatarAddedEvent.connect((sessionId) => { _avatarAction("connected", sessionId); }); + AvatarManager.avatarRemovedEvent.connect((sessionId) => { _avatarAction("left", sessionId); }); startup(); @@ -206,7 +202,7 @@ ); } function _avatarAction(type, sessionId) { - Script.setTimeout(() => { + Script.setTimeout(async () => { if (type == "connected") { palData = AvatarManager.getPalData().data; } @@ -234,7 +230,11 @@ _notificationCoreMessage(displayName, type) } - _emitEvent({ type: "notification", ...message }); + // Format notification message + let formattedMessagePacket = {...message}; + formattedMessagePacket.message = await _parseMessage(message.message); + + _emitEvent({ type: "notification", ...formattedMessagePacket }); }, 1500); } async function _loadSettings() { diff --git a/scripts/system/domainChat/domainChat.qml b/scripts/system/domainChat/domainChat.qml index f40121ee71..6a79cb7e2e 100644 --- a/scripts/system/domainChat/domainChat.qml +++ b/scripts/system/domainChat/domainChat.qml @@ -9,7 +9,6 @@ Rectangle { signal sendToScript(var message); property string pageVal: "local" - property string last_message_user: "" property date last_message_time: new Date() // When the window is created on the script side, the window starts open. @@ -163,7 +162,7 @@ Rectangle { model: getChannel(pageVal) delegate: Loader { property int delegateIndex: model.index - property var delegateText: model.text + property var delegateText: model.message property string delegateUsername: model.username property string delegateDate: model.date @@ -171,7 +170,6 @@ Rectangle { if (model.type === "chat") return template_chat_message; if (model.type === "notification") return template_notification; } - } } } @@ -406,15 +404,13 @@ Rectangle { channel = getChannel(channel) // Format content - if (type === "notification"){ - channel.append({ text: message, date: date, type: "notification" }); + channel.append({ message: message, date: date, type: "notification" }); scrollToBottom(null, 30); - return; } - channel.append({ text: message, username: username, date: date, type: type }); + channel.append({ message: message, username: username, date: date, type: type }); load_scroll_timer.running = true; } diff --git a/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml b/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml index 4165e8d37c..a9c366ce76 100644 --- a/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml +++ b/scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml @@ -7,7 +7,6 @@ Component { Rectangle { property int index: delegateIndex - property string username: delegateUsername height: Math.max(65, children[1].height + 30) color: index % 2 === 0 ? "transparent" : Qt.rgba(0.15,0.15,0.15,1) @@ -19,12 +18,12 @@ Component { anchors.horizontalCenter: parent.horizontalCenter height: 22 - Text{ - text: username + Text { + text: delegateUsername color: "lightgray" } - Text{ + Text { anchors.right: parent.right text: delegateDate color: "lightgray" @@ -109,7 +108,7 @@ Component { radius: 2; Image { - source: "./img/ui/world_black.png" + source: "../img/ui/world_black.png" width: 18; height: 18; sourceSize.width: 18 diff --git a/scripts/system/domainChat/qml_widgets/TemplateNotification.qml b/scripts/system/domainChat/qml_widgets/TemplateNotification.qml index e522d58c54..4b9797d7f4 100644 --- a/scripts/system/domainChat/qml_widgets/TemplateNotification.qml +++ b/scripts/system/domainChat/qml_widgets/TemplateNotification.qml @@ -6,15 +6,12 @@ Component { id: template_notification Rectangle { - property int index: delegateIndex - property string username: delegateUsername - color: "#171717" width: parent.width height: 40 - Item { - width: 10 + RowLayout { + width: parent.width height: parent.height Rectangle { @@ -22,38 +19,23 @@ Component { width: 5 color: "#505186" } - } - Item { - width: parent.width - parent.children[0].width - 5 - height: parent.height - anchors.left: parent.children[0].right + Repeater { + model: delegateText - TextEdit { - text: delegateText - color: "white" - font.pointSize: 12 - readOnly: true - width: parent.width * 0.8 - selectByMouse: true - selectByKeyboard: true - height: parent.height - wrapMode: Text.Wrap - verticalAlignment: Text.AlignVCenter - font.italic: true - } - - Text { - text: delegateDate - color: "white" - font.pointSize: 12 - anchors.right: parent.right - height: parent.height - wrapMode: Text.Wrap - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - font.italic: true + TextEdit { + visible: model.value != undefined; + text: model.value || "" + color: "white" + font.pointSize: 12 + readOnly: true + selectByMouse: true + selectByKeyboard: true + height: root.height + wrapMode: Text.Wrap + font.italic: true + } } } } -} \ No newline at end of file +}