Fix Desktop thinking it's web

I forgor to test host after adding web support
This commit is contained in:
Vendicated 2022-10-04 12:57:39 +02:00
parent e35393b40c
commit 3a9f692644
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3
6 changed files with 8 additions and 5 deletions

@ -16,6 +16,12 @@ import { checkForUpdates, UpdateLogger } from './utils/updater';
import { onceReady } from "./webpack"; import { onceReady } from "./webpack";
import { Router } from "./webpack/common"; import { Router } from "./webpack/common";
Object.defineProperty(window, "IS_WEB", {
get: () => !window.DiscordNative,
configurable: true,
enumerable: true
});
export let Components; export let Components;
async function init() { async function init() {

@ -9,7 +9,6 @@ import { startPlugin } from "../plugins";
import { stopPlugin } from '../plugins/index'; import { stopPlugin } from '../plugins/index';
import { Flex } from './Flex'; import { Flex } from './Flex';
import { ChangeList } from '../utils/ChangeList'; import { ChangeList } from '../utils/ChangeList';
import { IS_WEB } from '../utils/isWeb';
function showErrorToast(message: string) { function showErrorToast(message: string) {
Toasts.show({ Toasts.show({
@ -25,7 +24,7 @@ function showErrorToast(message: string) {
export default ErrorBoundary.wrap(function Settings() { export default ErrorBoundary.wrap(function Settings() {
const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke<string>(IpcEvents.GET_SETTINGS_DIR), "Loading..."); const [settingsDir, , settingsDirPending] = useAwaiter(() => VencordNative.ipc.invoke<string>(IpcEvents.GET_SETTINGS_DIR), "Loading...");
const settings = useSettings(); const settings = useSettings();
const changes = React.useMemo(() => new ChangeList<string>, []); const changes = React.useMemo(() => new ChangeList<string>(), []);
React.useEffect(() => { React.useEffect(() => {
return () => void (changes.hasChanges && Alerts.show({ return () => void (changes.hasChanges && Alerts.show({

1
src/globals.d.ts vendored

@ -1,4 +1,5 @@
declare global { declare global {
export var IS_WEB: boolean;
export var VencordNative: typeof import("./VencordNative").default; export var VencordNative: typeof import("./VencordNative").default;
export var Vencord: typeof import("./Vencord"); export var Vencord: typeof import("./Vencord");
export var appSettings: { export var appSettings: {

@ -1,7 +1,6 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import gitHash from "git-hash"; import gitHash from "git-hash";
import { Devs } from '../utils/constants'; import { Devs } from '../utils/constants';
import { IS_WEB } from "../utils/isWeb";
export default definePlugin({ export default definePlugin({
name: "Settings", name: "Settings",

@ -1 +0,0 @@
export const IS_WEB = window.IS_WEB = typeof window.DiscordNative === "undefined";

@ -6,7 +6,6 @@ let webpackChunk: any[];
const logger = new Logger("WebpackInterceptor", "#8caaee"); const logger = new Logger("WebpackInterceptor", "#8caaee");
console.log("prepatch is", window[WEBPACK_CHUNK]);
Object.defineProperty(window, WEBPACK_CHUNK, { Object.defineProperty(window, WEBPACK_CHUNK, {
get: () => webpackChunk, get: () => webpackChunk,
set: (v) => { set: (v) => {