[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,17 +1,17 @@
import { findByProps } from "@metro/filters";
import { constants } from "@metro/common";
import { color } from "@lib/themes";
//! This module is only found on 165.0+, under the assumption that iOS 165.0 is the same as Android 165.0.
//* In 167.1, most if not all traces of the old color modules were removed.
//* In 168.6, Discord restructured EVERYTHING again. SemanticColor on this module no longer works when passed to a stylesheet. We must now use what you see below.
//? However, this is not all bad. The changes made in 168.6 do allow for better native-less theming.
const colorModule = findByProps("colors", "meta");
//* For both below, SemanticColor and RawColor are seemingly not used. Once again, what are Discord doing?
//* In 173.10, Discord restructured a lot of the app. These changes included making the color module impossible to early-find.
//? To stop duplication, it is now exported in our theming code.
//? These comments are preserved for historical purposes.
// const colorModule = findByProps("colors", "meta");
//? SemanticColor and default.colors are effectively ThemeColorMap
export const semanticColors = (constants.ThemeColorMap ?? colorModule?.colors);
export const semanticColors = (color?.default?.colors ?? constants?.ThemeColorMap);
//? RawColor and default.unsafe_rawColors are effectively Colors
//* Note that constants.Colors does still appear to exist on newer versions despite Discord not internally using it - what the fuck?
export const rawColors = (constants.Colors ?? colorModule?.unsafe_rawColors);
export const rawColors = (color?.default?.unsafe_rawColors ?? constants?.Colors);