From 69de8075d0b4e4f944a8e7b44578d5f6ba34a659 Mon Sep 17 00:00:00 2001 From: ngomesodent <101274479+ngomesodent@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:28:28 +0100 Subject: [PATCH] fix: send userProfileId in queue:update --- backend/src/socketio/Room.ts | 2 +- backend/src/socketio/RoomIO.ts | 8 ++++---- commons/socket.io-types.ts | 2 +- expo/components/ActiveRoomView.tsx | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/socketio/Room.ts b/backend/src/socketio/Room.ts index c3b66093..6594a87f 100644 --- a/backend/src/socketio/Room.ts +++ b/backend/src/socketio/Room.ts @@ -79,7 +79,7 @@ export default class Room { } } - async add(rawUrl: string, userProfileId: string) { + async add(rawUrl: string) { const trackMetadata = this.trackFactory.fromUrl(rawUrl); if (trackMetadata !== null) { const track = await trackMetadata.toJSON(); diff --git a/backend/src/socketio/RoomIO.ts b/backend/src/socketio/RoomIO.ts index b28577a0..e4167ff1 100644 --- a/backend/src/socketio/RoomIO.ts +++ b/backend/src/socketio/RoomIO.ts @@ -59,8 +59,8 @@ export default function RoomIO( roomSocket.emit("queue:update", Room.toJSON(room)); socket.on("queue:add", async (url: string, userProfileId: string) => { - await room.add(url, userProfileId); - sendQueueUpdated(); + await room.add(url); + sendQueueUpdated(userProfileId); }); // We should check the origin of the request to prevent anyone that isn't the host from removing anything @@ -94,8 +94,8 @@ export default function RoomIO( } }); - const sendQueueUpdated = () => { - roomSocket.emit("queue:update", Room.toJSON(room)); + const sendQueueUpdated = (userProfileId?: string) => { + roomSocket.emit("queue:update", Room.toJSON(room), userProfileId); }; socket.on("player:playTrack", async (trackId) => { diff --git a/commons/socket.io-types.ts b/commons/socket.io-types.ts index 68208db4..25a83005 100644 --- a/commons/socket.io-types.ts +++ b/commons/socket.io-types.ts @@ -1,7 +1,7 @@ import { JSONTrack, PlayingJSONTrack, RoomJSON } from "./backend-types"; export interface ServerToClientEvents { - "queue:update": (room: RoomJSON | Error) => void; + "queue:update": (room: RoomJSON | Error, userProfileId?: string) => void; "player:updatePlaybackState": ( playbackState: PlayingJSONTrack | null ) => void; diff --git a/expo/components/ActiveRoomView.tsx b/expo/components/ActiveRoomView.tsx index 25c10e94..c1c7a8ff 100644 --- a/expo/components/ActiveRoomView.tsx +++ b/expo/components/ActiveRoomView.tsx @@ -80,8 +80,8 @@ const ActiveRoomView: React.FC = ({ room }) => { setLiveRoom(data); }); - socket.on("queue:update", (data: RoomJSON) => { - setLiveRoom(data); + socket.on("queue:update", (room: RoomJSON, userProfileId: string) => { + setLiveRoom(room); }); }, [socket]);