Skip to content

Commit c988f64

Browse files
committed
fix(popup): delete popup param once displayed, ran format
1 parent bf122ea commit c988f64

7 files changed

Lines changed: 86 additions & 82 deletions

File tree

app/(feed)/explore/explore-page-client.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useCallback, useEffect, useState } from "react";
4-
import { useSearchParams } from "next/navigation";
4+
import { usePathname, useRouter, useSearchParams } from "next/navigation";
55
import { VideoCard } from "@/components/app/video/video-card";
66
import { getVideos, type VideoDetails } from "@/lib/video";
77
import { Spinner } from "@/components/ui/spinner";
@@ -45,6 +45,8 @@ export default function ExplorePageClient({
4545
initialTotalPages,
4646
initialError,
4747
}: ExplorePageClientProps) {
48+
const router = useRouter();
49+
const pathname = usePathname();
4850
const params = useSearchParams();
4951

5052
const shouldFetchInit = Boolean(initialError);
@@ -111,8 +113,14 @@ export default function ExplorePageClient({
111113
}, [fetchVideos, shouldFetchInit]);
112114

113115
useEffect(() => {
114-
setIsPopupOpen(params.has("popup"));
115-
}, [params]);
116+
if (!params.has("popup")) return;
117+
118+
const nextParams = new URLSearchParams(params.toString());
119+
nextParams.delete("popup");
120+
121+
const nextUrl = nextParams.toString() ? `${pathname}?${nextParams.toString()}` : pathname;
122+
router.replace(nextUrl, { scroll: false });
123+
}, [params, pathname, router]);
116124

117125
const loadMore = useCallback(() => {
118126
if (isLoading || isLoadingMore || !hasMore) return;

app/api/auth/logout/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ async function revokeCurrentBackendSession(token: string) {
7979
let revokeResponse: Response;
8080

8181
try {
82-
revokeResponse = await fetch(`${apiBaseUrl}/auth/sessions/${encodeURIComponent(currentSession.id)}`, {
83-
method: "DELETE",
84-
headers: authHeaders,
85-
});
82+
revokeResponse = await fetch(
83+
`${apiBaseUrl}/auth/sessions/${encodeURIComponent(currentSession.id)}`,
84+
{
85+
method: "DELETE",
86+
headers: authHeaders,
87+
},
88+
);
8689
} catch {
8790
return {
8891
ok: false,

components/app/video/comments.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ export function Comments({ videoId, initialComments, allowComments = true }: Com
345345
) : isUnavailable && !user ? (
346346
<div className="mb-8 flex flex-col items-center gap-4 p-4 text-center">
347347
<p className="text-sm text-muted-foreground">
348-
{errorMessage ?? "Authentication is temporarily unavailable, so posting comments is disabled."}
348+
{errorMessage ??
349+
"Authentication is temporarily unavailable, so posting comments is disabled."}
349350
</p>
350351
<Link href={buildServiceUnavailableHref(`/video/${videoId}#comments`)}>
351352
<Button variant="outline" className="rounded-full px-4 py-2 text-sm font-semibold">

context/auth-context.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { createContext, useCallback, useContext, useMemo, type ReactNode } from
44
import { useQuery } from "@tanstack/react-query";
55
import axios from "axios";
66
import { clearAuthSession, getCurrentUser } from "@/lib/auth/api";
7-
import {
8-
type ClientAuthStatus,
9-
resolveClientAuthState,
10-
} from "@/lib/auth/client-auth-state";
7+
import { type ClientAuthStatus, resolveClientAuthState } from "@/lib/auth/client-auth-state";
118
import { authQueryKeys } from "@/lib/auth/query";
129
import type { User } from "@/lib/users";
1310

lib/auth/client-auth-state.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
import { getApiErrorMessage } from "../api-error";
22
import type { User } from "../users";
33

4-
export type ClientAuthStatus =
5-
| "loading"
6-
| "authenticated"
7-
| "unauthenticated"
8-
| "unavailable";
4+
export type ClientAuthStatus = "loading" | "authenticated" | "unauthenticated" | "unavailable";
95

106
type ResolveClientAuthStateOptions = {
117
user: User | null | undefined;
128
isLoading: boolean;
139
error: unknown;
1410
};
1511

16-
export function resolveClientAuthState({
17-
user,
18-
isLoading,
19-
error,
20-
}: ResolveClientAuthStateOptions) {
12+
export function resolveClientAuthState({ user, isLoading, error }: ResolveClientAuthStateOptions) {
2113
const status: ClientAuthStatus = isLoading
2214
? "loading"
2315
: error

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"framer-motion": "^12.34.1",
2929
"hls.js": "^1.6.15",
3030
"lucide-react": "^0.564.0",
31-
"next": "16.1.6",
31+
"next": "^16.2.4",
3232
"next-themes": "^0.4.6",
3333
"radix-ui": "^1.4.3",
3434
"react": "19.2.3",

0 commit comments

Comments
 (0)