mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Split out file transfer button handling.
Split out deleting of buttons during file transfer into its own function.
This commit is contained in:
parent
f75b964a6b
commit
645ba5fb48
1 changed files with 28 additions and 21 deletions
|
@ -2441,28 +2441,32 @@ function gotFileTransfer(f) {
|
||||||
/**
|
/**
|
||||||
* @param {TransferredFile} f
|
* @param {TransferredFile} f
|
||||||
* @param {string} status
|
* @param {string} status
|
||||||
* @param {boolean} [delyes]
|
|
||||||
* @param {boolean} [delno]
|
|
||||||
*/
|
*/
|
||||||
function setFileStatus(f, status, delyes, delno) {
|
function setFileStatus(f, status) {
|
||||||
let statusdiv = document.getElementById('status-' + f.fullid());
|
let statusdiv = document.getElementById('status-' + f.fullid());
|
||||||
if(!statusdiv)
|
if(!statusdiv)
|
||||||
throw new Error("Couldn't find statusdiv");
|
throw new Error("Couldn't find statusdiv");
|
||||||
statusdiv.textContent = status;
|
statusdiv.textContent = status;
|
||||||
if(delyes || delno) {
|
}
|
||||||
let div = document.getElementById('file-' + f.fullid());
|
|
||||||
if(!div)
|
/**
|
||||||
throw new Error("Couldn't find file div");
|
* @param {TransferredFile} f
|
||||||
if(delyes) {
|
* @param {boolean} delyes
|
||||||
let byes = document.getElementById('byes-' + f.fullid())
|
* @param {boolean} delno
|
||||||
if(byes)
|
*/
|
||||||
div.removeChild(byes);
|
function delFileStatusButtons(f, delyes, delno) {
|
||||||
}
|
let div = document.getElementById('file-' + f.fullid());
|
||||||
if(delno) {
|
if(!div)
|
||||||
let bno = document.getElementById('bno-' + f.fullid())
|
throw new Error("Couldn't find file div");
|
||||||
if(bno)
|
if(delyes) {
|
||||||
div.removeChild(bno);
|
let byes = document.getElementById('byes-' + f.fullid())
|
||||||
}
|
if(byes)
|
||||||
|
div.removeChild(byes);
|
||||||
|
}
|
||||||
|
if(delno) {
|
||||||
|
let bno = document.getElementById('bno-' + f.fullid())
|
||||||
|
if(bno)
|
||||||
|
div.removeChild(bno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2477,7 +2481,8 @@ function gotFileTransferEvent(state, data) {
|
||||||
case 'inviting':
|
case 'inviting':
|
||||||
break;
|
break;
|
||||||
case 'connecting':
|
case 'connecting':
|
||||||
setFileStatus(f, 'Connecting...', true);
|
delFileStatusButtons(f, true);
|
||||||
|
setFileStatus(f, 'Connecting...');
|
||||||
break;
|
break;
|
||||||
case 'connected':
|
case 'connected':
|
||||||
if(f.up)
|
if(f.up)
|
||||||
|
@ -2486,7 +2491,8 @@ function gotFileTransferEvent(state, data) {
|
||||||
setFileStatus(f, `Receiving... ${f.datalen}/${f.size}`);
|
setFileStatus(f, `Receiving... ${f.datalen}/${f.size}`);
|
||||||
break;
|
break;
|
||||||
case 'done':
|
case 'done':
|
||||||
setFileStatus(f, 'Done.', true, true);
|
delFileStatusButtons(f, true, true);
|
||||||
|
setFileStatus(f, 'Done.');
|
||||||
if(!f.up) {
|
if(!f.up) {
|
||||||
let url = URL.createObjectURL(data);
|
let url = URL.createObjectURL(data);
|
||||||
let a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
|
@ -2499,10 +2505,11 @@ function gotFileTransferEvent(state, data) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'cancelled':
|
case 'cancelled':
|
||||||
|
delFileStatusButtons(f, true, true);
|
||||||
if(data)
|
if(data)
|
||||||
setFileStatus(f, `Cancelled: ${data.toString()}.`, true, true);
|
setFileStatus(f, `Cancelled: ${data.toString()}.`);
|
||||||
else
|
else
|
||||||
setFileStatus(f, 'Cancelled.', true, true);
|
setFileStatus(f, 'Cancelled.');
|
||||||
break;
|
break;
|
||||||
case 'closed':
|
case 'closed':
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue