import { revalidatePath } from "next/cache"; | ||
import { NextRequest } from "next/server"; | ||
| ||
export async function GET(request: NextRequest) { | ||
const path = request.nextUrl.searchParams.get("path"); | ||
| ||
if (path) { | ||
revalidatePath(path); | ||
return Response.json({ revalidated: true, now: Date.now() }); | ||
} | ||
| ||
return Response.json({ | ||
revalidated: false, | ||
now: Date.now(), | ||
message: "Missing path to revalidate", | ||
}); | ||
} |
25 lines hidden | ||
useSubscribe({ | ||
table: "branch_authors", | ||
filter: `user_id=eq.${user.id}`, | ||
// If we are added to a whole new branch we need to reload | ||
if (!payload.eventType) return; | ||
reloadQuery().then((br) => { | ||
setBranches(br || []); | ||
}); | ||
}, | ||
}); | ||
| ||
// console.log("settings up branch_reads listener"); | ||
useSubscribe({ | ||
table: "branch_reads", | ||
filter: `user_id=eq.${user.id}`, | ||
if (!payload.eventType) return; | ||
reloadQuery().then((br) => { | ||
setBranches(br || []); | ||
}); | ||
26 lines hidden |
24 lines hidden | ||
data: { session }, | ||
} = await supabase.auth.getSession(); | ||
| ||
// be chill about revalidating | ||
if (req.nextUrl.pathname === "/api/revalidate") { | ||
return res; | ||
} | ||
| ||
// Load or redirect / based on logged in & cookies | ||
if (req.nextUrl.pathname === "/") { | ||
if (!session) { | ||
161 lines hidden |
"use client"; | ||
| ||
import { useCurrentBranch } from "@/contexts/BranchProvider"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect, useRef } from "react"; | ||
import { toast } from "sonner"; | ||
| ||
export const PushRefresh = () => { | ||
const router = useRouter(); | ||
const latestPush = useRef<string>(); | ||
const branch = useCurrentBranch(); | ||
| ||
useEffect(() => { | ||
const latest = branch.latest_sha || ""; | ||
| ||
if (!latestPush.current) { | ||
latestPush.current = latest; | ||
return; | ||
} | ||
| ||
if (latestPush.current !== latest) { | ||
toast.info("New push detected, updating branch…"); | ||
latestPush.current = latest; | ||
router.refresh(); | ||
} | ||
}, [branch.latest_sha]); | ||
| ||
return null; | ||
}; |
34 lines hidden | ||
} from "@/primitives/icons"; | ||
import { useDropzone } from "react-dropzone"; | ||
import { Alert } from "@/primitives/Alert"; | ||
import { useRouter } from "next/navigation"; | ||
| ||
export const UserForm = (props: { | ||
discordToken: string; | ||
discordClientId: string; | ||
}) => { | ||
const router = useRouter(); | ||
const supabase = clientClient(); | ||
const authenticatedUser = useUser(); | ||
if (!authenticatedUser) { | ||
175 lines hidden | ||
throw error; | ||
} | ||
| ||
}; | ||
| ||
return ( | ||
394 lines hidden |
24 lines hidden | ||
teamUrl, | ||
null, | ||
() => { | ||
// don't block on this, but revalidate list type for next page visit | ||
fetch(`/api/revalidate?path=/${teamUrl}/${type}`); | ||
| ||
if (type === "branches") { | ||
return recentBranchesQuery(client, user!.id, teamUrl); | ||
} else { | ||
15 lines hidden |
41 lines hidden | ||
import dynamic from "next/dynamic"; | ||
import { notFound } from "next/navigation"; | ||
import { PropsWithChildren, Suspense } from "react"; | ||
import { PushRefresh } from "./PushRefresh"; | ||
| ||
export const runtime = "edge"; | ||
| ||
76 lines hidden | ||
loggedOutBranch={loggedOutBranch} | ||
permissions={share?.permissions} | ||
> | ||
<PushRefresh /> | ||
<Suspense> | ||
{branch && ( | ||
<BottomBar | ||
370 lines hidden |
7 lines hidden | ||
import { EditableText, Text } from "@/primitives/Text"; | ||
import debounce from "lodash.debounce"; | ||
import Link from "next/link"; | ||
import { useRouter } from "next/navigation"; | ||
import { useCallback, useState } from "react"; | ||
| ||
export const Title = ({ | ||
8 lines hidden | ||
const [title, setTitle] = useState(_title || fallbackTitle); | ||
const supabase = clientClient(); | ||
const value = title; | ||
const router = useRouter() | ||
| ||
useSubscribe({ | ||
table: "branches", | ||
9 lines hidden | ||
const debouncedChangeHandler = useCallback( | ||
debounce((title: string) => { | ||
supabase.from("branches").update({ title }).eq("id", branchId).then(); | ||
router.refresh() | ||
}, 300), | ||
[], | ||
); | ||
18 lines hidden |
287 lines hidden | ||
data-id={repo.id} | ||
> | ||
<SidebarRepo | ||
prefetch={true} | ||
href={`/${teamUrl}/${repo.repo.url}`} | ||
style={{ fontSize: 13 }} | ||
team={teamUrl} | ||
97 lines hidden |
4 lines hidden | ||
import { IconButtonWithBorder } from "@/primitives/Icon"; | ||
import { IconMenu } from "@/primitives/icons"; | ||
| ||
const handleToggle = () => { | ||
const page = document.querySelector("#pierre-page") as HTMLElement; | ||
page.style.gridTemplateColumns = `var(--sidebar-width) auto`; | ||
19 lines hidden |
32 lines hidden | ||
count?: number; | ||
disabled?: boolean; | ||
href?: string; | ||
id?: string; | ||
prefetch?: boolean; | ||
style?: React.CSSProperties; | ||
85 lines hidden |
useRouter
to PushRefresh
revalidate