Skip to content

Node.js based forum software built for the modern web

refactor: use set

Barış Soner Uşaklıd9344140a0ab
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index fdcf6146b0..351b0d145e 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -318,16 +318,16 @@ Sockets.getUidsInRoom = async function (room) {
return [];
}
const ioRoom = Sockets.server.in(room);
- const uids = [];
+ const uids = new Set();
if (ioRoom) {
const sockets = await ioRoom.fetchSockets();
for (const s of sockets) {
if (s && s.data && s.data.uid > 0) {
- uids.push(s.data.uid);
+ uids.add(s.data.uid);
}
}
}
- return _.uniq(uids);
+ return [...uids];
};
Sockets.warnDeprecated = (socket, replacement) => {