Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"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");
|
||||
}
|
||||
Reference in New Issue
Block a user