Skip to content

Commit

Permalink
Merge pull request #1203 from Armored-Dragon/feature/ac_joinnotificat…
Browse files Browse the repository at this point in the history
…ions

ArmoredChat notifications on join and leave
  • Loading branch information
ksuprynowicz authored Nov 28, 2024
2 parents 07c57f6 + 91733a7 commit d547dc1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
18 changes: 15 additions & 3 deletions scripts/communityScripts/armored-chat/armored_chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
var settings = {
external_window: false,
maximum_messages: 200,
join_notification: true
};

// Global vars
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
26 changes: 26 additions & 0 deletions scripts/communityScripts/armored-chat/armored_chat.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
}
}
}
}

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit d547dc1

Please sign in to comment.