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:
@@ -62,22 +62,13 @@ const estadoInicial: EstadoChamada = {
|
||||
export const callState = writable<EstadoChamada>(estadoInicial);
|
||||
|
||||
// Store para indicar se há chamada ativa
|
||||
export const chamadaAtiva = derived(
|
||||
callState,
|
||||
($state) => $state.chamadaId !== null
|
||||
);
|
||||
export const chamadaAtiva = derived(callState, ($state) => $state.chamadaId !== null);
|
||||
|
||||
// Store para indicar se está conectado
|
||||
export const estaConectado = derived(
|
||||
callState,
|
||||
($state) => $state.estaConectado
|
||||
);
|
||||
export const estaConectado = derived(callState, ($state) => $state.estaConectado);
|
||||
|
||||
// Store para indicar se está gravando
|
||||
export const gravando = derived(
|
||||
callState,
|
||||
($state) => $state.gravando
|
||||
);
|
||||
export const gravando = derived(callState, ($state) => $state.gravando);
|
||||
|
||||
// Funções para atualizar o estado
|
||||
|
||||
@@ -109,12 +100,12 @@ export function inicializarChamada(
|
||||
*/
|
||||
export function finalizarChamada(): void {
|
||||
const estadoAtual = get(callState);
|
||||
|
||||
|
||||
// Liberar recursos
|
||||
if (estadoAtual.streamLocal) {
|
||||
estadoAtual.streamLocal.getTracks().forEach((track) => track.stop());
|
||||
}
|
||||
|
||||
|
||||
callState.set(estadoInicial);
|
||||
}
|
||||
|
||||
@@ -184,14 +175,12 @@ export function atualizarParticipantes(participantes: ParticipanteChamada[]): vo
|
||||
export function adicionarParticipante(participante: ParticipanteChamada): void {
|
||||
callState.update((state) => {
|
||||
// Verificar se já existe
|
||||
const existe = state.participantes.some(
|
||||
(p) => p.usuarioId === participante.usuarioId
|
||||
);
|
||||
|
||||
const existe = state.participantes.some((p) => p.usuarioId === participante.usuarioId);
|
||||
|
||||
if (existe) {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
...state,
|
||||
participantes: [...state.participantes, participante]
|
||||
@@ -205,9 +194,7 @@ export function adicionarParticipante(participante: ParticipanteChamada): void {
|
||||
export function removerParticipante(usuarioId: Id<'usuarios'>): void {
|
||||
callState.update((state) => ({
|
||||
...state,
|
||||
participantes: state.participantes.filter(
|
||||
(p) => p.usuarioId !== usuarioId
|
||||
)
|
||||
participantes: state.participantes.filter((p) => p.usuarioId !== usuarioId)
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -299,7 +286,7 @@ export function setStreamLocal(stream: MediaStream | null): void {
|
||||
if (state.streamLocal) {
|
||||
state.streamLocal.getTracks().forEach((track) => track.stop());
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
...state,
|
||||
streamLocal: stream
|
||||
@@ -320,4 +307,3 @@ export function obterEstadoAtual(): EstadoChamada {
|
||||
export function resetarEstado(): void {
|
||||
finalizarChamada();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user