diff --git a/raven/public/js/timeline_button.js b/raven/public/js/timeline_button.js index 6a1595984..e4be7125d 100644 --- a/raven/public/js/timeline_button.js +++ b/raven/public/js/timeline_button.js @@ -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(); }, }; @@ -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(); }, }; } @@ -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) { @@ -194,7 +214,6 @@ $(document).on('app_ready', function () { secondary_action() { dialog.hide(); }, - // size: 'small', minimizable: true, }); }