Actually fix notifications.

This commit is contained in:
armored-dragon 2024-12-19 04:41:49 -06:00
parent 48c690a2df
commit 7d789acaa6
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B
4 changed files with 32 additions and 55 deletions

View file

@ -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() {

View file

@ -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;
}

View file

@ -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

View file

@ -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
}
}
}
}
}
}