fix: show existing screenshots in edit mode, fix drag reorder jank, bump version to 2026.1.102

This commit is contained in:
2026-05-16 18:33:56 +08:00
parent 0ff27b613d
commit f4eab9c8e0
5 changed files with 34 additions and 8 deletions
+29 -3
View File
@@ -1,8 +1,9 @@
import { notFound } from "next/navigation"
import { db } from "@/lib/db/index"
import { games, gameVersions, performanceEntries, gamePlatformSupport } from "@/lib/db/schema"
import { games, gameVersions, performanceEntries, gamePlatformSupport, entryScreenshots } from "@/lib/db/schema"
import { eq, sql } from "drizzle-orm"
import { GameEntryWizard, type GameVersionInfo } from "@/components/wizard/game-entry-wizard"
import { getR2PublicUrl } from "@/lib/storage/r2-client"
// This page needs live data — skip static generation at build time
export const dynamic = "force-dynamic"
@@ -77,14 +78,39 @@ export default async function SubmitBenchmarkPage({
}
// If editing, fetch the existing performance entry
let editEntry = null
let editEntry: any = null
if (edit) {
const [entry] = await db
.select()
.from(performanceEntries)
.where(eq(performanceEntries.id, edit))
.limit(1)
editEntry = entry ?? null
if (entry) {
const publicUrl = getR2PublicUrl()
const screenshots = await db
.select({
id: entryScreenshots.id,
storageKey: entryScreenshots.storageKey,
orderIndex: entryScreenshots.orderIndex,
width: entryScreenshots.width,
height: entryScreenshots.height,
})
.from(entryScreenshots)
.where(eq(entryScreenshots.entryId, entry.id))
.orderBy(entryScreenshots.orderIndex)
editEntry = {
...entry,
screenshots: screenshots.map((ss) => ({
id: ss.id,
url: `${publicUrl}/${ss.storageKey}`,
width: ss.width,
height: ss.height,
orderIndex: ss.orderIndex,
})),
}
}
}
// Determine default version: when editing, use the entry's version;