@@ -7,6 +7,7 @@ import prettyBytes from "pretty-bytes";
7
7
import { parseURLSchemeHostPath } from "./pageutils" ;
8
8
import { property } from "lit/decorators.js" ;
9
9
import type { LoadInfo } from "./item" ;
10
+ import { ifDefined } from "lit/directives/if-defined.js" ;
10
11
11
12
// ===========================================================================
12
13
/**
@@ -266,7 +267,7 @@ You can select a file to upload from the main page by clicking the 'Choose File.
266
267
}
267
268
}
268
269
269
- onCancel ( ) {
270
+ async onCancel ( ) {
270
271
if ( ! this . worker ) {
271
272
return ;
272
273
}
@@ -275,6 +276,9 @@ You can select a file to upload from the main page by clicking the 'Choose File.
275
276
276
277
if ( ! this . noWebWorker ) {
277
278
this . worker . postMessage ( msg ) ;
279
+
280
+ await this . updateComplete ;
281
+
278
282
this . dispatchEvent (
279
283
new CustomEvent ( "coll-load-cancel" , {
280
284
bubbles : true ,
@@ -354,7 +358,7 @@ You can select a file to upload from the main page by clicking the 'Choose File.
354
358
name ="pulse "
355
359
easing ="ease-in-out "
356
360
duration ="2000 "
357
- ?play =${ this . isLoadingWacz }
361
+ ?play =${ this . isLoadingWacz || ! this . percent }
358
362
>
359
363
< fa-icon
360
364
size ="5rem "
@@ -436,15 +440,25 @@ You can select a file to upload from the main page by clicking the 'Choose File.
436
440
}
437
441
438
442
private renderProgressBar ( ) {
443
+ // Calculate percentage based on currentSize and totalSize
444
+ // if data is available before actual percent
445
+ const percent =
446
+ this . percent || ( this . currentSize && this . totalSize )
447
+ ? ( ( this . currentSize / this . totalSize ) * 100 ) . toFixed ( 0 )
448
+ : 0 ;
449
+
439
450
return html `
440
451
< progress
441
452
id ="progress "
442
453
class ="progress is-primary is-large "
443
- value =" ${ this . percent } "
454
+ value =${ ifDefined ( percent || undefined ) }
444
455
max ="100"
445
456
> </ progress >
446
- < label class ="progress-label " for ="progress "> ${ this . percent } %</ label >
447
-
457
+ ${ percent
458
+ ? html `
459
+ < label class ="progress-label " for ="progress "> ${ percent } %</ label >
460
+ `
461
+ : nothing }
448
462
${ this . currentSize && this . totalSize
449
463
? html ` < div class ="loaded-prog ">
450
464
Loaded
0 commit comments