forked from rDrama/rDrama
1
0
Fork 0

fix bug in safari and firefox caused by saving attachment on restore

master
Aevann 2023-08-08 17:20:42 +03:00
parent 982130bba5
commit 30fa694cbd
2 changed files with 21 additions and 8 deletions

View File

@ -525,7 +525,7 @@ function handle_files(input, newfiles) {
file_upload = document.getElementById('file-upload');
if (file_upload) {
function process_url_image() {
function display_url_image() {
if (file_upload.files)
{
const file = file_upload.files[0]
@ -553,13 +553,19 @@ if (file_upload) {
else {
document.getElementById('submit-btn').disabled = false;
}
if (typeof submit_save_files === "function") {
submit_save_files("attachment", [file]);
}
}
}
file_upload.onchange = process_url_image
file_upload.onchange = () => {
display_url_image()
if (typeof submit_save_files === "function") {
const array = []
for (const x of file_upload.files) {
array.push(x)
}
submit_save_files("attachment", array);
}
}
}
document.onpaste = function(event) {
@ -575,7 +581,14 @@ document.onpaste = function(event) {
}
else {
file_upload.files = files;
process_url_image();
display_url_image();
if (typeof submit_save_files === "function") {
const array = []
for (const x of file_upload.files) {
array.push(x)
}
submit_save_files("attachment", array);
}
return;
}
}

View File

@ -282,7 +282,7 @@ function submit_restore_files(kind, id) {
document.getElementById(id).files = list.files
if (kind == "attachment") {
process_url_image()
display_url_image()
}
else {
oldfiles["post-text"] = new DataTransfer();