fix: hide hidden models in style pro selector
This commit is contained in:
parent
39c8489e8f
commit
5ece717e31
@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
||||
import { z } from "zod";
|
||||
import { auth } from "@/app/(auth)/auth";
|
||||
import { generateCanvasImage } from "@/lib/canvas/generate-image";
|
||||
import { getSystemSetting, getUserById } from "@/lib/db/queries";
|
||||
import { getSystemSetting } from "@/lib/db/queries";
|
||||
import {
|
||||
findStyleProImageModelByRef,
|
||||
getStyleProImageModelEntries,
|
||||
@ -196,13 +196,8 @@ export async function POST(request: Request) {
|
||||
|
||||
let selectedModelRef = config.modelId || undefined;
|
||||
if (body.modelId) {
|
||||
const currentUser = await getUserById({ id: session.user.id }).catch(
|
||||
() => null
|
||||
);
|
||||
const includeHidden =
|
||||
session.user.type === "admin" || Boolean(currentUser?.isHighVip);
|
||||
const imageModelEntries = await getStyleProImageModelEntries({
|
||||
includeHidden,
|
||||
includeHidden: false,
|
||||
});
|
||||
const selectedModel = findStyleProImageModelByRef(
|
||||
imageModelEntries,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/app/(auth)/auth";
|
||||
import { getSystemSetting, getUserById } from "@/lib/db/queries";
|
||||
import { getSystemSetting } from "@/lib/db/queries";
|
||||
import {
|
||||
findStyleProImageModelByRef,
|
||||
getStyleProImageModelEntries,
|
||||
@ -23,13 +23,8 @@ export async function GET() {
|
||||
);
|
||||
}
|
||||
|
||||
const currentUser = await getUserById({ id: session.user.id }).catch(
|
||||
() => null
|
||||
);
|
||||
const includeHidden =
|
||||
session.user.type === "admin" || Boolean(currentUser?.isHighVip);
|
||||
const [entries, setting] = await Promise.all([
|
||||
getStyleProImageModelEntries({ includeHidden }),
|
||||
getStyleProImageModelEntries({ includeHidden: false }),
|
||||
getSystemSetting({ key: STYLE_PRO_CONFIG_KEY }).catch(() => null),
|
||||
]);
|
||||
const config = normalizeStyleProConfig(setting?.value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user