Start using it

This commit is contained in:
Manav Rathi 2024-04-09 09:53:28 +05:30
parent 54a973c457
commit 72dea7eca6
No known key found for this signature in database
2 changed files with 7 additions and 4 deletions

View file

@ -14,5 +14,9 @@ declare global {
* {@link Electron}) that allow us to communicate with the Node.js layer of
* our desktop app.
*/
const electron: Electron | undefined;
// This needs to be a var for it to be recognized as a property of
// globalThis, so we unfortunately need to hush eslint for the next line.
//
// eslint-disable-next-line no-var
var electron: Electron | undefined;
}

View file

@ -1,6 +1,4 @@
import { inWorker } from "@/next/env";
import isElectron from "is-electron";
import ElectronAPIs from "./electron";
import { isDevBuild } from "./env";
import { logToDisk as webLogToDisk } from "./log-web";
import { workerBridge } from "./worker/worker-bridge";
@ -12,7 +10,8 @@ import { workerBridge } from "./worker/worker-bridge";
* in the log that is saved on disk.
*/
export const logToDisk = (message: string) => {
if (isElectron()) ElectronAPIs.logToDisk(message);
const electron = globalThis.electron;
if (electron) electron.logToDisk(message);
else if (inWorker()) workerLogToDisk(message);
else webLogToDisk(message);
};