Skip to content

Commit

Permalink
fix:multiple and duplicate rendering of attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitjain236 committed Jan 19, 2024
1 parent 0fe375b commit d38fd94
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions raven/public/js/timeline_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $(document).on('app_ready', function () {
folder: 'Home/Attachments',
on_success: (attachment) => {
frm.attachments.push(attachment);
render_attachment_rows(attachment);
render_attachment_rows();
},
};

Expand All @@ -52,7 +52,7 @@ $(document).on('app_ready', function () {
folder: 'Home/Attachments',
on_success: (attachment) => {
frm.attachments.attachment_uploaded(attachment);
render_attachment_rows(attachment);
render_attachment_rows();
},
};
}
Expand Down Expand Up @@ -92,11 +92,31 @@ $(document).on('app_ready', function () {
);
} else {
let files = [];
// Add attachments from form
// check if attachment already exists in files array

if (frm.attachments && frm.attachments.length) {
files = files.concat(frm.attachments);
// files = files.concat(frm.attachments);
files = files.concat(
frm.attachments.filter((attachment, index, array) => {
return !array
.slice(0, index)
.some(
(obj) => obj.file_name === attachment.file_name
);
})
);
}
if (frm) {
files = files.concat(frm.get_files());

files = files.filter((attachment, index, array) => {
return !array
.slice(0, index)
.some(
(obj) => obj.file_name === attachment.file_name
);
});
}

if (files.length) {
Expand Down Expand Up @@ -194,7 +214,6 @@ $(document).on('app_ready', function () {
secondary_action() {
dialog.hide();
},
// size: 'small',
minimizable: true,
});
}
Expand Down

0 comments on commit d38fd94

Please sign in to comment.