feat: update ESLint and TypeScript configurations across frontend and backend; enhance component structure and improve data handling in various modules

This commit is contained in:
2025-12-02 16:36:02 -03:00
parent f48d28067c
commit d79e6959c3
215 changed files with 29474 additions and 28173 deletions

View File

@@ -1,13 +1,13 @@
/**
* Helper para garantir que o token seja passado para todas requisições Convex
*
*
* Este store reativa garante que quando o token mudar no authStore,
* todos os clientes Convex sejam atualizados automaticamente.
*/
import { authStore } from "./auth.svelte";
import { browser } from "$app/environment";
import { PUBLIC_CONVEX_URL } from "$env/static/public";
import { authStore } from './auth.svelte';
import { browser } from '$app/environment';
import { PUBLIC_CONVEX_URL } from '$env/static/public';
let convexClients = new Set<any>();
@@ -15,50 +15,49 @@ let convexClients = new Set<any>();
* Registrar um cliente Convex para receber atualizações de token
*/
export function registerConvexClient(client: any) {
if (!browser) return;
convexClients.add(client);
// Configurar token inicial
if (authStore.token && client.setAuth) {
client.setAuth(authStore.token);
}
// Retornar função de limpeza
return () => {
convexClients.delete(client);
};
if (!browser) return;
convexClients.add(client);
// Configurar token inicial
if (authStore.token && client.setAuth) {
client.setAuth(authStore.token);
}
// Retornar função de limpeza
return () => {
convexClients.delete(client);
};
}
/**
* Atualizar token em todos clientes registrados
*/
function updateAllClients() {
if (!browser) return;
const token = authStore.token;
convexClients.forEach((client) => {
if (client && typeof client.setAuth === "function") {
if (token) {
client.setAuth(token);
} else {
client.clearAuth?.();
}
}
});
if (!browser) return;
const token = authStore.token;
convexClients.forEach((client) => {
if (client && typeof client.setAuth === 'function') {
if (token) {
client.setAuth(token);
} else {
client.clearAuth?.();
}
}
});
}
// Observar mudanças no token e atualizar clientes
if (browser) {
// Usar uma abordagem reativa simples
let lastToken: string | null = null;
setInterval(() => {
const currentToken = authStore.token;
if (currentToken !== lastToken) {
lastToken = currentToken;
updateAllClients();
}
}, 500); // Verificar a cada 500ms
}
// Usar uma abordagem reativa simples
let lastToken: string | null = null;
setInterval(() => {
const currentToken = authStore.token;
if (currentToken !== lastToken) {
lastToken = currentToken;
updateAllClients();
}
}, 500); // Verificar a cada 500ms
}