Async comments WIP
This commit is contained in:
parent
b0d333d85b
commit
dc3f3b7f08
3 changed files with 15 additions and 0 deletions
|
|
@ -173,3 +173,9 @@ def can_subscribe_doc(doctype, docname, sid):
|
|||
if not frappe.has_permission(user=session.user, doctype=doctype, doc=docname, ptype='read'):
|
||||
raise PermissionError()
|
||||
return True
|
||||
|
||||
def new_comment(doc, event):
|
||||
emit_via_redis('new_comment', doc.as_dict(), room=get_doc_room(doc.comment_doctype, doc.comment_docname))
|
||||
|
||||
def get_doc_room(doctype, docname):
|
||||
return ''.join(['doc:', doctype, '/', docname])
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ doc_events = {
|
|||
"frappe.email.doctype.email_alert.email_alert.trigger_email_alerts"
|
||||
],
|
||||
"on_trash": "frappe.desk.notifications.clear_doctype_notifications"
|
||||
},
|
||||
"Comment": {
|
||||
"after_insert": "frappe.async.new_comment"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ frappe.socket = {
|
|||
frappe.socket.socket.on('task_progress', function(data) {
|
||||
frappe.socket.process_response(data, "progress");
|
||||
});
|
||||
frappe.socket.socket.on('new_comment', function(comment) {
|
||||
if (cur_frm.doctype === comment.comment_doctype && cur_frm.docname === comment.comment_docname) {
|
||||
cur_frm.get_docinfo().comments = cur_frm.comments.get_comments().concat([comment]);
|
||||
cur_frm.comments.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
setup_reconnect: function() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue