aboutsummaryrefslogtreecommitdiff
path: root/browser/VencordNativeStub.ts
diff options
context:
space:
mode:
authormegumin <megumin.bakaretsurie@gmail.com>2023-08-04 18:52:20 +0100
committerGitHub <noreply@github.com>2023-08-04 19:52:20 +0200
commitd6c43986fd665b60a8a83d41ef907dab22e990e7 (patch)
treeff9eda6794ef371568662b389a5e71e32bbbc16c /browser/VencordNativeStub.ts
parentbb7deeb09cb263d158de0d99e873c3d3f43a73bb (diff)
downloadVencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.tar.gz
Vencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.tar.bz2
Vencord-d6c43986fd665b60a8a83d41ef907dab22e990e7.zip
Add proper user-friendly theme manager (#635)
Co-authored-by: Justice Almanzar <superdash993@gmail.com> Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'browser/VencordNativeStub.ts')
-rw-r--r--browser/VencordNativeStub.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/browser/VencordNativeStub.ts b/browser/VencordNativeStub.ts
index 515ccc3..664e9ee 100644
--- a/browser/VencordNativeStub.ts
+++ b/browser/VencordNativeStub.ts
@@ -23,6 +23,7 @@ import monacoHtml from "~fileContent/../src/components/monacoWin.html";
import * as DataStore from "../src/api/DataStore";
import { debounce } from "../src/utils";
import { getTheme, Theme } from "../src/utils/discord";
+import { getThemeInfo } from "../src/main/themes";
// Discord deletes this so need to store in variable
const { localStorage } = window;
@@ -34,8 +35,20 @@ const NOOP_ASYNC = async () => { };
const setCssDebounced = debounce((css: string) => VencordNative.quickCss.set(css));
+const themeStore = DataStore.createStore("VencordThemes", "VencordThemeData");
+
// probably should make this less cursed at some point
window.VencordNative = {
+ themes: {
+ uploadTheme: (fileName: string, fileData: string) => DataStore.set(fileName, fileData, themeStore),
+ deleteTheme: (fileName: string) => DataStore.del(fileName, themeStore),
+ getThemesDir: async () => "",
+ getThemesList: () => DataStore.entries(themeStore).then(entries =>
+ entries.map(([name, css]) => getThemeInfo(css, name.toString()))
+ ),
+ getThemeData: (fileName: string) => DataStore.get(fileName, themeStore)
+ },
+
native: {
getVersions: () => ({}),
openExternal: async (url) => void open(url, "_blank")
@@ -57,6 +70,7 @@ window.VencordNative = {
addChangeListener(cb) {
cssListeners.add(cb);
},
+ addThemeChangeListener: NOOP,
openFile: NOOP_ASYNC,
async openEditor() {
const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`;
@@ -81,5 +95,7 @@ window.VencordNative = {
get: () => localStorage.getItem("VencordSettings") || "{}",
set: async (s: string) => localStorage.setItem("VencordSettings", s),
getSettingsDir: async () => "LocalStorage"
- }
+ },
+
+ pluginHelpers: {} as any,
};