[MIRROR] hands over the round ID to TGchat (#7971)

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2
2024-03-15 03:44:50 -07:00
committed by GitHub
parent 1912e9b707
commit 1f7b75dc18
5 changed files with 15 additions and 15 deletions

View File

@@ -3,4 +3,4 @@
set name = "Export Chatlog"
set desc = "Allows to trigger the chat export"
to_chat(usr, "<span data-command=\"$do_export\"></span>")
tgui_panel.window.send_message("saveToDiskCommand")

View File

@@ -72,6 +72,7 @@
/datum/tgui_panel/proc/on_message(type, payload)
if(type == "ready")
broken = FALSE
window.send_message("connected", list("round_id" = GLOB.round_id)) // Sends the round ID to the chat, requires round IDs
window.send_message("update", list(
"config" = list(
"client" = list(

View File

@@ -160,7 +160,6 @@ export const chatMiddleware = (store) => {
settings.visibleMessageLimit,
settings.combineMessageLimit,
settings.combineIntervalLimit,
settings.logLineCount,
settings.logEnable,
settings.logLimit,
settings.storedTypes,
@@ -267,6 +266,10 @@ export const chatMiddleware = (store) => {
saveChatToStorage(store);
return next(action);
}
if (type === 'saveToDiskCommand') {
chatRenderer.saveToDisk(settings.logLineCount);
return;
}
if (type === saveChatToDisk.type) {
chatRenderer.saveToDisk(
settings.logLineCount,

View File

@@ -152,7 +152,6 @@ class ChatRenderer {
this.visibleMessageLimit = 2500;
this.combineMessageLimit = 5;
this.combineIntervalLimit = 5;
this.exportLimit = 0;
this.logLimit = 0;
this.logEnable = true;
this.roundId = null;
@@ -373,7 +372,6 @@ class ChatRenderer {
visibleMessageLimit,
combineMessageLimit,
combineIntervalLimit,
exportLimit,
logEnable,
logLimit,
storedTypes,
@@ -384,7 +382,6 @@ class ChatRenderer {
this.visibleMessageLimit = visibleMessageLimit;
this.combineMessageLimit = combineMessageLimit;
this.combineIntervalLimit = combineIntervalLimit;
this.exportLimit = exportLimit;
this.logEnable = logEnable;
this.logLimit = logLimit;
this.storedTypes = storedTypes;
@@ -498,15 +495,6 @@ class ChatRenderer {
} else {
logger.error('Error: message is missing text payload', message);
}
// Get our commands we might want to send to chat
const commands = node.querySelectorAll('[data-command]');
if (commands.length) {
const command = commands[0].getAttribute('data-command');
if (command === '$do_export') {
this.saveToDisk(this.exportLimit);
}
return; // We do not want those logged or shown!
}
// Get all nodes in this message that want to be rendered like jsx
const nodes = node.querySelectorAll('[data-component]');
for (let i = 0; i < nodes.length; i++) {

View File

@@ -17,13 +17,21 @@ const initialState = {
};
export const gameReducer = (state = initialState, action) => {
const { type, meta } = action;
const { type, meta, payload } = action;
if (type === 'roundrestart') {
return {
...state,
roundRestartedAt: meta.now,
};
}
if (type === 'connected') {
if (state.roundId !== payload.round_id) {
return {
...state,
roundId: payload.round_id,
};
}
}
if (type === connectionLost.type) {
return {
...state,