23 lines
628 B
TypeScript
23 lines
628 B
TypeScript
"use server";
|
|
import { revalidatePath } from "next/cache";
|
|
import { cookies } from "next/headers";
|
|
import { setAppSetting } from "@/lib/db/appSettings";
|
|
import { isValidSort, SORT_COOKIE } from "@/lib/sort";
|
|
|
|
const ONE_YEAR = 60 * 60 * 24 * 365;
|
|
|
|
export async function setDefaultSort(sort: string) {
|
|
if (!isValidSort(sort)) return;
|
|
setAppSetting("defaultSort", sort);
|
|
(await cookies()).set(SORT_COOKIE, sort, {
|
|
path: "/",
|
|
maxAge: ONE_YEAR,
|
|
sameSite: "lax",
|
|
});
|
|
revalidatePath("/");
|
|
revalidatePath("/collection");
|
|
revalidatePath("/actress");
|
|
revalidatePath("/studios");
|
|
revalidatePath("/series");
|
|
}
|