perf: インスタンスデフォルトテーマを予めjson5 -> jsonに変換しておくことでjson5を初期バンドルに含めずに済むように

Co-authored-by: Syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
ThatOneCalculator 2023-06-02 23:28:21 -07:00
parent c1f699789b
commit 6956522694
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
2 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,4 @@
import * as JSON5 from "json5";
import { IsNull, MoreThan } from "typeorm";
import config from "@/config/index.js";
import { fetchMeta } from "@/misc/fetch-meta.js";
@ -462,8 +463,13 @@ export default define(meta, paramDef, async (ps, me) => {
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH,
emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis),
defaultLightTheme: instance.defaultLightTheme,
defaultDarkTheme: instance.defaultDarkTheme,
// クライアントの手間を減らすためあらかじめJSONに変換しておく
defaultLightTheme: instance.defaultLightTheme
? JSON.stringify(JSON5.parse(instance.defaultLightTheme))
: null,
defaultDarkTheme: instance.defaultDarkTheme
? JSON.stringify(JSON5.parse(instance.defaultDarkTheme))
: null,
ads:
instance.privateMode && !me
? []

View File

@ -27,7 +27,6 @@ import {
defineAsyncComponent,
} from "vue";
import { compareVersions } from "compare-versions";
import JSON5 from "json5";
import widgets from "@/widgets";
import directives from "@/directives";
@ -312,12 +311,12 @@ import { getAccountFromId } from "@/scripts/get-account-from-id";
if (instance.defaultLightTheme != null)
ColdDeviceStorage.set(
"lightTheme",
JSON5.parse(instance.defaultLightTheme),
JSON.parse(instance.defaultLightTheme),
);
if (instance.defaultDarkTheme != null)
ColdDeviceStorage.set(
"darkTheme",
JSON5.parse(instance.defaultDarkTheme),
JSON.parse(instance.defaultDarkTheme),
);
defaultStore.set("themeInitial", false);
}