Skip to content

Commit

Permalink
fix: unsubscribe from task after completion
Browse files Browse the repository at this point in the history
Also update event name to be more logical

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
  • Loading branch information
akhilnarang committed Mar 13, 2024
1 parent 0ec3e4a commit 6a5af14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion frappe/public/js/frappe/list/bulk_operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ export default class BulkOperations {
.then((response) => {
let task_id = response.message.task_id;
frappe.realtime.task_subscribe(task_id);
frappe.realtime.on(`task_progress:${task_id}`, (data) => {
frappe.realtime.on(`task_complete:${task_id}`, (data) => {
frappe.msgprint(
`Please click <a href=${data.file_url} target="_blank">here</a> to download the PDF`
);
frappe.realtime.task_unsubscribe(task_id);
frappe.realtime.off(`task_complete:${task_id}`);
});
dialog.hide();
});
Expand Down
2 changes: 1 addition & 1 deletion frappe/utils/print_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _download_multi_pdf(
}
)
_file.save()
frappe.publish_realtime(f"task_progress:{task_id}", message={"file_url": _file.unique_url})
frappe.publish_realtime(f"task_complete:{task_id}", message={"file_url": _file.unique_url})
else:
frappe.local.response.filecontent = merged_pdf.getvalue()
frappe.local.response.type = "pdf"
Expand Down

0 comments on commit 6a5af14

Please sign in to comment.