Add translations and testing framework.

This commit is contained in:
Patrick Fic
2025-03-12 14:53:02 -07:00
parent e0cec62e13
commit 776d152d88
23 changed files with 1334 additions and 33 deletions

View File

@@ -1,6 +1,38 @@
import { ipcMain } from "electron";
import ipcTypes from "../../util/ipcTypes.json";
import log from "electron-log/main";
import { ipcMainHandleAuthStateChanged } from "./ipcMainHandler.user";
// Log all IPC messages and their payloads
const logIpcMessages = () => {
// Get all message types from ipcTypes.toMain
Object.keys(ipcTypes.toMain).forEach((key) => {
const messageType = ipcTypes.toMain[key];
// Wrap the original handler with our logging
const originalHandler = ipcMain.listeners(messageType)[0];
if (originalHandler) {
ipcMain.removeAllListeners(messageType);
}
ipcMain.on(messageType, (event, payload) => {
log.info(
`%c[IPC Main]%c${messageType}`,
"color: red",
"color: green",
payload
);
// Call original handler if it existed
if (originalHandler) {
originalHandler(event, payload);
}
});
});
};
ipcMain.on(ipcTypes.toMain.test, (payload: any) =>
console.log("** Verify that ipcMain is loaded and working.", payload)
);
ipcMain.on(ipcTypes.toMain.authStateChanged, ipcMainHandleAuthStateChanged);
logIpcMessages();