diff options
author | Vendicated <vendicated@riseup.net> | 2022-10-22 04:41:33 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-10-22 04:42:54 +0200 |
commit | 44f6f71c3efd2e4e0f9dbd97ab4680ec76536052 (patch) | |
tree | cd2ad847833ff428e009ca55b50eabd57031443d /src/ipcMain/index.ts | |
parent | 23d4cae1230bd60da2f0497ecac9d4a32a326f5b (diff) | |
download | Vencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.tar.gz Vencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.tar.bz2 Vencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.zip |
Monaco for Discord Desktop
Diffstat (limited to 'src/ipcMain/index.ts')
-rw-r--r-- | src/ipcMain/index.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/ipcMain/index.ts b/src/ipcMain/index.ts index caa4e34..dc05079 100644 --- a/src/ipcMain/index.ts +++ b/src/ipcMain/index.ts @@ -22,8 +22,10 @@ import { open, readFile, writeFile } from "fs/promises"; import { join } from "path"; import { debounce } from "../utils/debounce"; import IpcEvents from "../utils/IpcEvents"; +import monacoHtml from "@fileContent/../components/monacoWin.html;base64"; import "./updater"; +import { Queue } from "../utils/Queue"; const DATA_DIR = process.env.VENCORD_USER_DATA_DIR ?? ( process.env.DISCORD_USER_DATA_DIR @@ -71,15 +73,19 @@ ipcMain.handle(IpcEvents.OPEN_EXTERNAL, (_, url) => { shell.openExternal(url); }); +const cssWriteQueue = new Queue(); +const settingsWriteQueue = new Queue(); ipcMain.handle(IpcEvents.GET_QUICK_CSS, () => readCss()); +ipcMain.handle(IpcEvents.SET_QUICK_CSS, (_, css) => + cssWriteQueue.add(() => writeFile(QUICKCSS_PATH, css)) +); ipcMain.handle(IpcEvents.GET_SETTINGS_DIR, () => SETTINGS_DIR); ipcMain.on(IpcEvents.GET_SETTINGS, e => e.returnValue = readSettings()); -let settingsWriteQueue = Promise.resolve(); ipcMain.handle(IpcEvents.SET_SETTINGS, (_, s) => { - settingsWriteQueue = settingsWriteQueue.then(() => writeFile(SETTINGS_FILE, s)); + settingsWriteQueue.add(() => writeFile(SETTINGS_FILE, s)); }); @@ -91,3 +97,13 @@ export function initIpc(mainWindow: BrowserWindow) { }, 50)); }); } + +ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => { + const win = new BrowserWindow({ + title: "QuickCss Editor", + webPreferences: { + preload: join(__dirname, "preload.js"), + } + }); + await win.loadURL(`data:text/html;base64,${monacoHtml}`); +}); |