Remove video embeds.

Added debug logs.
Don't save settings when initializing the application.
This commit is contained in:
armored-dragon 2025-01-16 14:53:54 -06:00
parent f59f39ecb4
commit 5586df1a93
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B
3 changed files with 63 additions and 44 deletions

View file

@ -100,7 +100,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);
@ -195,6 +194,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;
@ -245,6 +246,7 @@
}
async function _loadSettings() {
settings = Settings.getValue("ArmoredChat-Config", settings);
console.log("Loading settings: ", jstr(settings));
if (messageHistory) {
// Load message history
@ -260,10 +262,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 })
@ -275,9 +278,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
})();

View file

@ -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.
@ -445,7 +447,6 @@ Rectangle {
messageViewFlickable.returnToBounds();
}
function addMessage(username, message, date, channel, type){
channel = getChannel(channel)
@ -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)
}
}

View file

@ -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
@ -170,45 +170,44 @@ Component {
}
}
Item {
visible: model.type === 'videoEmbed';
width: messageBoxFlow.width;
height: 200;
// 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;
// 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;
}
}
// 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();
}
}
}
}
}
// MouseArea {
// anchors.fill: parent
// onClicked: {
// const videoIsOver = videoPlayer.position == videoPlayer.duration
// if (videoPlayer.playbackState == MediaPlayer.PlayingState) {
// videoPlayer.pause();
// }
// else {
// parent.play();
// }
// }
// }
// }
}
}
}