rename function and add event to achieve compatibility with snapdrop-android app

This commit is contained in:
schlagmichdoch 2023-03-13 12:15:55 +01:00
parent 4a0cd1f49a
commit 17abc91c86
2 changed files with 10 additions and 4 deletions

View file

@ -329,7 +329,7 @@ class Peer {
this._onFilesTransferRequest(messageJSON);
break;
case 'header':
this._onFilesHeader(messageJSON);
this._onFileHeader(messageJSON);
break;
case 'partition':
this._onReceivedPartitionEnd(messageJSON);
@ -389,7 +389,7 @@ class Peer {
this._requestPending = null;
}
_onFilesHeader(header) {
_onFileHeader(header) {
if (this._requestAccepted && this._requestAccepted.header.length) {
this._lastProgress = 0;
this._digester = new FileDigester({size: header.size, name: header.name, mime: header.mime},
@ -443,6 +443,9 @@ class Peer {
this._abortTransfer();
}
// include for compatibility with Snapdrop for Android app
Events.fire('file-received', fileBlob);
this._filesReceived.push(fileBlob);
if (!this._requestAccepted.header.length) {
this._busy = false;

View file

@ -340,7 +340,7 @@ class Peer {
this._onFilesTransferRequest(messageJSON);
break;
case 'header':
this._onFilesHeader(messageJSON);
this._onFileHeader(messageJSON);
break;
case 'partition':
this._onReceivedPartitionEnd(messageJSON);
@ -400,7 +400,7 @@ class Peer {
this._requestPending = null;
}
_onFilesHeader(header) {
_onFileHeader(header) {
if (this._requestAccepted && this._requestAccepted.header.length) {
this._lastProgress = 0;
this._digester = new FileDigester({size: header.size, name: header.name, mime: header.mime},
@ -454,6 +454,9 @@ class Peer {
this._abortTransfer();
}
// include for compatibility with Snapdrop for Android app
Events.fire('file-received', fileBlob);
this._filesReceived.push(fileBlob);
if (!this._requestAccepted.header.length) {
this._busy = false;