mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-01 20:43:33 +00:00
common: Factor out electron.remote pattern to a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import electron from "electron";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
@@ -9,14 +8,12 @@ import type * as z from "zod";
|
||||
import {configSchemata} from "./config-schemata";
|
||||
import * as EnterpriseUtil from "./enterprise-util";
|
||||
import Logger from "./logger-util";
|
||||
import {app, dialog} from "./remote";
|
||||
|
||||
export type Config = {
|
||||
[Key in keyof typeof configSchemata]: z.output<typeof configSchemata[Key]>;
|
||||
};
|
||||
|
||||
/* To make the util runnable in both main and renderer process */
|
||||
const {app, dialog} = process.type === "renderer" ? electron.remote : electron;
|
||||
|
||||
const logger = new Logger({
|
||||
file: "config-util.log",
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import electron from "electron";
|
||||
import fs from "fs";
|
||||
|
||||
const {app} = process.type === "renderer" ? electron.remote : electron;
|
||||
import {app} from "./remote";
|
||||
|
||||
let setupCompleted = false;
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@ import fs from "fs";
|
||||
import os from "os";
|
||||
|
||||
import {initSetUp} from "./default-util";
|
||||
import {app} from "./remote";
|
||||
import {captureException, sentryInit} from "./sentry-util";
|
||||
|
||||
const {app} = process.type === "renderer" ? electron.remote : electron;
|
||||
|
||||
interface LoggerOptions {
|
||||
file?: string;
|
||||
}
|
||||
|
||||
4
app/common/remote.ts
Normal file
4
app/common/remote.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import electron from "electron";
|
||||
|
||||
export const {app, dialog} =
|
||||
process.type === "renderer" ? electron.remote : electron;
|
||||
@@ -1,8 +1,6 @@
|
||||
import electron from "electron";
|
||||
|
||||
import {init} from "@sentry/electron";
|
||||
|
||||
const {app} = process.type === "renderer" ? electron.remote : electron;
|
||||
import {app} from "./remote";
|
||||
|
||||
export const sentryInit = (): void => {
|
||||
if (app.isPackaged) {
|
||||
|
||||
Reference in New Issue
Block a user