Debounce CssWatcher, fix empty tooltips in settings
This commit is contained in:
parent
02aeca6b73
commit
68057d49e8
@ -43,7 +43,7 @@ export default ErrorBoundary.wrap(function Settings(props) {
|
|||||||
</Flex.Child>
|
</Flex.Child>
|
||||||
<Flex.Child>
|
<Flex.Child>
|
||||||
<Button
|
<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}
|
size={ButtonProps.ButtonSizes.SMALL}
|
||||||
disabled={settingsDir === "Loading..."}
|
disabled={settingsDir === "Loading..."}
|
||||||
>
|
>
|
||||||
@ -98,7 +98,7 @@ export default ErrorBoundary.wrap(function Settings(props) {
|
|||||||
"This plugin is required. Thus you cannot disable it."
|
"This plugin is required. Thus you cannot disable it."
|
||||||
: dependency ?
|
: dependency ?
|
||||||
`${humanFriendlyJoin(enabledDependants)} ${enabledDependants.length === 1 ? "depends" : "depend"} on this plugin. Thus you cannot disable it.`
|
`${humanFriendlyJoin(enabledDependants)} ${enabledDependants.length === 1 ? "depends" : "depend"} on this plugin. Thus you cannot disable it.`
|
||||||
: ""
|
: null
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{p.name}
|
{p.name}
|
||||||
|
@ -2,6 +2,7 @@ import { app, BrowserWindow, ipcMain, shell } from "electron";
|
|||||||
import { mkdirSync, readFileSync, watch } from "fs";
|
import { mkdirSync, readFileSync, watch } from "fs";
|
||||||
import { open, readFile, writeFile } from "fs/promises";
|
import { open, readFile, writeFile } from "fs/promises";
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
import { debounce } from "./utils/debounce";
|
||||||
import IpcEvents from './utils/IpcEvents';
|
import IpcEvents from './utils/IpcEvents';
|
||||||
|
|
||||||
const DATA_DIR = join(app.getPath("userData"), "..", "Vencord");
|
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_SETTINGS_DIR, () => SETTINGS_DIR);
|
||||||
ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss());
|
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));
|
ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => shell.openExternal(url));
|
||||||
|
|
||||||
// .on because we need Settings synchronously (ipcRenderer.sendSync)
|
// .on because we need Settings synchronously (ipcRenderer.sendSync)
|
||||||
@ -40,8 +41,8 @@ ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => {
|
|||||||
export function initIpc(mainWindow: BrowserWindow) {
|
export function initIpc(mainWindow: BrowserWindow) {
|
||||||
open(QUICKCSS_PATH, "a+").then(fd => {
|
open(QUICKCSS_PATH, "a+").then(fd => {
|
||||||
fd.close();
|
fd.close();
|
||||||
watch(QUICKCSS_PATH, async () => {
|
watch(QUICKCSS_PATH, debounce(async () => {
|
||||||
mainWindow.webContents.postMessage(IpcEvents.QUICK_CSS_UPDATE, await readCss());
|
mainWindow.webContents.postMessage(IpcEvents.QUICK_CSS_UPDATE, await readCss());
|
||||||
});
|
}, 50));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import definePlugin from "../utils/types";
|
|||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoTrack",
|
name: "NoTrack",
|
||||||
description: "Disable Discord's tracking and crash reporting",
|
description: "Disable Discord's tracking and crash reporting",
|
||||||
author: "Vendicated",
|
author: "Cynosphere",
|
||||||
required: true,
|
required: true,
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
|
7
src/utils/debounce.ts
Normal file
7
src/utils/debounce.ts
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user