Skip to content

Commit

Permalink
feat: change follow room naming scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelle committed Dec 15, 2023
1 parent 0820503 commit 32fde3a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ try {
);

socket.on("user-follow", async (payload: OnUserFollowedPayload) => {
const roomID = `follow_${payload.userToFollow.socketId}`;
const roomID = `follow@${payload.userToFollow.socketId}`;

switch (payload.action) {
case "FOLLOW": {
Expand Down Expand Up @@ -127,7 +127,7 @@ try {
(_socket) => _socket.id !== socket.id,
);

const isFollowRoom = roomID.startsWith("follow_");
const isFollowRoom = roomID.startsWith("follow@");

if (!isFollowRoom && otherClients.length > 0) {
socket.broadcast.to(roomID).emit(
Expand All @@ -137,7 +137,7 @@ try {
}

if (isFollowRoom && otherClients.length === 0) {
const socketId = roomID.replace("follow_", "");
const socketId = roomID.replace("follow@", "");
io.to(socketId).emit("broadcast-unfollow");
}
}
Expand Down

0 comments on commit 32fde3a

Please sign in to comment.