fix: hide hidden models in style pro selector
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-05-17 00:46:37 +08:00
parent 39c8489e8f
commit 5ece717e31
2 changed files with 4 additions and 14 deletions

View File

@ -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,

View File

@ -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);