mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-31 00:53: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';
|
'use server';
|
||||||
|
|
||||||
import { auth } from '@clerk/nextjs/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 { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||||
|
|
||||||
import { db } from '@/lib/db';
|
import { db } from '@/lib/db';
|
||||||
|
@ -74,6 +74,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revalidateTag(`board-${id}`);
|
||||||
revalidatePath(`/board/${id}`);
|
revalidatePath(`/board/${id}`);
|
||||||
return { data: board };
|
return { data: board };
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { notFound, redirect } from 'next/navigation';
|
||||||
import { db } from '@/lib/db';
|
import { db } from '@/lib/db';
|
||||||
import { BoardNavbar } from './_components/board-navbar';
|
import { BoardNavbar } from './_components/board-navbar';
|
||||||
import { BoardLiveblocks } from './_components/board-liveblocks';
|
import { BoardLiveblocks } from './_components/board-liveblocks';
|
||||||
|
import { unstable_cache } from 'next/cache';
|
||||||
|
|
||||||
export async function generateMetadata(props: {
|
export async function generateMetadata(props: {
|
||||||
params: Promise<{ boardId: string }>;
|
params: Promise<{ boardId: string }>;
|
||||||
|
@ -37,13 +38,23 @@ const BoardIdLayout = async (props: {
|
||||||
|
|
||||||
if (!orgId) redirect('/select-org');
|
if (!orgId) redirect('/select-org');
|
||||||
|
|
||||||
const board = await db.board.findUnique({
|
const getBoard = unstable_cache(
|
||||||
where: {
|
async () => {
|
||||||
id: params.boardId,
|
return await db.board.findUnique({
|
||||||
orgId,
|
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();
|
if (!board) notFound();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue