aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/transfers.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/transfers.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/transfers.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transfers.js b/packages/meshbay-hub/src/meshbay_hub/static/transfers.js
index 9a1455a..7036c4f 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/transfers.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/transfers.js
@@ -29,13 +29,6 @@ function _live(status) {
|| status === 'paused';
}
-/** Raised by `run` when it stopped because the transfer was paused. */
-function _pausedError() {
- const err = new Error('Paused');
- err.name = 'PausedError';
- return err;
-}
-
function _abortError() {
const err = new Error('Cancelled');
err.name = 'AbortError';
@@ -80,14 +73,16 @@ export class TransferStore {
queuedByOwnLimit: Boolean(
it.lease && it.lease.cap && it.lease.used >= it.lease.cap),
error: it.error || '',
+ note: it.note || '',
speed: this._speed(it),
// The ETA is drawn only once the window holds a few seconds of real
// measurement -- see etaSeconds.
settled: it.samples.length > 2
&& (it.samples[it.samples.length - 1].t - it.samples[0].t) >= 3000,
percent: it.total ? Math.min(100, Math.round(it.done / it.total * 100)) : 0,
- // Only for a file written into a folder the browser granted us: that is
- // the one case where the page can read its own download back.
+ // Where the finished file can be read back — a granted folder, the
+ // in-memory floor, the app's own save — and only for a type that is
+ // safe to open (downloads.openInTab).
canOpen: it.status === 'done' && typeof it.open === 'function',
// Whether the target can be stopped and continued. False is the honest
// answer for a service-worker stream, and the button is not drawn.
@@ -141,10 +136,14 @@ export class TransferStore {
* there is somewhere to write — see file-utils.js's downloadEntry.
*/
start({ kind, name, total = 0, transport = null, run, open = null,
- lease = null, prepare = null, makeLease = null, pausable = false }) {
+ lease = null, prepare = null, makeLease = null, pausable = false,
+ note = '' }) {
const item = {
id: _nextId++,
kind, name, total, transport, open, lease,
+ // One line said under the name for the life of the row — that a name was
+ // changed to be written here, for instance.
+ note,
done: 0,
// A transfer that has to wait for a slot starts as 'queued', not
// 'running'. Two different things are true of it — nothing is moving, and
@@ -227,6 +226,9 @@ export class TransferStore {
// the button is offered where it works and nowhere else — a pause
// that silently restarts from zero is worse than no pause.
if (ready && ready.pausable) item.pausable = true;
+ // Likewise whether "Open" can do anything: a page opens in a tab
+ // only a type that runs nothing (downloads.openInTab).
+ if (ready && ready.openable === false) item.open = null;
item.status = 'running';
this._emit();
}