Fix multiple bugs on iOS

- receive multiple files
- display videos correctly
This commit is contained in:
RobinLinus 2018-10-11 01:42:20 +02:00
parent eee098e723
commit 73c7430883
2 changed files with 9 additions and 5 deletions

View file

@ -480,13 +480,12 @@ class FileDigester {
this.progress = this._bytesReceived / this._size; this.progress = this._bytesReceived / this._size;
if (this._bytesReceived < this._size) return; if (this._bytesReceived < this._size) return;
// we are done // we are done
let received = new Blob(this._buffer, { type: this._mime }); let blob = new Blob(this._buffer, { type: this._mime });
let url = URL.createObjectURL(received);
this._callback({ this._callback({
name: this._name, name: this._name,
mime: this._mime, mime: this._mime,
size: this._size, size: this._size,
url: url blob: blob
}); });
} }

View file

@ -230,7 +230,8 @@ class ReceiveDialog extends Dialog {
_displayFile(file) { _displayFile(file) {
const $a = this.$el.querySelector('#download'); const $a = this.$el.querySelector('#download');
$a.href = file.url; const url = URL.createObjectURL(file.blob);
$a.href = url;
$a.download = file.name; $a.download = file.name;
this.$el.querySelector('#fileName').textContent = file.name; this.$el.querySelector('#fileName').textContent = file.name;
@ -238,7 +239,11 @@ class ReceiveDialog extends Dialog {
this.show(); this.show();
if (window.isDownloadSupported) return; if (window.isDownloadSupported) return;
// $a.target = "_blank"; // fallback // fallback for iOS
$a.target = '_blank';
const reader = new FileReader();
reader.onload = e => $a.href = reader.result;
reader.readAsDataURL(file.blob);
} }
_formatFileSize(bytes) { _formatFileSize(bytes) {