[Global] Fixes for latest Discord versions

This commit is contained in:
Beef 2023-03-30 19:56:32 +01:00
parent 9157cadec9
commit ac4da3032e
5 changed files with 15 additions and 16 deletions

View file

@ -1,7 +1,7 @@
import { find, findByProps } from "@metro/filters";
// Discord
export { constants } from "@lib/preinit";
export const constants = findByProps("API_HOST");
export const channels = findByProps("getVoiceChannelId");
export const i18n = findByProps("Messages");
export const url = findByProps("openURL", "openDeeplink");

View file

@ -12,12 +12,6 @@ window.React = basicFind("createElement") as typeof import("react");
// Export ReactNative
export const ReactNative = basicFind("AppRegistry") as typeof import("react-native");
// Export Discord's constants
export const constants = basicFind("AbortCodes");
// Export Discord's color module
export const color = basicFind("SemanticColor");
// Export chroma.js
export const chroma = basicFind("brewer") as typeof import("chroma-js");

View file

@ -2,7 +2,8 @@ import { DCDFileManager, MMKVManager, StorageBackend } from "@types";
import { ReactNative as RN } from "@metro/common";
const MMKVManager = window.nativeModuleProxy.MMKVManager as MMKVManager;
const DCDFileManager = window.nativeModuleProxy.DCDFileManager as DCDFileManager;
//! 173.10 renamed this to RTNFileManager.
const DCDFileManager = (window.nativeModuleProxy.DCDFileManager ?? window.nativeModuleProxy.RTNFileManager) as DCDFileManager;
export const createMMKVBackend = (store: string): StorageBackend => ({
get: async () => JSON.parse((await MMKVManager.getItem(store)) ?? "{}"),

View file

@ -1,10 +1,14 @@
import { DCDFileManager, Indexable, Theme, ThemeData } from "@types";
import { findByProps } from "@metro/filters";
import { ReactNative, chroma } from "@metro/common";
import { instead } from "@lib/patcher";
import { color } from "@lib/preinit";
import { createFileBackend, createMMKVBackend, createStorage, wrapSync, awaitSyncWrapper } from "@lib/storage";
import { safeFetch } from "@utils";
//! As of 173.10, early-finding this does not work.
// Somehow, this is late enough, though?
export const color = findByProps("SemanticColor");
const DCDFileManager = window.nativeModuleProxy.DCDFileManager as DCDFileManager;
export const themes = wrapSync(createStorage<Indexable<Theme>>(createMMKVBackend("VENDETTA_THEMES")));