Skip to content

Commit

Permalink
Remove video embeds.
Browse files Browse the repository at this point in the history
Added debug logs.
Don't save settings when initializing the application.
  • Loading branch information
Armored-Dragon committed Jan 16, 2025
1 parent e67526c commit dbf5af0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 47 deletions.
21 changes: 17 additions & 4 deletions scripts/system/domainChat/domainChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
// Is the message a chat message?
channel = channel.toLowerCase();
if (channel !== "chat") return;

if ((message = formatting.toJSON(message)) == null) return; // Make sure we are working with a JSON object we expect, otherwise kill
message = formatting.addTimeAndDateStringToPacket(message);

Expand Down Expand Up @@ -194,6 +193,8 @@
chatOverlayWindow.presentationMode = changeToExternal
? Desktop.PresentationMode.NATIVE
: Desktop.PresentationMode.VIRTUAL;

console.log(`Presentation mode was changed to ${chatOverlayWindow.presentationMode}`);
}
function _sendMessage(message, channel) {
if (message.length == 0) return;
Expand Down Expand Up @@ -244,6 +245,7 @@
}
async function _loadSettings() {
settings = Settings.getValue("ArmoredChat-Config", settings);
console.log("Loading settings: ", jstr(settings));

if (messageHistory) {
// Load message history
Expand All @@ -259,10 +261,11 @@
_emitEvent({ type: "initial_settings", settings: settings }); // Send current settings to the app
}
function _saveSettings() {
console.log("Saving config");
console.log("Saving settings: ", jstr(settings));
Settings.setValue("ArmoredChat-Config", settings);
}
function _notificationCoreMessage(displayName, message){
console.log("Sending notification to notificationCore:", `Display name: ${displayName}\n Message: ${message}`);
Messages.sendLocalMessage(
"Floof-Notif",
JSON.stringify({ sender: displayName, text: message })
Expand All @@ -274,9 +277,19 @@
* @param {("show_message"|"clear_messages"|"notification"|"initial_settings")} packet.type - The type of packet it is
*/
function _emitEvent(packet = { type: "" }) {
if (packet.type == `show_message`) {
// Don't show the message contents, this is a courtesy to prevent message leakage in the logs.
let strippedPacket = {...packet};
delete strippedPacket.message
console.log("Sending packet to QML interface", jstr(strippedPacket));
}
else {
console.log("Sending packet to QML interface", jstr(packet));
}

chatOverlayWindow.sendToQml(packet);
}



// Debug and developer functions and data
const jstr = (object) => JSON.stringify(object, null, 4); // JSON Stringify function with formatting
})();
13 changes: 10 additions & 3 deletions scripts/system/domainChat/domainChat.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Rectangle {
color: Qt.rgba(0.1,0.1,0.1,1)
signal sendToScript(var message);

property string pageVal: "local"
property date last_message_time: new Date()
property string pageVal: "local";
property date last_message_time: new Date();
property bool initialized: false;


// When the window is created on the script side, the window starts open.
// Once the QML window is created wait, then send the initialized signal.
Expand Down Expand Up @@ -445,7 +447,6 @@ Rectangle {
messageViewFlickable.returnToBounds();
}


function addMessage(username, message, date, channel, type){
channel = getChannel(channel)

Expand Down Expand Up @@ -479,17 +480,23 @@ Rectangle {
domain.clear();
break;
case "initial_settings":
print(`Got settings:\n ${JSON.stringify(message.settings, null, 4)}`);
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;
if (message.settings.switchToInternalOnHeadsetUsed) s_force_vw_in_vr.checked = true;
if (message.settings.enableEmbedding) s_enable_embedding.checked = true;

initialized = true; // Application is ready

break;
}
}

// Send message to script
function toScript(packet){
if (packet.type === "setting_change" && !initialized) return; // Don't announce a change in settings if not ready

sendToScript(packet)
}
}
79 changes: 39 additions & 40 deletions scripts/system/domainChat/qml_widgets/TemplateChatMessage.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3
import QtMultimedia 5.15
// import QtMultimedia 5.15

Component {
id: template_chat_message
Expand Down Expand Up @@ -170,45 +170,44 @@ Component {
}
}

Item {
visible: model.type === 'videoEmbed';
width: messageBoxFlow.width;
height: 200;

Video {
id: videoPlayer
source: model.type === 'videoEmbed' ? model.value : ''
height: 200;
width: 400;
fillMode: Image.PreserveAspectFit
autoLoad: false;

onStatusChanged: {
if (status === 7) {
// Weird hack to make the video restart when it's over
// Ideally you'd want to use the seek function to restart the video but it doesn't work?
// Will need to make a more refined solution for this later. in the form of a more advanced media player.
// For now, this is sufficient. -AD
let originalURL = videoPlayer.source;
videoPlayer.source = "";
videoPlayer.source = originalURL;
}
}

MouseArea {
anchors.fill: parent
onClicked: {
const videoIsOver = videoPlayer.position == videoPlayer.duration
if (videoPlayer.playbackState == MediaPlayer.PlayingState) {
videoPlayer.pause();
}
else {
parent.play();
}
}
}
}
}
// Item {
// visible: model.type === 'videoEmbed';
// width: messageBoxFlow.width;
// height: 200;

// Video {
// id: videoPlayer
// source: model.type === 'videoEmbed' ? model.value : ''
// height: 200;
// width: 400;
// fillMode: Image.PreserveAspectFit
// autoLoad: false;

// onStatusChanged: {
// if (status === 7) {
// // Weird hack to make the video restart when it's over
// // Ideally you'd want to use the seek function to restart the video but it doesn't work?
// // Will need to make a more refined solution for this later. in the form of a more advanced media player.
// // For now, this is sufficient. -AD
// let originalURL = videoPlayer.source;
// videoPlayer.source = "";
// videoPlayer.source = originalURL;
// }
// }

// MouseArea {
// anchors.fill: parent
// onClicked: {
// const videoIsOver = videoPlayer.position == videoPlayer.duration
// if (videoPlayer.playbackState == MediaPlayer.PlayingState) {
// videoPlayer.pause();
// }
// else {
// parent.play();
// }
// }
// }
// }
}
}
}
Expand Down

0 comments on commit dbf5af0

Please sign in to comment.