[Global] Some changes and fixes

This commit is contained in:
redstonekasi 2023-04-05 22:18:22 +02:00 committed by Beef
parent 50755b2306
commit 5461065db8
4 changed files with 13 additions and 14 deletions

View file

@ -8,7 +8,6 @@ export const createMMKVBackend = (store: string): StorageBackend => ({
});
export const createFileBackend = (file: string): StorageBackend => {
// TODO: Creating this function in every file backend probably isn't ideal.
const filePathFixer: (file: string) => string = RN.Platform.select({
default: (f) => f,
ios: (f) => `Documents/${f}`,
@ -21,6 +20,6 @@ export const createFileBackend = (file: string): StorageBackend => {
if (!created && !(await FileManager.fileExists(path))) return (created = true), FileManager.writeFile("documents", filePathFixer(file), "{}", "utf8");
return JSON.parse(await FileManager.readFile(path, "utf8"));
},
set: (data) => void FileManager.writeFile("documents", filePathFixer(file), JSON.stringify(data), "utf8"),
set: async (data) => void await FileManager.writeFile("documents", filePathFixer(file), JSON.stringify(data), "utf8"),
};
};
};

View file

@ -17,7 +17,7 @@ import * as assets from "@ui/assets";
import * as color from "@ui/color";
import * as utils from "@utils";
function without<T extends Record<string, any>>(object: T, ...keys: string[]) {
function without<O extends object, K extends readonly (keyof O)[]>(object: O, ...keys: K): Omit<O, typeof keys[number]> {
const cloned = { ...object };
keys.forEach((k) => delete cloned[k]);
return cloned;
@ -36,7 +36,7 @@ export default async (unloads: any[]): Promise<VendettaObject> => ({
assets,
...color,
},
plugins: without(plugins, "initPlugins"),
plugins: without(plugins, "initPlugins", "evalPlugin"),
themes: without(themes, "initThemes"),
commands: without(commands, "patchCommands"),
storage,