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") {