Add STATE_TRANSFER_REQUEST_RECEIVED and close transfer request dialog if requesting peer reloads

This commit is contained in:
schlagmichdoch 2024-02-16 17:56:55 +01:00
parent 0d17ada58b
commit 3c8848d406
2 changed files with 55 additions and 11 deletions

View file

@ -1444,6 +1444,7 @@ class ReceiveRequestDialog extends ReceiveDialog {
this._currentRequest = null;
Events.on('files-transfer-request', e => this._onRequestFileTransfer(e.detail.request, e.detail.peerId))
Events.on('files-transfer-request-abort', e => this._onRequestFileTransferAbort(e.detail.peerId));
Events.on('keydown', e => this._onKeyDown(e));
}
@ -1461,6 +1462,22 @@ class ReceiveRequestDialog extends ReceiveDialog {
this._dequeueRequests();
}
_onRequestFileTransferAbort(peerId) {
// Remove file transfer request from this peer from queue
for (let i = 0; i < this._filesTransferRequestQueue.length; i++) {
if (this._filesTransferRequestQueue[i].peerId === peerId) {
this._filesTransferRequestQueue.splice(i, 1);
break;
}
}
// Hide dialog if the currently open transfer request is from this peer
if (this.isShown() && this.correspondingPeerId === peerId) {
this.hide();
Events.fire('notify-user', Localization.getTranslation("notifications.selected-peer-left"));
}
}
_dequeueRequests() {
if (!this._filesTransferRequestQueue.length) {
this._currentRequest = null;
@ -2724,6 +2741,7 @@ class Notifications {
Events.on('text-received', e => this._messageNotification(e.detail.text, e.detail.peerId));
Events.on('files-received', e => this._downloadNotification(e.detail.files, e.detail.imagesOnly));
Events.on('files-transfer-request', e => this._requestNotification(e.detail.request, e.detail.peerId));
// Todo on 'files-transfer-request-abort' remove notification
}
async _requestPermission() {