From 09ee5e68627bd1448c0c6e319d72e81b4ed0bec1 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 21 May 2024 20:45:13 +0200 Subject: [PATCH] Extract dayjs setup into file --- src/index.tsx | 10 +--------- src/lib/dayjs/Setup.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 src/lib/dayjs/Setup.ts diff --git a/src/index.tsx b/src/index.tsx index 5cafd31d..ba733b2c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,20 +8,12 @@ import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; -import dayjs from 'dayjs'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; import { App } from '@/App'; import '@/index.css'; // roboto font import '@fontsource/roboto'; import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts'; -import { loadDayJsLocale } from '@/util/language.tsx'; - -dayjs.extend(customParseFormat); - -loadDayJsLocale(navigator.language).then(() => { - dayjs.locale(navigator.language); -}); +import '@/lib/dayjs/Setup.ts'; if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then((registration) => { diff --git a/src/lib/dayjs/Setup.ts b/src/lib/dayjs/Setup.ts new file mode 100644 index 00000000..8189769e --- /dev/null +++ b/src/lib/dayjs/Setup.ts @@ -0,0 +1,17 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +import dayjs from 'dayjs'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import { loadDayJsLocale } from '@/util/language.tsx'; + +dayjs.extend(customParseFormat); + +loadDayJsLocale(navigator.language).then(() => { + dayjs.locale(navigator.language); +});