Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

620 multiple attachments shown when we send a message from the app #632

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 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 Expand Up @@ -230,7 +249,8 @@ $(document).on('app_ready', function () {
(channel) => channel.name == values.channel
).value;
// get message from values.message and clean it up, remove html tags
let message = values.message.replace(/<[^>]*>?/gm, '');
// let message = values.message.replace(/<[^>]*>?/gm, '');
let message = values.message;

let get_type = (url) => {
if (url) {
Expand Down
Loading