Add option to turn off notification.

This commit is contained in:
armored-dragon 2024-10-27 23:06:00 -05:00
parent d98ff9cd0a
commit 91733a76ce
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B
2 changed files with 38 additions and 10 deletions

View file

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

View file

@ -337,6 +337,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})
}
}
}
} }
} }
@ -561,6 +586,7 @@ Rectangle {
case "initial_settings": case "initial_settings":
if (message.settings.external_window) s_external_window.checked = true; 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.maximum_messages) s_maximum_messages.value = message.settings.maximum_messages;
if (message.settings.join_notification) s_join_notification.checked = true;
break; break;
} }
} }