perf(startup): instant splash, cached home and non-blocking auth
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

Renders a static branded splash immediately, restores the last user/API session from disk, hydrates home/library queries from localStorage, shows a home skeleton while the first request runs, drops blocking auth network checks, and redirects a streamless /player to home.
This commit is contained in:
1xDed committed 2026-11-28 17:08:08 +03:00
1 parent b1d9b40def
commit 205b655d00
12 files changed
+424 -158

No files matched your search

+95
View File
@@ -146,6 +146,101 @@ body.has-player-bar .home-sections {
padding-bottom: 10rem;
}
/* Instant frame while the first home request resolves or cache restores. */
.home-skeleton {
position: relative;
height: calc(100vh - 16px);
min-height: 560px;
overflow: hidden;
background:
radial-gradient(
circle at 75% 35%,
rgb(80 80 105 / 0.28),
transparent 55%
),
linear-gradient(135deg, #11131a 0%, #0a0b10 70%);
}
.home-skeleton-copy {
position: absolute;
left: clamp(2rem, 5vw, 4.5rem);
bottom: calc(var(--home-trending-space, 200px) + 3.5rem);
display: flex;
flex-direction: column;
gap: 0.9rem;
width: min(42rem, 55%);
}
.home-skeleton-pill,
.home-skeleton-title,
.home-skeleton-text,
.home-skeleton-buttons,
.home-skeleton-heading,
.home-skeleton-cards span {
display: block;
border-radius: 12px;
background: rgb(255 255 255 / 0.08);
}
.home-skeleton-pill {
width: 7em;
height: 2.1em;
}
.home-skeleton-title {
width: 92%;
height: clamp(2.4rem, 4vw, 4rem);
border-radius: 14px;
}
.home-skeleton-text {
width: 100%;
height: 5.2rem;
opacity: 0.7;
}
.home-skeleton-buttons {
width: 18rem;
height: 3.1rem;
border-radius: 999px;
background: rgb(255 255 255 / 0.14);
}
.home-skeleton-trending {
position: absolute;
left: clamp(2rem, 5vw, 4.5rem);
right: clamp(2rem, 5vw, 4.5rem);
bottom: 1.5rem;
}
.home-skeleton-heading {
width: 8em;
height: 1.4rem;
margin-bottom: 0.9rem;
}
.home-skeleton-cards {
display: flex;
gap: 0.75rem;
}
.home-skeleton-cards span {
flex: 0 0 auto;
width: clamp(200px, 21vw, 300px);
aspect-ratio: 16 / 9;
border-radius: 12px;
}
@media (max-width: 700px) {
.home-skeleton-copy {
width: 80%;
}
.home-skeleton-cards span {
width: 42vw;
}
}
@media (max-width: 900px) {
.home-header {
.home-nav-link {
+47 -7
View File
@@ -1,5 +1,5 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import React, { useCallback, useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import React, { useCallback, useEffect, useMemo } from "react";
import "./home.scss";
@@ -51,7 +51,7 @@ function Home() {
}
function HomeContent({ api, user }: { api: Api; user: UserDto }) {
const libraries = useSuspenseQuery({
const libraries = useQuery({
queryKey: ["libraries"],
queryFn: async () => {
const libs = await getUserViewApi(api).getUserViews({
@@ -62,11 +62,11 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
networkMode: "always",
});
const latestMedia = useSuspenseQuery(
const latestMedia = useQuery(
getLatestItemsQueryOptions(api, user.Id),
);
const resumeItemsVideo = useSuspenseQuery({
const resumeItemsVideo = useQuery({
queryKey: ["home", "resume", "video"],
queryFn: async () => {
const resumeItems = await getLibraryApi(api).getResumeItems({
@@ -80,7 +80,7 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
},
});
const resumeItemsAudio = useSuspenseQuery({
const resumeItemsAudio = useQuery({
queryKey: ["home", "resume", "audio"],
queryFn: async () => {
const resumeItems = await getLibraryApi(api).getResumeItems({
@@ -94,7 +94,7 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
},
});
const upNextItems = useSuspenseQuery({
const upNextItems = useQuery({
queryKey: ["home", "upNext"],
queryFn: async () => {
const upNext = await getShowApi(api).getNextUp({
@@ -178,6 +178,46 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
?.scrollIntoView({ behavior: "smooth", block: "start" });
}, []);
useEffect(() => {
if (!import.meta.env.DEV) return;
if (!libraries.data || !latestMedia.data) return;
performance.mark("blink:home-ready");
}, [libraries.data, latestMedia.data]);
// Render the frame immediately; only the expensive content waits for data.
if (!libraries.data || !latestMedia.data) {
return (
<main className="home-cinema">
<div className="home-frame">
<HomeHeader
libraries={libraries.data?.Items ?? []}
onNewAndPopular={scrollToNewAndPopular}
/>
<section
className="home-skeleton"
aria-busy="true"
aria-label="Loading home"
>
<div className="home-skeleton-copy">
<span className="home-skeleton-pill" />
<span className="home-skeleton-title" />
<span className="home-skeleton-text" />
<span className="home-skeleton-buttons" />
</div>
<div className="home-skeleton-trending">
<span className="home-skeleton-heading" />
<div className="home-skeleton-cards">
{[0, 1, 2, 3].map((index) => (
<span key={index} />
))}
</div>
</div>
</section>
</div>
</main>
);
}
return (
<main className="home-cinema">
<div className="home-frame">