Skip to content

Commit d61281f

Browse files
committed
refresfed state sset to false
removed revalidatePath from blob
1 parent 2777b8b commit d61281f

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
import { NextRequest, NextResponse } from "next/server"
2-
import { session, userGitHubClient } from "@/composition"
3-
import { makeUnauthenticatedAPIErrorResponse } from "@/common"
4-
import { revalidatePath } from "next/cache"
5-
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { session, userGitHubClient } from "@/composition";
3+
import { makeUnauthenticatedAPIErrorResponse } from "@/common";
64

75
interface GetBlobParams {
8-
owner: string
9-
repository: string
10-
path: [string]
6+
owner: string;
7+
repository: string;
8+
path: [string];
119
}
1210

13-
export async function GET(req: NextRequest, { params }: { params: Promise<GetBlobParams> } ) {
14-
const isAuthenticated = await session.getIsAuthenticated()
11+
export async function GET(
12+
req: NextRequest,
13+
{ params }: { params: Promise<GetBlobParams> }
14+
) {
15+
const isAuthenticated = await session.getIsAuthenticated();
1516
if (!isAuthenticated) {
16-
return makeUnauthenticatedAPIErrorResponse()
17+
return makeUnauthenticatedAPIErrorResponse();
1718
}
18-
const { path: paramsPath, owner, repository } = await params
19-
const path = paramsPath.join("/")
19+
const { path: paramsPath, owner, repository } = await params;
20+
const path = paramsPath.join("/");
2021
const item = await userGitHubClient.getRepositoryContent({
2122
repositoryOwner: owner,
2223
repositoryName: repository,
2324
path: path,
24-
ref: req.nextUrl.searchParams.get("ref") ?? undefined
25-
})
26-
const url = new URL(item.downloadURL)
25+
ref: req.nextUrl.searchParams.get("ref") ?? undefined,
26+
});
27+
const url = new URL(item.downloadURL);
2728
const imageRegex = /\.(jpg|jpeg|png|webp|avif|gif)$/;
28-
const res = await fetch(url, { next: { revalidate: 6000 } })
29-
const file = await res.blob()
30-
revalidatePath('/(authed)/projects')
31-
const headers = new Headers()
32-
if (res.status !== 200) {
33-
headers.set("Content-Type", "text/plain");
34-
headers.set("Cache-Control", `max-age=3000`)
35-
}
29+
const res = await fetch(url);
30+
const file = await res.blob();
31+
32+
const headers = new Headers();
3633
if (new RegExp(imageRegex).exec(path)) {
37-
const cacheExpirationInSeconds = 60 * 60 * 24 * 30 // 30 days
34+
const cacheExpirationInSeconds = 60 * 60 * 24 * 30; // 30 days
3835
headers.set("Content-Type", "image/*");
39-
headers.set("Cache-Control", `max-age=${cacheExpirationInSeconds}`)
40-
}
41-
return new NextResponse(file, { status: 200, headers })
36+
headers.set("Cache-Control", `max-age=${cacheExpirationInSeconds}`);
37+
} else {
38+
headers.set("Content-Type", "text/plain");
39+
}
40+
return new NextResponse(file, { status: 200, headers });
4241
}

src/features/projects/view/ProjectsContextProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ProjectsContextProvider = ({
1111
initialProjects?: Project[];
1212
children?: React.ReactNode;
1313
}) => {
14-
const [refreshed, setRefreshed] = useState<boolean>(true);
14+
const [refreshed, setRefreshed] = useState<boolean>(false);
1515
const [projects, setProjects] = useState<Project[]>(initialProjects || []);
1616

1717
const hasProjectChanged = (value: Project[]) =>

0 commit comments

Comments
 (0)