Skip to content

Commit 495208e

Browse files
committed
error handling
1 parent 6190859 commit 495208e

File tree

10 files changed

+16
-11
lines changed

10 files changed

+16
-11
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"jszip": "^3.10.1",
1515
"pinia": "^2.1.6",
1616
"sass": "^1.64.1",
17-
"simple-image-compressor": "^1.2.1",
17+
"simple-image-compressor": "^1.4.0",
1818
"vue": "^3.4.19",
1919
"vue-i18n": "^9.8.0"
2020
},

src/App.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function editFileObj(fileObj: FileObj) {
2929
fileObj.file = compressedFile;
3030
fileObj.isCompressed = true;
3131
} catch {
32-
fileObj.isTooLarge = true;
32+
fileObj.isError = true;
3333
}
3434
}
3535
@@ -38,13 +38,18 @@ async function compressFiles() {
3838
3939
const uncompressedFiles = files.value.filter((fileObj: FileObj) => !fileObj.isCompressed);
4040
41+
// option 1 (no errors, slower)
4142
const paginatedFileArray = paginate(uncompressedFiles, availableThreads);
4243
4344
for (const subArray of paginatedFileArray) {
4445
const promises = subArray.map(editFileObj);
4546
await Promise.all(promises);
4647
}
4748
49+
// option 2 (errors, faster -> better option once the errors are fixed in Firefox)
50+
// const promises = uncompressedFiles.map(editFileObj);
51+
// await Promise.all(promises);
52+
4853
isCompressing.value = false;
4954
5055
URL.revokeObjectURL(zipData.value);

src/components/FileItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ onUnmounted(() => URL.revokeObjectURL(objectUrl.value));
5757
<span class="field-title">{{ t('translation.compressedsize') }}</span> {{ computeFileSize(compSize) }}MB
5858
</div>
5959
<div
60-
v-if="fileObj.isTooLarge"
60+
v-if="fileObj.isError"
6161
class="error"
6262
>
63-
<span class="field-title">{{ t('translation.error') }}</span> {{ t('translation.filetoolarge') }}
63+
<span class="field-title">{{ t('translation.error') }}</span> {{ t('translation.hasFailed') }}
6464
</div>
6565
</div>
6666
</div>

src/components/FileUpload.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function addFiles(uploadedFiles: FileList) {
3232
const fileObj: FileObj = {
3333
id: id++,
3434
isCompressed: false,
35-
isTooLarge: false,
35+
isError: false,
3636
file,
3737
};
3838
files.value.push(fileObj);

src/i18n/de-DE/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
compressedsize: 'Komprimierte Größe:',
88
download: 'Herunterladen',
99
error: 'Fehler:',
10-
filetoolarge: 'Datei ist zu groß!',
10+
hasFailed: 'Datei konnte nicht komprimiert werden',
1111
header: 'Bild Kompressor',
1212
subtitle: 'Komprimiert Bilder auf < 10MB',
1313
buttonwiki: 'NMS Wiki Bild Upload öffnen',

src/i18n/en-EN/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
compressedsize: 'Compressed Size:',
88
download: 'Download',
99
error: 'Error:',
10-
filetoolarge: 'File is too large!',
10+
hasFailed: "File couldn't be compressed",
1111
header: 'Image Compressor',
1212
subtitle: 'Compresses images to < 10MB',
1313
buttonwiki: 'Open NMS Wiki Image Upload',

src/i18n/es-ES/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
compressedsize: 'Tamaño comprimido:',
88
download: 'Descargar',
99
error: 'Error:',
10-
filetoolarge: '¡El archivo es demasiado grande!',
10+
hasFailed: '¡El archivo es demasiado grande!',
1111
header: 'Compresor de imágenes',
1212
subtitle: 'Comprime imágenes a <10 MB',
1313
buttonwiki: 'Abrir página carga imágenes Wiki NMS',

src/i18n/eu-EU/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
compressedsize: 'Tamaina komprimatuta:',
88
download: 'Deskargatu',
99
error: 'Akats:',
10-
filetoolarge: 'Fitxategia handiegia da!',
10+
hasFailed: 'Fitxategia handiegia da!',
1111
header: 'Irudi-konpresorea',
1212
subtitle: 'Konprimitu irudiak < 10 MBra',
1313
buttonwiki: 'Ireki NMS Wiki-ko argazkiak igotzeko orria',

src/types/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface FileObj {
22
id: number;
33
isCompressed: boolean;
4-
isTooLarge: boolean;
4+
isError: boolean;
55
file: File;
66
}

0 commit comments

Comments
 (0)