From b04a8f897d5ac05ad9c8653d4f4a690d41656898 Mon Sep 17 00:00:00 2001 From: adevopg Date: Thu, 16 Jul 2026 13:10:58 +0000 Subject: [PATCH] Foro: reprocesar los enlaces de wowhead tras montar los posts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Los enlaces de wowhead de un post salían en crudo (item=41599) en vez de con nombre, color e icono. Causa: tooltips.js solo recorre el DOM al cargar, así que el contenido que monta React (los posts, inyectados con dangerouslySetInnerHTML, y las páginas abiertas por navegación SPA) se quedaba sin procesar. Se añade WowheadRefresh, un componente cliente que llama a $WowheadPower.refreshLinks() al montar (con reintentos, porque tooltips.js carga afterInteractive) y se repite al cambiar de tema/página. Es exactamente lo que ya hacía la tienda (StoreBrowser) tras cada AJAX. Con esto los enlaces reciben color por calidad, icono y —al llevar data-wh-rename-link— el nombre automático. Verificado: refreshLinks compilado en el bundle; la página del tema carga tooltips.js y sirve el enlace con data-wh-rename-link + href /wotlk/. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../[locale]/forum/topic/[topicId]/page.tsx | 2 ++ web-next/components/WowheadRefresh.tsx | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 web-next/components/WowheadRefresh.tsx diff --git a/web-next/app/[locale]/forum/topic/[topicId]/page.tsx b/web-next/app/[locale]/forum/topic/[topicId]/page.tsx index e7dbcfe..57a79d4 100644 --- a/web-next/app/[locale]/forum/topic/[topicId]/page.tsx +++ b/web-next/app/[locale]/forum/topic/[topicId]/page.tsx @@ -17,6 +17,7 @@ import { Pagination } from '@/components/Pagination' import { ReplyForm } from '@/components/ReplyForm' import { EditPostForm } from '@/components/EditPostForm' import { ForumModActions } from '@/components/ForumModActions' +import { WowheadRefresh } from '@/components/WowheadRefresh' export const dynamic = 'force-dynamic' @@ -66,6 +67,7 @@ export default async function TopicPage({ } >
+ {path && ( { + let tries = 0 + let timer: ReturnType + const run = () => { + const wp = (window as unknown as { $WowheadPower?: { refreshLinks?: () => void } }).$WowheadPower + if (wp?.refreshLinks) { + wp.refreshLinks() + return + } + if (tries++ < 25) timer = setTimeout(run, 150) + } + run() + return () => clearTimeout(timer) + }, [dep]) + return null +}