From c1575c8b852a340dd4873b5c2092dff645433294 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Tue, 8 Nov 2022 15:43:24 +0100 Subject: [PATCH] add notification when message transfer is completed analogous to completed file transfer --- client/scripts/network.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/scripts/network.js b/client/scripts/network.js index e1383f3..3c01a8c 100644 --- a/client/scripts/network.js +++ b/client/scripts/network.js @@ -167,8 +167,11 @@ class Peer { case 'progress': this._onDownloadProgress(message.progress); break; - case 'transfer-complete': - this._onTransferCompleted(); + case 'file-transfer-complete': + this._onFileTransferCompleted(); + break; + case 'message-transfer-complete': + this._onMessageTransferCompleted(); break; case 'text': this._onTextReceived(message); @@ -204,10 +207,10 @@ class Peer { _onFileReceived(proxyFile) { Events.fire('file-received', proxyFile); - this.sendJSON({ type: 'transfer-complete' }); + this.sendJSON({ type: 'file-transfer-complete' }); } - _onTransferCompleted() { + _onFileTransferCompleted() { this._onDownloadProgress(1); this._reader = null; this._busy = false; @@ -215,6 +218,10 @@ class Peer { Events.fire('notify-user', 'File transfer completed.'); } + _onMessageTransferCompleted() { + Events.fire('notify-user', 'Message transfer completed.'); + } + sendText(text) { const unescaped = btoa(unescape(encodeURIComponent(text))); this.sendJSON({ type: 'text', text: unescaped }); @@ -223,6 +230,7 @@ class Peer { _onTextReceived(message) { const escaped = decodeURIComponent(escape(atob(message.text))); Events.fire('text-received', { text: escaped, sender: this._peerId }); + this.sendJSON({ type: 'message-transfer-complete' }); } }