Merge pull request #1203 from Armored-Dragon/feature/ac_joinnotifications

ArmoredChat notifications on join and leave
This commit is contained in:
ksuprynowicz 2024-11-28 19:57:59 +01:00 committed by GitHub
commit d547dc1244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 3 deletions

View file

@ -14,6 +14,7 @@
var settings = {
external_window: false,
maximum_messages: 200,
join_notification: true
};
// Global vars
@ -115,6 +116,7 @@
// Update qml view of to new message
_emitEvent({ type: "show_message", ...message });
// Show new message on screen
Messages.sendLocalMessage(
"Floof-Notif",
JSON.stringify({
@ -146,18 +148,17 @@
_sendMessage(event.message, event.channel);
break;
case "setting_change":
// Set the setting value, and save the config
settings[event.setting] = event.value; // Update local settings
_saveSettings(); // Save local settings
// Extra actions to preform.
switch (event.setting) {
case "external_window":
chatOverlayWindow.presentationMode = event.value
? Desktop.PresentationMode.NATIVE
: Desktop.PresentationMode.VIRTUAL;
break;
case "maximum_messages":
// Do nothing
break;
}
break;
@ -229,6 +230,17 @@
let message = {};
message.message = `${displayName} ${type}`;
// Show new message on screen
if (settings.join_notification){
Messages.sendLocalMessage(
"Floof-Notif",
JSON.stringify({
sender: displayName,
text: type,
})
);
}
_emitEvent({ type: "notification", ...message });
}, 1500);
}

View file

@ -348,6 +348,31 @@ Rectangle {
}
}
}
// Join notification
Rectangle {
width: parent.width
height: 40
color: "transparent"
Text{
text: "Join notification"
color: "white"
font.pointSize: 12
anchors.verticalCenter: parent.verticalCenter
}
CheckBox{
id: s_join_notification
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
onCheckedChanged: {
toScript({type: 'setting_change', setting: 'join_notification', value: checked})
}
}
}
}
}
@ -579,6 +604,7 @@ Rectangle {
case "initial_settings":
if (message.settings.external_window) s_external_window.checked = true;
if (message.settings.maximum_messages) s_maximum_messages.value = message.settings.maximum_messages;
if (message.settings.join_notification) s_join_notification.checked = true;
break;
}
}