← All changes
|
modules/optimization/assets/js/classes/control/control-sync.js
+23
-1
1.0.0
→
1.7.7
View file →
| @@ -23,8 +23,15 @@ | ||
| 23 | 23 | if ( currentStatus === imageData.status ) { |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | + if ( controlWrapper.dataset.isFrozen === 'true' ) { | |
| 28 | + controlWrapper.dataset.isFrozen = false; | |
| 29 | + | |
| 30 | + return; | |
| 31 | + } | |
| 32 | + | |
| 33 | + // Required check as the status endpoint doesn't return validation errors | |
| 27 | 34 | if ( currentStatus === 'error' && ! new ControlMeta( controlWrapper ).allowRetry() ) { |
| 28 | 35 | return; |
| 29 | 36 | } |
| 30 | 37 | |
| @@ -50,12 +57,13 @@ | ||
| 50 | 57 | break; |
| 51 | 58 | |
| 52 | 59 | case 'optimized': |
| 53 | 60 | const statsData = { |
| 61 | + sizesTotal: imageData.stats.total_image_count, | |
| 54 | 62 | sizesOptimized: imageData.stats.optimized_image_count, |
| 55 | 63 | saved: { |
| 56 | 64 | absolute: imageData.stats.initial_image_size - imageData.stats.current_image_size, |
| 57 | - relative: Math.round( imageData.stats.current_image_size / imageData.stats.initial_image_size * 100 ), | |
| 65 | + relative: Math.max( 100 - Math.round( imageData.stats.current_image_size / imageData.stats.initial_image_size * 100 ), 0 ), | |
| 58 | 66 | }, |
| 59 | 67 | }; |
| 60 | 68 | |
| 61 | 69 | controlStates.renderOptimized( statsData ); |
| @@ -64,9 +72,23 @@ | ||
| 64 | 72 | |
| 65 | 73 | case 'optimization-failed': |
| 66 | 74 | controlStates.renderError( { |
| 67 | 75 | message: imageData.message, |
| 76 | + errorType: imageData.error_type, | |
| 77 | + imagesLeft: imageData.images_left, | |
| 78 | + allowRetry: new ControlMeta( controlWrapper ).allowRetry(), | |
| 68 | 79 | action: 'optimize', |
| 80 | + } ); | |
| 81 | + | |
| 82 | + break; | |
| 83 | + | |
| 84 | + case 'reoptimizing-failed': | |
| 85 | + controlStates.renderError( { | |
| 86 | + message: imageData.message, | |
| 87 | + errorType: imageData.error_type, | |
| 88 | + imagesLeft: imageData.images_left, | |
| 89 | + allowRetry: new ControlMeta( controlWrapper ).allowRetry(), | |
| 90 | + action: 'reoptimize', | |
| 69 | 91 | } ); |
| 70 | 92 | |
| 71 | 93 | break; |
| 72 | 94 | |