Recognize imported furniture by normalized classname and local IDs
This commit is contained in:
1 parent
9dc6b8a261
commit
a78d8256e0
7 files changed
+254
-46
No files matched your search
@@ -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;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user