Fix catalog items missing due to page_id VARCHAR mismatch.
Local Build and Deploy / deploy (push) Successful in 56s
Local Build and Deploy / deploy (push) Successful in 56s
Use raw SQL for counts/loads/creates/moves so Habbo DBs with VARCHAR page_id and no AUTO_INCREMENT still show and persist furni. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
33a8a19820
commit
7bc0845932
6 files changed
+139
-79
No files matched your search
@@ -3,6 +3,12 @@ import { apiError, apiOk } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { loadCatalogItemsData } from "@/lib/services/catalog-items-loader";
|
||||
|
||||
function jsonSafe<T>(data: T): T {
|
||||
return JSON.parse(
|
||||
JSON.stringify(data, (_k, v) => (typeof v === "bigint" ? Number(v) : v)),
|
||||
) as T;
|
||||
}
|
||||
|
||||
export const GET = withAdmin(
|
||||
{ permission: PERMS.CATALOG_VIEW },
|
||||
async (request) => {
|
||||
@@ -11,6 +17,6 @@ export const GET = withAdmin(
|
||||
return apiError("Invalid pageId");
|
||||
}
|
||||
const data = await loadCatalogItemsData(pageId);
|
||||
return apiOk(data as unknown as Record<string, unknown>);
|
||||
return apiOk(jsonSafe(data) as unknown as Record<string, unknown>);
|
||||
},
|
||||
);
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
deletePage,
|
||||
getAncestors,
|
||||
getTreeFlat,
|
||||
safeItemCounts,
|
||||
getCatalogItemCounts,
|
||||
toInt,
|
||||
} from "@/lib/services/catalog-tree";
|
||||
import { rcon } from "@/lib/services/rcon";
|
||||
@@ -158,7 +158,7 @@ async function getChildren(
|
||||
_count: true,
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
safeItemCounts(ids),
|
||||
getCatalogItemCounts(ids),
|
||||
]);
|
||||
const childMap = Object.fromEntries(
|
||||
childCounts.map((c) => [toInt(c.parentId), c._count]),
|
||||
@@ -234,7 +234,7 @@ async function searchPages(q: string, isBc: boolean): Promise<TreeNode[]> {
|
||||
_count: true,
|
||||
})
|
||||
: Promise.resolve([]),
|
||||
safeItemCounts(ids),
|
||||
getCatalogItemCounts(ids),
|
||||
]);
|
||||
const childMap = Object.fromEntries(
|
||||
childCounts.map((c) => [toInt(c.parentId), c._count]),
|
||||
|
||||
Reference in new issue
Block a user