|
1 | 1 | (function() { |
| 2 | + const processedItems = []; |
2 | 3 | var parallelCompressions = 5; |
3 | 4 |
|
4 | 5 | function updateProgressBar(successFullCompressions) { |
|
148 | 149 | return; |
149 | 150 | } |
150 | 151 |
|
| 152 | + const itemID = items[i].ID; |
| 153 | + if (processedItems.includes(itemID)) { |
| 154 | + const row = jQuery('#optimization-items tr').eq(parseInt(i, 10) + 1); |
| 155 | + row.find('.status') |
| 156 | + .attr('data-status', 'skipped-duplicate') |
| 157 | + .html('<span class="icon dashicons dashicons-no alert"></span>' + tinyCompress.L10nDuplicate); |
| 158 | + } |
| 159 | + |
151 | 160 | var row = jQuery('#optimization-items tr').eq(parseInt(i, 10)+1); |
152 | 161 | row.find('.status').removeClass('todo'); |
153 | 162 | row.find('.status').html('<span class="icon spinner"></span>' + tinyCompress.L10nCompressing).attr('data-status', 'compressing'); |
|
158 | 167 | data: { |
159 | 168 | _nonce: tinyCompress.nonce, |
160 | 169 | action: 'tiny_compress_image_for_bulk', |
161 | | - id: items[i].ID, |
| 170 | + id: itemID, |
162 | 171 | current_size: window.currentLibraryBytes |
163 | 172 | }, |
164 | 173 | success: function(data) { bulkOptimizationCallback(null, data, items, i); }, |
165 | 174 | error: function(xhr, textStatus, errorThrown) { bulkOptimizationCallback(errorThrown, null, items, i, parallelCompressions); } |
166 | 175 | }); |
| 176 | + processedItems.push(itemID); |
167 | 177 | jQuery('#tiny-progress span').html(i + 1); |
168 | 178 | } |
169 | 179 |
|
|
176 | 186 | window.optimizationCancelled = false; |
177 | 187 | window.totalRowsDrawn = 0; |
178 | 188 | window.currentLibraryBytes = parseInt(jQuery('#optimized-library-size').data('bytes'), 10); |
| 189 | + processedItems.splice(0, processedItems.length); |
179 | 190 |
|
180 | 191 | jQuery('div.progress').css('animation', 'progress-bar 80s linear infinite'); |
181 | 192 | jQuery('div#optimization-spinner').css('display', 'inline-block'); |
|
0 commit comments