Refresh Suggest hotel label from live CMS setting.
Local Build and Deploy / deploy (push) Successful in 56s

Avoid stale SSR/Redis cache keeping Suggest IT after habbo_gamedata_hotel changes.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-17 22:36:10 +02:00
1 parent 785c1b6976
commit a798999440
5 files changed
+49 -10

No files matched your search

@@ -83,6 +83,39 @@ export function CatalogTranslateTab({
useEffect(() => {
setActiveHotel(normalizeHabboGamedataHotel(gamedataHotel));
}, [gamedataHotel]);
// Always refresh from CMS settings so the button label tracks hotel changes
// without requiring a full page remount after saving Settings.
useEffect(() => {
let cancelled = false;
async function refreshHotel() {
try {
const res = await fetch("/api/admin/catalog/suggest", {
cache: "no-store",
});
if (!res.ok) return;
const data = (await res.json()) as { hotel?: string };
if (!cancelled && typeof data.hotel === "string") {
setActiveHotel(normalizeHabboGamedataHotel(data.hotel));
}
} catch {
// keep prop/default
}
}
void refreshHotel();
const onFocus = () => void refreshHotel();
const onVisibility = () => {
if (document.visibilityState === "visible") void refreshHotel();
};
window.addEventListener("focus", onFocus);
document.addEventListener("visibilitychange", onVisibility);
return () => {
cancelled = true;
window.removeEventListener("focus", onFocus);
document.removeEventListener("visibilitychange", onVisibility);
};
}, []);
const hotelShort = habboGamedataHotelShort(activeHotel);
const hotelLabel = habboGamedataHotelLabel(activeHotel);
+2
View File
@@ -8,6 +8,8 @@ import { loadCatalogItemsData } from "@/lib/services/catalog-items-loader";
import { getAncestors } from "@/lib/services/catalog-tree";
import { CatalogDetailTabs } from "./catalog-detail-tabs";
export const dynamic = "force-dynamic";
export default async function CatalogEditPage({
params,
}: {