mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-30 16:43:37 +00:00
Finished Adding Chacing
This commit is contained in:
parent
be70b88925
commit
e0ba56659f
2 changed files with 19 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
'use server';
|
||||
|
||||
import { auth } from '@clerk/nextjs/server';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { revalidatePath, revalidateTag } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from '@/lib/db';
|
||||
|
@ -74,6 +74,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
};
|
||||
}
|
||||
|
||||
revalidateTag(`board-${id}`);
|
||||
revalidatePath(`/board/${id}`);
|
||||
return { data: board };
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@ import { notFound, redirect } from 'next/navigation';
|
|||
import { db } from '@/lib/db';
|
||||
import { BoardNavbar } from './_components/board-navbar';
|
||||
import { BoardLiveblocks } from './_components/board-liveblocks';
|
||||
import { unstable_cache } from 'next/cache';
|
||||
|
||||
export async function generateMetadata(props: {
|
||||
params: Promise<{ boardId: string }>;
|
||||
|
@ -37,13 +38,23 @@ const BoardIdLayout = async (props: {
|
|||
|
||||
if (!orgId) redirect('/select-org');
|
||||
|
||||
const board = await db.board.findUnique({
|
||||
where: {
|
||||
id: params.boardId,
|
||||
orgId,
|
||||
const getBoard = unstable_cache(
|
||||
async () => {
|
||||
return await db.board.findUnique({
|
||||
where: {
|
||||
id: params.boardId,
|
||||
orgId,
|
||||
},
|
||||
});
|
||||
},
|
||||
cacheStrategy: { ttl: 30, swr: 60 },
|
||||
});
|
||||
[`board-${params.boardId}`],
|
||||
{
|
||||
tags: [`board-${params.boardId}`],
|
||||
revalidate: false,
|
||||
}
|
||||
);
|
||||
|
||||
const board = await getBoard();
|
||||
|
||||
if (!board) notFound();
|
||||
|
||||
|
|
Loading…
Reference in a new issue