Skip to content

Commit

Permalink
Remove loading states; just use nprogress
Browse files Browse the repository at this point in the history
  • Loading branch information
switz committed Nov 22, 2024
1 parent 366ce3e commit 24305c9
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 43 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"mousetrap": "1.6.5",
"next": "15.0.3",
"next-redux-wrapper": "8.1.0",
"nextjs-toploader": "^3.7.15",
"node-device-detector": "^2.1.0",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106",
Expand Down
46 changes: 30 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MainLayoutProps } from '@/app/(main)/(home)/layout';
import { useIsMobile } from '@/app/(main)/(home)/page';
import { isMobile } from '@/app/(main)/(home)/page';
import { fetchShow } from '@/app/queries';
import SongsColumn from '@/components/SongsColumn';
import TapesColumn from '@/components/TapesColumn';
Expand All @@ -12,7 +12,7 @@ export default async function Page(props: MainLayoutProps) {

const { children } = props;

const isMobile = useIsMobile();
const isMobileClient = await isMobile();
const { artistSlug, year, month, day } = params;

if (!year || !month || !day) return notFound();
Expand All @@ -22,7 +22,7 @@ export default async function Page(props: MainLayoutProps) {
return (
<React.Fragment key={[artistSlug, year, month, day].join('::')}>
<SongsColumn artistSlug={artistSlug} year={year} month={month} day={day} show={show} />
{!isMobile && (
{!isMobileClient && (
<TapesColumn artistSlug={artistSlug} year={year} month={month} day={day} show={show} />
)}
{children}
Expand Down
10 changes: 0 additions & 10 deletions src/app/(main)/(home)/[artistSlug]/[year]/loading.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/(main)/(home)/[artistSlug]/loading.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/(main)/(home)/[artistSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { API_DOMAIN } from '@/lib/constants';
import { Tape } from '@/types';
import ky from 'ky-universal';
import { notFound } from 'next/navigation';
import { useIsMobile } from '../page';
import { isMobile } from '../page';
import React from 'react';

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

if (useIsMobile()) return null;
if (await isMobile()) return null;

const randomShow = await fetchRandomShow(artistSlug).catch((err) => {
const statusCode = err?.response?.status;
Expand Down
10 changes: 5 additions & 5 deletions src/app/(main)/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { headers } from 'next/headers';
import parser from 'ua-parser-js';
import { headers, type UnsafeUnwrappedHeaders } from 'next/headers';

import ShowsColumn from '@/components/ShowsColumn';
import SongsColumn from '@/components/SongsColumn';
import TapesColumn from '@/components/TapesColumn';
import YearsColumn from '@/components/YearsColumn';
import { fetchRandomShow } from './[artistSlug]/page';
import React from 'react';
import { fetchRandomShow } from './[artistSlug]/page';

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

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

export default async function Page() {
if (useIsMobile()) return null;
if (await isMobile()) return null;

const artistSlug = 'grateful-dead';

Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Roboto } from 'next/font/google';
import dns from 'node:dns';
import React from 'react';
import Providers from './Providers';
import NextTopLoader from 'nextjs-toploader';

// https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012
dns.setDefaultResultOrder('ipv4first');
Expand All @@ -19,6 +20,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<link rel="icon" href="/favicon.ico" />
</head>
<body className={roboto.className}>
<NextTopLoader />
<Link href="https://en.wikipedia.org/wiki/Phil_Lesh" target="_blank">
<div className="fixed top-0 z-10 h-2 w-full bg-black" />
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ const Row = ({
{...props}
>
{loading && <RowLoading />}
{/* {isPending && (
{isPending && (
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 opacity-40">
<Spinner />
</div>
)} */}
)}
{isPending && <div className="w-2 animate-pulse bg-black/30" />}

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

0 comments on commit 24305c9

Please sign in to comment.