Recognize imported furniture by normalized classname and local IDs
CI / check (push) Successful in 1m30s
CI / deploy (push) Successful in 1m21s
CI / e2e (push) Successful in 22s

This commit is contained in:
Simo committed 2026-09-05 14:04:52 +02:00
1 parent 9dc6b8a261
commit a78d8256e0
7 files changed
+254 -46

No files matched your search

+6 -3
View File
@@ -1,3 +1,4 @@
import { normalizeClassname } from "@/lib/furni/classname";
/**
* Furniture search & listing — powered by official Habbo furnidata.
*
@@ -37,7 +38,9 @@ export async function listFurniture(
const perPage = Math.min(options.perPage || 50, 100);
const page = options.page || 1;
const search = options.search?.toLowerCase().trim() || "";
const importedSet = options.importedSet;
const importedSet = options.importedSet
? new Set([...options.importedSet].map(normalizeClassname))
: undefined;
try {
const map = await getOfficialHabboFurnidata();
@@ -58,8 +61,8 @@ export async function listFurniture(
if (importedSet) {
// Non-imported first (id desc), then imported (id desc).
items.sort((a, b) => {
const aImp = importedSet.has(a.classname) ? 1 : 0;
const bImp = importedSet.has(b.classname) ? 1 : 0;
const aImp = importedSet.has(normalizeClassname(a.classname)) ? 1 : 0;
const bImp = importedSet.has(normalizeClassname(b.classname)) ? 1 : 0;
if (aImp !== bImp) return aImp - bImp;
return b.id - a.id;
});