GoonCord/src/core/fixes.ts

26 lines
913 B
TypeScript
Raw Normal View History

2024-02-29 20:07:55 +08:00
/**
* Why do we need this exactly? It's simple, to fight the side effects caused by when you
* initialize modules not in the right time or when you're not supposed to.
* Back then, we had major bugs like the mixing of light and dark themes and AMOLED option getting ignored.
* Nowadays, there are only three which I can spot: Hindi timestamps, crashing on some native components and slower startup time.
* - @pylixonly
*/
2023-03-07 23:12:41 +00:00
import { FluxDispatcher, moment } from "@metro/common";
import logger from "@lib/utils/logger";
2023-03-07 23:12:41 +00:00
function onDispatch({ locale }: { locale: string }) {
// Timestamps
try {
moment.locale(locale.toLowerCase());
2024-02-29 20:07:55 +08:00
} catch (e) {
2023-03-07 23:12:41 +00:00
logger.error("Failed to fix timestamps...", e);
}
// We're done here!
2023-03-08 20:49:41 +00:00
FluxDispatcher.unsubscribe("I18N_LOAD_SUCCESS", onDispatch);
2023-03-07 23:12:41 +00:00
}
2024-02-29 20:07:55 +08:00
export default () => {
FluxDispatcher.subscribe("I18N_LOAD_SUCCESS", onDispatch)
};