From 9bfdb451bcb32df75e6ff96098af8000c85d8ed4 Mon Sep 17 00:00:00 2001 From: codex-bot Date: Thu, 23 Oct 2025 10:37:09 -0300 Subject: [PATCH] fix(editor/mentions): do not cache empty results so numeric queries like @41005 revalidate after deploy --- src/components/ui/rich-text-editor.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ui/rich-text-editor.tsx b/src/components/ui/rich-text-editor.tsx index 0737e5e..b616290 100644 --- a/src/components/ui/rich-text-editor.tsx +++ b/src/components/ui/rich-text-editor.tsx @@ -97,6 +97,10 @@ const priorityLabels: Record = { URGENT: "Urgente", } +// Cache simples para resultados de menções. +// Obs.: não armazenamos resultados vazios para permitir que +// consultas que antes falharam (ex.: endpoint indisponível) +// sejam revalidadas em tentativas subsequentes. const mentionCache = new Map() let mentionAbortController: AbortController | null = null @@ -117,7 +121,11 @@ async function fetchTicketMentions(query: string): Promise } const json = (await response.json()) as { items?: TicketMentionItem[] } const items = Array.isArray(json.items) ? json.items : [] - mentionCache.set(cacheKey, items) + if (items.length > 0) { + mentionCache.set(cacheKey, items) + } else { + mentionCache.delete(cacheKey) + } return items } catch (error) { if ((error as Error).name === "AbortError") {