Skip to content

Commit

Permalink
fix: remove skeleton when app load but in 404
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Nov 9, 2024
1 parent aea25fc commit 54d4e52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useAppIsReady } from "./atoms/app"
import { useUISettingKey } from "./atoms/settings/ui"
import { navigateEntry } from "./hooks/biz/useNavigateEntry"
import { applyAfterReadyCallbacks } from "./initialize/queue"
import { removeAppSkeleton } from "./lib/app"
import { appLog } from "./lib/log"
import { Titlebar } from "./modules/app/Titlebar"
import { RootProviders } from "./providers/root-providers"
Expand Down Expand Up @@ -53,7 +54,7 @@ const AppLayer = () => {
const appIsReady = useAppIsReady()

useEffect(() => {
document.querySelector("#app-skeleton")?.remove()
removeAppSkeleton()

const doneTime = Math.trunc(performance.now())
window.analytics?.capture("ui_render_init", {
Expand Down
3 changes: 2 additions & 1 deletion apps/renderer/src/components/common/ErrorElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useRef } from "react"
import { isRouteErrorResponse, useNavigate, useRouteError } from "react-router-dom"
import { toast } from "sonner"

import { removeAppSkeleton } from "~/lib/app"
import { attachOpenInEditor } from "~/lib/dev"
import { getNewIssueUrl } from "~/lib/issues"
import { clearLocalPersistStoreData } from "~/store/utils/clear"
Expand All @@ -21,7 +22,7 @@ export function ErrorElement() {
const stack = error instanceof Error ? error.stack : null

useEffect(() => {
document.querySelector("#app-skeleton")?.remove()
removeAppSkeleton()
}, [])

useEffect(() => {
Expand Down
5 changes: 5 additions & 0 deletions apps/renderer/src/components/common/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Location } from "react-router-dom"
import { useLocation, useNavigate } from "react-router-dom"

import { isElectronBuild } from "~/constants"
import { removeAppSkeleton } from "~/lib/app"

import { PoweredByFooter } from "./PoweredByFooter"

Expand Down Expand Up @@ -37,6 +38,10 @@ export const NotFound = () => {
),
)
}, [location])

useEffect(() => {
removeAppSkeleton()
}, [])
const navigate = useNavigate()
return (
<div className="prose center m-auto size-full flex-col dark:prose-invert">
Expand Down
3 changes: 3 additions & 0 deletions apps/renderer/src/lib/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const removeAppSkeleton = () => {
document.querySelector("#app-skeleton")?.remove()
}

0 comments on commit 54d4e52

Please sign in to comment.