feat: improve email status querying and URL handling
- Updated email status query to execute only when there are email IDs, enhancing performance. - Ensured URL handling in email sending functions always includes a protocol, improving reliability. - Added new queries for fetching emails by IDs and listing scheduled emails, enriching email management capabilities.
This commit is contained in:
@@ -52,14 +52,15 @@
|
||||
// Mapa de emailIds para rastrear status
|
||||
let emailIdsRastreados = $state<Set<string>>(new Set());
|
||||
|
||||
// Query para buscar status dos emails
|
||||
// Query para buscar status dos emails (só executa quando há IDs)
|
||||
const emailIdsArray = $derived(
|
||||
Array.from(emailIdsRastreados).map((id) => id as Id<"notificacoesEmail">),
|
||||
);
|
||||
const emailsStatusQuery = useQuery(
|
||||
api.email.buscarEmailsPorIds,
|
||||
emailIdsArray.length > 0 ? { emailIds: emailIdsArray } : undefined,
|
||||
);
|
||||
// Usar função para evitar execução quando array está vazio
|
||||
const emailsStatusQuery = $derived.by(() => {
|
||||
if (emailIdsArray.length === 0) return null;
|
||||
return useQuery(api.email.buscarEmailsPorIds, { emailIds: emailIdsArray });
|
||||
});
|
||||
|
||||
// Queries para agendamentos
|
||||
const agendamentosEmailQuery = useQuery(
|
||||
|
||||
Reference in New Issue
Block a user