fix(editor/mentions): do not cache empty results so numeric queries like @41005 revalidate after deploy
This commit is contained in:
parent
66fe34868c
commit
9bfdb451bc
1 changed files with 9 additions and 1 deletions
|
|
@ -97,6 +97,10 @@ const priorityLabels: Record<string, string> = {
|
||||||
URGENT: "Urgente",
|
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[]>()
|
const mentionCache = new Map<string, TicketMentionItem[]>()
|
||||||
let mentionAbortController: AbortController | null = null
|
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 json = (await response.json()) as { items?: TicketMentionItem[] }
|
||||||
const items = Array.isArray(json.items) ? json.items : []
|
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
|
return items
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((error as Error).name === "AbortError") {
|
if ((error as Error).name === "AbortError") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue