Skip to content

Commit 24305c9

Browse files
committed
Remove loading states; just use nprogress
1 parent 366ce3e commit 24305c9

File tree

9 files changed

+45
-43
lines changed

9 files changed

+45
-43
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"mousetrap": "1.6.5",
3030
"next": "15.0.3",
3131
"next-redux-wrapper": "8.1.0",
32+
"nextjs-toploader": "^3.7.15",
3233
"node-device-detector": "^2.1.0",
3334
"react": "19.0.0-rc-66855b96-20241106",
3435
"react-dom": "19.0.0-rc-66855b96-20241106",

pnpm-lock.yaml

Lines changed: 30 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/(main)/(home)/[artistSlug]/[year]/[month]/[day]/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MainLayoutProps } from '@/app/(main)/(home)/layout';
2-
import { useIsMobile } from '@/app/(main)/(home)/page';
2+
import { isMobile } from '@/app/(main)/(home)/page';
33
import { fetchShow } from '@/app/queries';
44
import SongsColumn from '@/components/SongsColumn';
55
import TapesColumn from '@/components/TapesColumn';
@@ -12,7 +12,7 @@ export default async function Page(props: MainLayoutProps) {
1212

1313
const { children } = props;
1414

15-
const isMobile = useIsMobile();
15+
const isMobileClient = await isMobile();
1616
const { artistSlug, year, month, day } = params;
1717

1818
if (!year || !month || !day) return notFound();
@@ -22,7 +22,7 @@ export default async function Page(props: MainLayoutProps) {
2222
return (
2323
<React.Fragment key={[artistSlug, year, month, day].join('::')}>
2424
<SongsColumn artistSlug={artistSlug} year={year} month={month} day={day} show={show} />
25-
{!isMobile && (
25+
{!isMobileClient && (
2626
<TapesColumn artistSlug={artistSlug} year={year} month={month} day={day} show={show} />
2727
)}
2828
{children}

src/app/(main)/(home)/[artistSlug]/[year]/loading.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/(main)/(home)/[artistSlug]/loading.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/app/(main)/(home)/[artistSlug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { API_DOMAIN } from '@/lib/constants';
66
import { Tape } from '@/types';
77
import ky from 'ky-universal';
88
import { notFound } from 'next/navigation';
9-
import { useIsMobile } from '../page';
9+
import { isMobile } from '../page';
1010
import React from 'react';
1111

1212
export const fetchRandomShow = async (slug?: string): Promise<Tape | undefined> => {
@@ -23,7 +23,7 @@ export default async function Page(props) {
2323
const params = await props.params;
2424
const { artistSlug } = params;
2525

26-
if (useIsMobile()) return null;
26+
if (await isMobile()) return null;
2727

2828
const randomShow = await fetchRandomShow(artistSlug).catch((err) => {
2929
const statusCode = err?.response?.status;

src/app/(main)/(home)/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { headers } from 'next/headers';
12
import parser from 'ua-parser-js';
2-
import { headers, type UnsafeUnwrappedHeaders } from 'next/headers';
33

44
import ShowsColumn from '@/components/ShowsColumn';
55
import SongsColumn from '@/components/SongsColumn';
66
import TapesColumn from '@/components/TapesColumn';
77
import YearsColumn from '@/components/YearsColumn';
8-
import { fetchRandomShow } from './[artistSlug]/page';
98
import React from 'react';
9+
import { fetchRandomShow } from './[artistSlug]/page';
1010

11-
export const useIsMobile = () => {
12-
const headersList = (headers() as unknown as UnsafeUnwrappedHeaders);
11+
export const isMobile = async () => {
12+
const headersList = await headers();
1313
const userAgent = headersList.get('user-agent');
1414

1515
if (!userAgent) return false;
@@ -20,7 +20,7 @@ export const useIsMobile = () => {
2020
};
2121

2222
export default async function Page() {
23-
if (useIsMobile()) return null;
23+
if (await isMobile()) return null;
2424

2525
const artistSlug = 'grateful-dead';
2626

src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Roboto } from 'next/font/google';
22
import dns from 'node:dns';
33
import React from 'react';
44
import Providers from './Providers';
5+
import NextTopLoader from 'nextjs-toploader';
56

67
// https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012
78
dns.setDefaultResultOrder('ipv4first');
@@ -19,6 +20,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
1920
<link rel="icon" href="/favicon.ico" />
2021
</head>
2122
<body className={roboto.className}>
23+
<NextTopLoader />
2224
<Link href="https://en.wikipedia.org/wiki/Phil_Lesh" target="_blank">
2325
<div className="fixed top-0 z-10 h-2 w-full bg-black" />
2426
</Link>

src/components/Row.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ const Row = ({
7474
{...props}
7575
>
7676
{loading && <RowLoading />}
77-
{/* {isPending && (
77+
{isPending && (
7878
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 opacity-40">
7979
<Spinner />
8080
</div>
81-
)} */}
81+
)}
8282
{isPending && <div className="w-2 animate-pulse bg-black/30" />}
8383

8484
{!isPending && isActive && <div className="w-2 bg-black/75" />}

0 commit comments

Comments
 (0)