Merge branch 'add_message_transfer_completed_notification' into add_device_pairing
This commit is contained in:
commit
75846f4de1
1 changed files with 12 additions and 4 deletions
|
@ -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' });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue