fix: remove hacky logic for doc open and doc close

How and why is this so complicated?
- If doc is opned - send doc open event
- If doc gets closed - send doc close event.

No need to rememeber last doc and do weird logic on top of it.
This commit is contained in:
Ankush Menat 2023-06-29 13:22:23 +05:30
parent fbcc594986
commit 38f04be747

View file

@ -162,36 +162,10 @@ frappe.socketio = {
});
},
doc_open: function (doctype, docname) {
// notify that the user has opened this doc, if not already notified
if (
!frappe.socketio.last_doc ||
frappe.socketio.last_doc[0] != doctype ||
frappe.socketio.last_doc[1] != docname
) {
frappe.socketio.socket.emit("doc_open", doctype, docname);
frappe.socketio.last_doc &&
frappe.socketio.doc_close(
frappe.socketio.last_doc[0],
frappe.socketio.last_doc[1]
);
}
frappe.socketio.last_doc = [doctype, docname];
frappe.socketio.socket.emit("doc_open", doctype, docname);
},
doc_close: function (doctype, docname) {
// notify that the user has closed this doc
frappe.socketio.socket.emit("doc_close", doctype, docname);
// if the doc is closed the user has also stopped typing
frappe.socketio.socket.emit("doc_typing_stopped", doctype, docname);
},
form_typing: function (doctype, docname) {
// notifiy that the user is typing on the doc
frappe.socketio.socket.emit("doc_typing", doctype, docname);
},
form_stopped_typing: function (doctype, docname) {
// notifiy that the user has stopped typing
frappe.socketio.socket.emit("doc_typing_stopped", doctype, docname);
},
setup_listeners: function () {
frappe.socketio.socket.on("task_status_change", function (data) {