From ac768ece132fbf3f745d304563643a3422270fac Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 24 Jun 2023 11:43:37 -0700 Subject: [PATCH] fix: :alembic: ensure splash is removed upon load https://codeberg.org/calckey/calckey/pulls/10285#issuecomment-951231 --- packages/client/src/init.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 5d9ae12f36..9593be829a 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -12,8 +12,9 @@ import "@phosphor-icons/web/fill"; //#region account indexedDB migration import { set } from "@/scripts/idb-proxy"; -if (localStorage.getItem("accounts") != null) { - set("accounts", JSON.parse(localStorage.getItem("accounts"))); +const accounts = localStorage.getItem("accounts") +if (accounts) { + set("accounts", JSON.parse(accounts)); localStorage.removeItem("accounts"); } //#endregion @@ -50,6 +51,18 @@ import { reactionPicker } from "@/scripts/reaction-picker"; import { getUrlWithoutLoginId } from "@/scripts/login-id"; import { getAccountFromId } from "@/scripts/get-account-from-id"; +function checkForSplash() { + const splash = document.getElementById("splash"); + // 念のためnullチェック(HTMLが古い場合があるため(そのうち消す)) + if (splash) { + splash.style.opacity = "0"; + splash.style.pointerEvents = "none"; + splash.addEventListener("transitionend", () => { + splash.remove(); + }); + } +} + (async () => { console.info(`Calckey v${version}`); @@ -105,7 +118,7 @@ import { getAccountFromId } from "@/scripts/get-account-from-id"; //#region Set lang attr const html = document.documentElement; - html.setAttribute("lang", lang); + html.setAttribute("lang", lang || "en-US"); //#endregion //#region loginId @@ -198,12 +211,7 @@ import { getAccountFromId } from "@/scripts/get-account-from-id"; directives(app); components(app); - const splash = document.getElementById("splash"); - // 念のためnullチェック(HTMLが古い場合があるため(そのうち消す)) - if (splash) - splash.addEventListener("transitionend", () => { - splash.remove(); - }); + checkForSplash(); // https://github.com/misskey-dev/misskey/pull/8575#issuecomment-1114239210 // なぜかinit.tsの内容が2回実行されることがあるため、mountするdivを1つに制限する @@ -231,10 +239,7 @@ import { getAccountFromId } from "@/scripts/get-account-from-id"; reactionPicker.init(); - if (splash) { - splash.style.opacity = "0"; - splash.style.pointerEvents = "none"; - } + checkForSplash(); // クライアントが更新されたか? const lastVersion = localStorage.getItem("lastVersion");