From 5c66430cb49ccb7142a71b3cea135a94657bff8c Mon Sep 17 00:00:00 2001
From: Pascal Syma
Date: Sun, 14 Sep 2025 17:45:34 +0200
Subject: [PATCH] Compress answers and show upload progress
---
app/lang/de.json | 4 +-
app/lang/en.json | 4 +-
.../hunt/[huntSlug]/[questSlug]/index.vue | 72 +++++++++++++++----
bun.lock | 7 ++
package.json | 1 +
shared/utils/image.ts | 21 ++++++
6 files changed, 93 insertions(+), 16 deletions(-)
diff --git a/app/lang/de.json b/app/lang/de.json
index 1adc5cc..a794cad 100644
--- a/app/lang/de.json
+++ b/app/lang/de.json
@@ -114,7 +114,9 @@
"required_answer": "Erforderliche Antwort",
"finalize": "Antwort finalisieren",
"already_submitted": "Deine Antwort wurde bereits übermittelt!",
- "finalize_explain": "Dies gibt den Admins die Möglichkeit deine Antwort zu bewerten und dir Punkte zu geben. Du kannst deine Antwort anschließend nicht mehr ändern!"
+ "finalize_explain": "Dies gibt den Admins die Möglichkeit deine Antwort zu bewerten und dir Punkte zu geben. Du kannst deine Antwort anschließend nicht mehr ändern!",
+ "upload_title": "Antwort wird hochgeladen...",
+ "upload_compress": "Bild wird komprimiert..."
},
"hunt": {
"total_points": "Punktestand: {score}",
diff --git a/app/lang/en.json b/app/lang/en.json
index ce99302..0da698c 100644
--- a/app/lang/en.json
+++ b/app/lang/en.json
@@ -114,7 +114,9 @@
"required_answer": "Required Answer",
"finalize": "Finalize answer",
"already_submitted": "Your final answer has already been submitted!",
- "finalize_explain": "This allows the admins to review your answer and give you points. You cannot change your answer afterwards!"
+ "finalize_explain": "This allows the admins to review your answer and give you points. You cannot change your answer afterwards!",
+ "upload_title": "Uploading answer...",
+ "upload_compress": "Compressing image..."
},
"hunt": {
"total_points": "Total points: {score}",
diff --git a/app/pages/hunt/[huntSlug]/[questSlug]/index.vue b/app/pages/hunt/[huntSlug]/[questSlug]/index.vue
index 4a8d31a..64b7752 100644
--- a/app/pages/hunt/[huntSlug]/[questSlug]/index.vue
+++ b/app/pages/hunt/[huntSlug]/[questSlug]/index.vue
@@ -1,5 +1,5 @@
+
+ {{ t('page.quest.upload_title') }}
+
+ {{ t('page.quest.upload_compress') }}
+
+
+ {{ (uploadProgress * 100).toFixed(0) + '%' }}
+
+
URL.createObjectURL(file);
+
+export async function compressImage(file: File) {
+ return new Promise((resolve, reject) => {
+ if (!file) {
+ reject();
+ return;
+ }
+ new Compressor(file, {
+ quality: 0.8,
+ error(error) {
+ console.error(error);
+ reject(error);
+ },
+ success(result) {
+ resolve(result);
+ }
+ });
+ }).catch(() => file);
+}