diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Settings.tsx | 4 | ||||
-rw-r--r-- | src/ipcMain.ts | 7 | ||||
-rw-r--r-- | src/plugins/noTrack.ts | 2 | ||||
-rw-r--r-- | src/utils/debounce.ts | 7 |
4 files changed, 14 insertions, 6 deletions
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index dfea116..69e923a 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -43,7 +43,7 @@ export default ErrorBoundary.wrap(function Settings(props) { </Flex.Child> <Flex.Child> <Button - onClick={() => VencordNative.ipc.invoke(IpcEvents.OPEN_PATH, settingsDir + "/quickCss.css")} + onClick={() => VencordNative.ipc.invoke(IpcEvents.OPEN_PATH, settingsDir, "quickCss.css")} size={ButtonProps.ButtonSizes.SMALL} disabled={settingsDir === "Loading..."} > @@ -98,7 +98,7 @@ export default ErrorBoundary.wrap(function Settings(props) { "This plugin is required. Thus you cannot disable it." : dependency ? `${humanFriendlyJoin(enabledDependants)} ${enabledDependants.length === 1 ? "depends" : "depend"} on this plugin. Thus you cannot disable it.` - : "" + : null } > {p.name} diff --git a/src/ipcMain.ts b/src/ipcMain.ts index a35b248..d8bf475 100644 --- a/src/ipcMain.ts +++ b/src/ipcMain.ts @@ -2,6 +2,7 @@ import { app, BrowserWindow, ipcMain, shell } from "electron"; import { mkdirSync, readFileSync, watch } from "fs"; import { open, readFile, writeFile } from "fs/promises"; import { join } from 'path'; +import { debounce } from "./utils/debounce"; import IpcEvents from './utils/IpcEvents'; const DATA_DIR = join(app.getPath("userData"), "..", "Vencord"); @@ -25,7 +26,7 @@ function readSettings() { ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR); ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss()); -ipcMain.handle(IpcEvents.OPEN_PATH, (_, path) => shell.openPath(path)); +ipcMain.handle(IpcEvents.OPEN_PATH, (_, ...pathElements) => shell.openPath(join(...pathElements))); ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => shell.openExternal(url)); // .on because we need Settings synchronously (ipcRenderer.sendSync) @@ -40,8 +41,8 @@ ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => { export function initIpc(mainWindow: BrowserWindow) { open(QUICKCSS_PATH, "a+").then(fd => { fd.close(); - watch(QUICKCSS_PATH, async () => { + watch(QUICKCSS_PATH, debounce(async () => { mainWindow.webContents.postMessage(IpcEvents.QUICK_CSS_UPDATE, await readCss()); - }); + }, 50)); }); } diff --git a/src/plugins/noTrack.ts b/src/plugins/noTrack.ts index 6f15d4c..ff4b95c 100644 --- a/src/plugins/noTrack.ts +++ b/src/plugins/noTrack.ts @@ -3,7 +3,7 @@ import definePlugin from "../utils/types"; export default definePlugin({ name: "NoTrack", description: "Disable Discord's tracking and crash reporting", - author: "Vendicated", + author: "Cynosphere", required: true, patches: [ { diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts new file mode 100644 index 0000000..6a1756b --- /dev/null +++ b/src/utils/debounce.ts @@ -0,0 +1,7 @@ +export function debounce<T extends Function>(func: T, delay = 300): T { + let timeout: NodeJS.Timeout; + return function (...args: any[]) { + clearTimeout(timeout); + timeout = setTimeout(() => { func(...args); }, delay); + } as any; +}
\ No newline at end of file |