[minor] throttle doc_subscribed
This commit is contained in:
parent
8533306af3
commit
3b2a1227fb
2 changed files with 11 additions and 9 deletions
|
|
@ -57,15 +57,6 @@ frappe.socket = {
|
|||
frappe.socket.setup_reconnect();
|
||||
|
||||
$(document).on('form-load form-rename', function(e, frm) {
|
||||
if (frappe.flags.doc_subscribe) {
|
||||
return;
|
||||
}
|
||||
|
||||
frappe.flags.doc_subscribe = true;
|
||||
|
||||
// throttle to 1 per sec
|
||||
setTimeout(function() { frappe.flags.doc_subscribe = false }, 1000);
|
||||
|
||||
if (frm.is_new()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -136,6 +127,16 @@ frappe.socket = {
|
|||
frappe.socket.socket.emit('task_unsubscribe', task_id);
|
||||
},
|
||||
doc_subscribe: function(doctype, docname) {
|
||||
if (frappe.flags.doc_subscribe) {
|
||||
console.log('throttled');
|
||||
return;
|
||||
}
|
||||
|
||||
frappe.flags.doc_subscribe = true;
|
||||
|
||||
// throttle to 1 per sec
|
||||
setTimeout(function() { frappe.flags.doc_subscribe = false }, 1000);
|
||||
|
||||
frappe.socket.socket.emit('doc_subscribe', doctype, docname);
|
||||
frappe.socket.open_docs.push({doctype: doctype, docname: docname});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ function get_url(socket, path) {
|
|||
|
||||
function can_subscribe_doc(args) {
|
||||
if(!args) return;
|
||||
if(!args.doctype || !args.docname) return;
|
||||
request.get(get_url(args.socket, '/api/method/frappe.async.can_subscribe_doc'))
|
||||
.type('form')
|
||||
.query({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue