From 17abc91c86a0f17a2174bd729313854843cd87c9 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Mon, 13 Mar 2023 12:15:55 +0100 Subject: [PATCH] rename function and add event to achieve compatibility with snapdrop-android app --- public/scripts/network.js | 7 +++++-- public_included_ws_fallback/scripts/network.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index e9692d5..bf5ac2d 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -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; diff --git a/public_included_ws_fallback/scripts/network.js b/public_included_ws_fallback/scripts/network.js index f01b6bd..78f6f5a 100644 --- a/public_included_ws_fallback/scripts/network.js +++ b/public_included_ws_fallback/scripts/network.js @@ -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;