add notification when message transfer is completed analogous to completed file transfer

This commit is contained in:
schlagmichdoch 2022-11-08 15:43:24 +01:00
parent cc9c2bf088
commit c1575c8b85

View file

@ -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' });
}
}