feat: enhance call functionality and improve type safety
- Updated CallControls to replace the Record icon with Radio for better representation during recording states. - Refactored CallWindow to introduce Jitsi connection and conference interfaces, improving type safety and clarity in handling Jitsi events. - Streamlined event handling for connection and conference states, ensuring robust management of audio/video calls. - Enhanced ChatWindow to directly import CallWindow, simplifying the component structure and improving call handling logic. - Improved utility functions for window management to ensure compatibility with server-side rendering.
This commit is contained in:
@@ -16,12 +16,24 @@ export interface LimitesJanela {
|
||||
maxHeight?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_LIMITS: LimitesJanela = {
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
maxWidth: window.innerWidth,
|
||||
maxHeight: window.innerHeight
|
||||
};
|
||||
function getDefaultLimits(): LimitesJanela {
|
||||
if (typeof window === 'undefined') {
|
||||
return {
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
maxWidth: 1920,
|
||||
maxHeight: 1080
|
||||
};
|
||||
}
|
||||
return {
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
maxWidth: window.innerWidth,
|
||||
maxHeight: window.innerHeight
|
||||
};
|
||||
}
|
||||
|
||||
const DEFAULT_LIMITS: LimitesJanela = getDefaultLimits();
|
||||
|
||||
/**
|
||||
* Salvar posição da janela no localStorage
|
||||
@@ -30,6 +42,9 @@ export function salvarPosicaoJanela(
|
||||
id: string,
|
||||
posicao: PosicaoJanela
|
||||
): void {
|
||||
if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const key = `floating-window-${id}`;
|
||||
localStorage.setItem(key, JSON.stringify(posicao));
|
||||
@@ -42,6 +57,9 @@ export function salvarPosicaoJanela(
|
||||
* Restaurar posição da janela do localStorage
|
||||
*/
|
||||
export function restaurarPosicaoJanela(id: string): PosicaoJanela | null {
|
||||
if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const key = `floating-window-${id}`;
|
||||
const saved = localStorage.getItem(key);
|
||||
@@ -75,6 +93,14 @@ export function obterPosicaoInicial(
|
||||
width: number = 800,
|
||||
height: number = 600
|
||||
): PosicaoJanela {
|
||||
if (typeof window === 'undefined') {
|
||||
return {
|
||||
x: 100,
|
||||
y: 100,
|
||||
width,
|
||||
height
|
||||
};
|
||||
}
|
||||
return {
|
||||
x: (window.innerWidth - width) / 2,
|
||||
y: (window.innerHeight - height) / 2,
|
||||
@@ -124,6 +150,7 @@ export function criarDragHandler(
|
||||
let newY = initialY + deltaY;
|
||||
|
||||
// Limitar movimento dentro da tela
|
||||
if (typeof window === 'undefined') return;
|
||||
const maxX = window.innerWidth - element.offsetWidth;
|
||||
const maxY = window.innerHeight - element.offsetHeight;
|
||||
|
||||
@@ -173,6 +200,7 @@ export function criarDragHandler(
|
||||
let newX = initialX + deltaX;
|
||||
let newY = initialY + deltaY;
|
||||
|
||||
if (typeof window === 'undefined') return;
|
||||
const maxX = window.innerWidth - element.offsetWidth;
|
||||
const maxY = window.innerHeight - element.offsetHeight;
|
||||
|
||||
@@ -306,6 +334,8 @@ export function criarResizeHandler(
|
||||
newTop = startTop + deltaY;
|
||||
}
|
||||
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
// Aplicar limites
|
||||
const maxWidth = limites.maxWidth || window.innerWidth - newLeft;
|
||||
const maxHeight = limites.maxHeight || window.innerHeight - newTop;
|
||||
@@ -364,3 +394,4 @@ export function criarResizeHandler(
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -329,3 +329,4 @@ export class GravadorMedia {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user