Update browser window calls.

This commit is contained in:
Patrick Fic
2025-10-20 14:52:37 -07:00
parent 19bd41375e
commit 6d830ae98b
6 changed files with 22 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import { GraphQLClient, RequestMiddleware } from "graphql-request";
import errorTypeCheck from "../../util/errorTypeCheck.js";
import ipcTypes from "../../util/ipcTypes.json";
import store from "../store/store.js";
import getMainWindow from "../../util/getMainWindow.js";
const requestMiddleware: RequestMiddleware = async (request) => {
const token = await getTokenFromRenderer();
@@ -32,9 +33,9 @@ const client: GraphQLClient = new GraphQLClient(
export async function getTokenFromRenderer(): Promise<string> {
return new Promise((resolve) => {
try {
const mainWindow = BrowserWindow.getAllWindows()[0]; //TODO: Filter to only main window once a proper key has been set.
const mainWindow = getMainWindow();
//TODO: Verify that this will work if the app is minimized/closed.
mainWindow.webContents.send(ipcTypes.toRenderer.user.getToken);
mainWindow?.webContents.send(ipcTypes.toRenderer.user.getToken);
} catch (error) {
log.error(
"Unable to send request to renderer process for token",