From 3a9f6926442dd673bfac67424317e04b80bcc0f8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 4 Oct 2022 12:57:39 +0200 Subject: [PATCH] Fix Desktop thinking it's web I forgor to test host after adding web support --- src/Vencord.ts | 6 ++++++ src/components/Settings.tsx | 3 +-- src/globals.d.ts | 1 + src/plugins/settings.ts | 1 - src/utils/isWeb.ts | 1 - src/webpack/patchWebpack.ts | 1 - 6 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 src/utils/isWeb.ts diff --git a/src/Vencord.ts b/src/Vencord.ts index 5b3d6f2..716cb83 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -16,6 +16,12 @@ import { checkForUpdates, UpdateLogger } from './utils/updater'; import { onceReady } from "./webpack"; import { Router } from "./webpack/common"; +Object.defineProperty(window, "IS_WEB", { + get: () => !window.DiscordNative, + configurable: true, + enumerable: true +}); + export let Components; async function init() { diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 4dbb1b2..007767e 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -9,7 +9,6 @@ import { startPlugin } from "../plugins"; import { stopPlugin } from '../plugins/index'; import { Flex } from './Flex'; import { ChangeList } from '../utils/ChangeList'; -import { IS_WEB } from '../utils/isWeb'; function showErrorToast(message: string) { Toasts.show({ @@ -25,7 +24,7 @@ function showErrorToast(message: string) { export default ErrorBoundary.wrap(function Settings() { const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke(IpcEvents.GET_SETTINGS_DIR), "Loading..."); const settings = useSettings(); - const changes = React.useMemo(() => new ChangeList, []); + const changes = React.useMemo(() => new ChangeList(), []); React.useEffect(() => { return () => void (changes.hasChanges && Alerts.show({ diff --git a/src/globals.d.ts b/src/globals.d.ts index 92ca95c..292fa96 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -1,4 +1,5 @@ declare global { + export var IS_WEB: boolean; export var VencordNative: typeof import("./VencordNative").default; export var Vencord: typeof import("./Vencord"); export var appSettings: { diff --git a/src/plugins/settings.ts b/src/plugins/settings.ts index 6927f64..7125823 100644 --- a/src/plugins/settings.ts +++ b/src/plugins/settings.ts @@ -1,7 +1,6 @@ import definePlugin from "../utils/types"; import gitHash from "git-hash"; import { Devs } from '../utils/constants'; -import { IS_WEB } from "../utils/isWeb"; export default definePlugin({ name: "Settings", diff --git a/src/utils/isWeb.ts b/src/utils/isWeb.ts deleted file mode 100644 index 4082164..0000000 --- a/src/utils/isWeb.ts +++ /dev/null @@ -1 +0,0 @@ -export const IS_WEB = window.IS_WEB = typeof window.DiscordNative === "undefined"; diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index ffd81d5..469b930 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -6,7 +6,6 @@ let webpackChunk: any[]; const logger = new Logger("WebpackInterceptor", "#8caaee"); -console.log("prepatch is", window[WEBPACK_CHUNK]); Object.defineProperty(window, WEBPACK_CHUNK, { get: () => webpackChunk, set: (v) => {