fix(editor/mentions): do not cache empty results so numeric queries like @41005 revalidate after deploy

This commit is contained in:
codex-bot 2025-10-23 10:37:09 -03:00
parent 66fe34868c
commit 9bfdb451bc

View file

@ -97,6 +97,10 @@ const priorityLabels: Record<string, string> = {
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<string, TicketMentionItem[]>()
let mentionAbortController: AbortController | null = null
@ -117,7 +121,11 @@ async function fetchTicketMentions(query: string): Promise<TicketMentionItem[]>
}
const json = (await response.json()) as { items?: TicketMentionItem[] }
const items = Array.isArray(json.items) ? json.items : []
if (items.length > 0) {
mentionCache.set(cacheKey, items)
} else {
mentionCache.delete(cacheKey)
}
return items
} catch (error) {
if ((error as Error).name === "AbortError") {