Skip to content

Commit

Permalink
fix: send userProfileId in queue:update
Browse files Browse the repository at this point in the history
  • Loading branch information
ngomesodent committed Mar 22, 2024
1 parent aa0bfb2 commit 69de807
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/src/socketio/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions backend/src/socketio/RoomIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion commons/socket.io-types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions expo/components/ActiveRoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const ActiveRoomView: React.FC<ActiveRoomViewProps> = ({ room }) => {
setLiveRoom(data);
});

socket.on("queue:update", (data: RoomJSON) => {
setLiveRoom(data);
socket.on("queue:update", (room: RoomJSON, userProfileId: string) => {
setLiveRoom(room);
});
}, [socket]);

Expand Down

0 comments on commit 69de807

Please sign in to comment.