perf: dont send doc view updates to self

This commit is contained in:
Ankush Menat 2023-06-29 15:01:19 +05:30
parent c3a37421d6
commit 4ea6f3d672

View file

@ -271,7 +271,6 @@ function send_users(args) {
if (!(args && args.doctype && args.docname)) { if (!(args && args.doctype && args.docname)) {
return; return;
} }
const open_doc_room = get_open_doc_room(args.socket, args.doctype, args.docname); const open_doc_room = get_open_doc_room(args.socket, args.doctype, args.docname);
const clients = Array.from(io.sockets.adapter.rooms.get(open_doc_room) || []); const clients = Array.from(io.sockets.adapter.rooms.get(open_doc_room) || []);
@ -283,6 +282,9 @@ function send_users(args) {
} }
}); });
// dont send update to self. meaningless.
if (users.length == 1 && users[0] == args.socket.user) return;
// notify // notify
io.to(open_doc_room).emit("doc_viewers", { io.to(open_doc_room).emit("doc_viewers", {
doctype: args.doctype, doctype: args.doctype,