GoonCord/src/core/fixes.ts

27 lines
920 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
*/
2024-03-07 12:35:07 +08:00
import { logger } from "@lib/utils/logger";
2024-03-06 01:57:59 +08:00
import { FluxDispatcher, moment } from "@metro/common";
2023-03-07 23:12:41 +00:00
2024-03-06 01:57:59 +08:00
function onDispatch({ locale }: { locale: string; }) {
2023-03-07 23:12:41 +00:00
// 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 () => {
2024-03-06 01:57:59 +08:00
FluxDispatcher.subscribe("I18N_LOAD_SUCCESS", onDispatch);
};