[Bugfix] Fix forced Hindi timestamps
This commit is contained in:
parent
293c256dc9
commit
2201ff3a1d
6 changed files with 38 additions and 42 deletions
|
@ -3,9 +3,9 @@ import { patchCommands } from "@lib/commands";
|
|||
import { initPlugins } from "@lib/plugins";
|
||||
import { patchAssets } from "@ui/assets";
|
||||
import initSettings from "@ui/settings";
|
||||
import fixTheme from "@ui/fixTheme";
|
||||
import windowObject from "@lib/windowObject";
|
||||
import initFixes from "@lib/fixes";
|
||||
import logger from "@lib/logger";
|
||||
import windowObject from "@lib/windowObject";
|
||||
|
||||
// This logs in the native logging implementation, e.g. logcat
|
||||
console.log("Hello from Vendetta!");
|
||||
|
@ -17,7 +17,7 @@ console.log("Hello from Vendetta!");
|
|||
patchLogHook(),
|
||||
patchAssets(),
|
||||
patchCommands(),
|
||||
fixTheme(),
|
||||
initFixes(),
|
||||
initSettings(),
|
||||
]);
|
||||
|
||||
|
|
33
src/lib/fixes.ts
Normal file
33
src/lib/fixes.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { FluxDispatcher, moment } from "@metro/common";
|
||||
import { findByProps, findByStoreName } from "@metro/filters";
|
||||
import logger from "@lib/logger";
|
||||
|
||||
const ThemeManager = findByProps("updateTheme", "overrideTheme");
|
||||
const AMOLEDThemeManager = findByProps("setAMOLEDThemeEnabled");
|
||||
const ThemeStore = findByStoreName("ThemeStore");
|
||||
const UnsyncedUserSettingsStore = findByStoreName("UnsyncedUserSettingsStore");
|
||||
|
||||
function onDispatch({ locale }: { locale: string }) {
|
||||
// Theming
|
||||
// Based on https://github.com/Aliucord/AliucordRN/blob/main/src/ui/patchTheme.ts
|
||||
try {
|
||||
const theme = ThemeStore.theme || "dark";
|
||||
ThemeManager.overrideTheme(theme);
|
||||
if (AMOLEDThemeManager && UnsyncedUserSettingsStore.useAMOLEDTheme === 2) AMOLEDThemeManager.setAMOLEDThemeEnabled(true);
|
||||
} catch(e) {
|
||||
logger.error("Failed to fix theme...", e);
|
||||
}
|
||||
|
||||
// Timestamps
|
||||
try {
|
||||
// TODO: Test if this works with all locales
|
||||
moment.locale(locale.toLowerCase());
|
||||
} catch(e) {
|
||||
logger.error("Failed to fix timestamps...", e);
|
||||
}
|
||||
|
||||
// We're done here!
|
||||
FluxDispatcher.unsubscribe("I18N_LOAD_START", onDispatch);
|
||||
}
|
||||
|
||||
export default () => FluxDispatcher.subscribe("I18N_LOAD_START", onDispatch);
|
|
@ -24,4 +24,4 @@ export const React = window.React as typeof import("react");
|
|||
export { ReactNative } from "@metro/hoist";
|
||||
|
||||
// Moment
|
||||
export { moment } from "@metro/hoist";
|
||||
export const moment = findByProps("isMoment") as typeof import("moment");
|
|
@ -1,5 +1,4 @@
|
|||
import { MetroModules, PropsFinder, PropsFinderAll } from "@types";
|
||||
import { moment } from "@metro/hoist";
|
||||
|
||||
// Metro require
|
||||
declare const __r: (moduleId: number) => any;
|
||||
|
@ -29,17 +28,12 @@ for (const key in window.modules) {
|
|||
const filterModules = (modules: MetroModules, single = false) => (filter: (m: any) => boolean) => {
|
||||
const found = [];
|
||||
|
||||
// Get the previous moment locale
|
||||
const previousLocale = moment?.locale();
|
||||
|
||||
for (const key in modules) {
|
||||
const id = Number(key);
|
||||
const module = modules[id]?.publicModule?.exports;
|
||||
|
||||
if (!modules[id].isInitialized) try {
|
||||
__r(id);
|
||||
// Set moment locale, sort of crappy fix but works I guess
|
||||
if (previousLocale && previousLocale !== moment.locale()) moment.locale(previousLocale);
|
||||
} catch {};
|
||||
|
||||
if (!module) {
|
||||
|
|
|
@ -12,6 +12,3 @@ export const ReactNative = basicFind("AppRegistry") as typeof import("react-nati
|
|||
|
||||
// Export Discord's constants
|
||||
export const constants = basicFind("AbortCodes");
|
||||
|
||||
// Export moment
|
||||
export const moment = basicFind("isMoment") as typeof import("moment");
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// Based on https://github.com/Aliucord/AliucordRN/blob/main/src/ui/patchTheme.ts
|
||||
// Literally could not figure this out, many thanks
|
||||
|
||||
import { FluxDispatcher } from "@metro/common";
|
||||
import { findByProps, findByStoreName } from "@metro/filters";
|
||||
import logger from "@lib/logger";
|
||||
|
||||
// TODO: Move these to common modules?
|
||||
const ThemeManager = findByProps("updateTheme", "overrideTheme");
|
||||
const AMOLEDThemeManager = findByProps("setAMOLEDThemeEnabled");
|
||||
const ThemeStore = findByStoreName("ThemeStore");
|
||||
const UnsyncedUserSettingsStore = findByStoreName("UnsyncedUserSettingsStore");
|
||||
|
||||
function override() {
|
||||
const theme = ThemeStore.theme || "dark";
|
||||
ThemeManager.overrideTheme(theme);
|
||||
|
||||
if (AMOLEDThemeManager && UnsyncedUserSettingsStore.useAMOLEDTheme === 2) AMOLEDThemeManager.setAMOLEDThemeEnabled(true);
|
||||
FluxDispatcher.unsubscribe("I18N_LOAD_START", override);
|
||||
}
|
||||
|
||||
export default function fixTheme() {
|
||||
try {
|
||||
if (ThemeStore) FluxDispatcher.subscribe("I18N_LOAD_START", override);
|
||||
} catch(e) {
|
||||
logger.error("Failed to fix theme...", e)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue