Floofchat compatibility.

Made conversion functions to allow communication between apps.
Removed developer console.log function.

Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
This commit is contained in:
Armored Dragon 2024-06-08 11:51:25 -05:00
parent eb84de84b4
commit 192d80aece
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B

View file

@ -66,7 +66,6 @@
}
function toggleMainChatWindow() {
appIsVisible = !appIsVisible;
console.log(`App is now ${appIsVisible ? "visible" : "hidden"}`);
appButton.editProperties({ isActive: appIsVisible });
chatOverlayWindow.visible = appIsVisible;
@ -97,6 +96,9 @@
if (channel !== "chat") return;
message = JSON.parse(message);
// Floofchat compatibility hook
message = floofChatCompatibilityConversion(message);
message.channel = message.channel.toLowerCase(); // Make sure the "local", "domain", etc. is formatted consistently
if (!channels.includes(message.channel)) return; // Check the channel
@ -197,6 +199,8 @@
action: "send_chat_message",
})
);
floofChatCompatibilitySendMessage(message, channel);
}
function _avatarAction(type, sessionId) {
Script.setTimeout(() => {
@ -251,4 +255,34 @@
function _emitEvent(packet = { type: "" }) {
chatOverlayWindow.sendToQml(packet);
}
//
// Floofchat compatibility functions
// Added to ease the transition between Floofchat to ArmoredChat
// These functions can be safely removed at a much later date.
function floofChatCompatibilityConversion(message) {
if (message.type === "TransmitChatMessage" && !message.forApp) {
return {
position: message.position,
message: message.message,
displayName: message.displayName,
channel: message.channel.toLowerCase(),
};
}
return message;
}
function floofChatCompatibilitySendMessage(message, channel) {
Messages.sendMessage(
"Chat",
JSON.stringify({
position: MyAvatar.position,
message: message,
displayName: MyAvatar.sessionDisplayName,
channel: channel.charAt(0).toUpperCase() + channel.slice(1),
type: "TransmitChatMessage",
forApp: "Floof",
})
);
}
})();