better UX and UI on the room page

This commit is contained in:
2026-01-05 00:00:12 +01:00
parent 6e51bf8568
commit 5cf034200e
13 changed files with 1984 additions and 2341 deletions

View File

@@ -10,6 +10,15 @@ interface RoomUser {
userId?: number;
}
interface SourceContext {
animeId: string;
episode: string | number;
source: string;
extension: string;
server: string;
category: string;
}
export interface QueueItem {
uid: string;
metadata: RoomMetadata;
@@ -23,6 +32,7 @@ interface RoomMetadata {
episode: number;
image?: string;
source?: string;
malId?: number;
}
interface RoomData {
@@ -38,6 +48,7 @@ interface RoomData {
videoData?: any;
currentTime: number;
isPlaying: boolean;
context?: SourceContext;
} | null;
password?: string;
metadata?: RoomMetadata | null;
@@ -168,7 +179,10 @@ export function updateRoomVideo(roomId: string, videoData: any): boolean {
const room = rooms.get(roomId);
if (!room) return false;
room.currentVideo = videoData;
room.currentVideo = {
...room.currentVideo,
...videoData
};
return true;
}

View File

@@ -303,14 +303,34 @@ function handleMessage(roomId: string, userId: string, data: any) {
broadcastToRoom(roomId, {
type: 'video_update',
video: data.video,
metadata: data.metadata // ✅ CLAVE
metadata: data.metadata
});
break;
case 'queue_add_batch':
if (room.host.id !== userId) return;
if (Array.isArray(data.items)) {
// Añadimos el índice (i) al forEach
data.items.forEach((item: any, i: number) => {
const newItem = {
// Añadimos el índice '_${i}' al UID para garantizar unicidad en milisegundos
uid: `q_${Date.now()}_${i}_${Math.random().toString(36).substr(2, 5)}`,
metadata: item.metadata,
videoData: item.video,
addedBy: room.users.get(userId)?.username || 'Unknown'
};
roomService.addQueueItem(roomId, newItem);
});
broadcastToRoom(roomId, {
type: 'queue_update',
queue: room.queue
});
}
break;
case 'sync':
// Solo el host puede hacer sync
if (room.host.id !== userId) return;
if (room.currentVideo) {