Skip to content

Commit 86c0aad

Browse files
committed
chore: seprate import
1 parent f3e3f9f commit 86c0aad

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import electron from "electron";
1+
import electron, { app, net, protocol, session } from "electron";
22
import { dirname, join } from "path";
33
import { CONFIG_PATHS } from "src/util.mjs";
44
import type { PackageJson } from "type-fest";
@@ -72,13 +72,13 @@ delete require.cache[electronPath]!.exports;
7272
require.cache[electronPath]!.exports = electronExports;
7373

7474
(
75-
electron.app as typeof electron.app & {
75+
app as typeof app & {
7676
setAppPath: (path: string) => void;
7777
}
7878
).setAppPath(discordPath);
79-
// electron.app.name = discordPackage.name;
79+
// app.name = discordPackage.name;
8080

81-
electron.protocol.registerSchemesAsPrivileged([
81+
protocol.registerSchemesAsPrivileged([
8282
{
8383
scheme: "replugged",
8484
privileges: {
@@ -93,13 +93,13 @@ function loadReactDevTools(): void {
9393
const rdtSetting = getSetting<boolean>("dev.replugged.Settings", "reactDevTools", false);
9494

9595
if (rdtSetting) {
96-
void electron.session.defaultSession.loadExtension(CONFIG_PATHS["react-devtools"]);
96+
void session.defaultSession.loadExtension(CONFIG_PATHS["react-devtools"]);
9797
}
9898
}
9999

100100
// Copied from old codebase
101-
electron.app.once("ready", () => {
102-
electron.session.defaultSession.webRequest.onBeforeRequest(
101+
app.once("ready", () => {
102+
session.defaultSession.webRequest.onBeforeRequest(
103103
{
104104
urls: [
105105
"https://*/api/v*/science",
@@ -115,7 +115,7 @@ electron.app.once("ready", () => {
115115
},
116116
);
117117
// @todo: Whitelist a few domains instead of removing CSP altogether; See #386
118-
electron.session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders }, done) => {
118+
session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders }, done) => {
119119
if (!responseHeaders) {
120120
done({});
121121
return;
@@ -149,7 +149,7 @@ electron.app.once("ready", () => {
149149
});
150150

151151
// TODO: Eventually in the future, this should be migrated to IPC for better performance
152-
electron.protocol.handle("replugged", (request) => {
152+
protocol.handle("replugged", (request) => {
153153
let filePath = "";
154154
const reqUrl = new URL(request.url);
155155
switch (reqUrl.hostname) {
@@ -169,7 +169,7 @@ electron.app.once("ready", () => {
169169
filePath = join(CONFIG_PATHS.plugins, reqUrl.pathname);
170170
break;
171171
}
172-
return electron.net.fetch(pathToFileURL(filePath).toString());
172+
return net.fetch(pathToFileURL(filePath).toString());
173173
});
174174

175175
loadReactDevTools();

0 commit comments

Comments
 (0)