fix video + audio preview

This commit is contained in:
schlagmichdoch 2023-01-21 18:20:42 +01:00
parent c0c2715f56
commit fb306b6c94
2 changed files with 8 additions and 6 deletions

View file

@ -502,11 +502,11 @@ class ReceiveFileDialog extends ReceiveDialog {
let element = document.createElement(previewElement[mime]);
element.src = URL.createObjectURL(file);
element.controls = true;
element.classList = 'element-preview'
this.$previewBox.style.display = 'block';
element.classList.add('element-preview');
this.$previewBox.appendChild(element)
element.onload = _ => resolve(true);
element.addEventListener('loadeddata', _ => resolve(true));
element.onerror = _ => reject(`${mime} preview could not be loaded`);
}
});
}
@ -572,7 +572,7 @@ class ReceiveFileDialog extends ReceiveDialog {
this.$shareOrDownloadBtn.href = url;
}
this.createPreviewElement(files[0]).then(_ => {
this.createPreviewElement(files[0]).finally(_ => {
document.title = `PairDrop - ${files.length} Files received`;
document.changeFavicon("images/favicon-96x96-notification.png");
this.show();
@ -643,7 +643,6 @@ class ReceiveRequestDialog extends ReceiveDialog {
element.src = request.thumbnailDataUrl;
element.classList.add('element-preview');
this.$previewBox.style.display = 'block';
this.$previewBox.appendChild(element)
}
@ -666,7 +665,6 @@ class ReceiveRequestDialog extends ReceiveDialog {
}
hide() {
this.$previewBox.style.display = 'none';
this.$previewBox.innerHTML = '';
super.hide();
}

View file

@ -899,6 +899,10 @@ x-dialog x-paper {
margin: 10px -24px 40px -24px;
}
.file-preview:empty {
display: none;
}
.element-preview {
max-width: 100%;
max-height: 40vh;