better UX and UI on the room page
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user