From dbbc83d369fc81feb5d5bafed57f73bc6767b9fb Mon Sep 17 00:00:00 2001 From: plebeius Date: Tue, 17 Feb 2026 16:44:16 +0800 Subject: [PATCH] feat: add shared cross-platform catbox media upload flow Added `useFileUpload()` and `uploadToCatbox()` to centralize upload behavior and remove duplicated upload code from `post-form.tsx` and `reply-modal.tsx`. The flow now routes Android to `FileUploader`, Electron to hidden-input + catbox upload, and web to a translated fallback alert with consistent upload UI state. --- public/translations/ar/default.json | 5 +- public/translations/bn/default.json | 5 +- public/translations/cs/default.json | 5 +- public/translations/da/default.json | 5 +- public/translations/de/default.json | 5 +- public/translations/el/default.json | 5 +- public/translations/en/default.json | 5 +- public/translations/es/default.json | 5 +- public/translations/fa/default.json | 5 +- public/translations/fi/default.json | 5 +- public/translations/fil/default.json | 5 +- public/translations/fr/default.json | 5 +- public/translations/he/default.json | 5 +- public/translations/hi/default.json | 5 +- public/translations/hu/default.json | 5 +- public/translations/id/default.json | 5 +- public/translations/it/default.json | 5 +- public/translations/ja/default.json | 5 +- public/translations/ko/default.json | 5 +- public/translations/mr/default.json | 5 +- public/translations/nl/default.json | 5 +- public/translations/no/default.json | 5 +- public/translations/pl/default.json | 5 +- public/translations/pt/default.json | 5 +- public/translations/ro/default.json | 5 +- public/translations/ru/default.json | 5 +- public/translations/sq/default.json | 5 +- public/translations/sv/default.json | 5 +- public/translations/te/default.json | 5 +- public/translations/th/default.json | 5 +- public/translations/tr/default.json | 5 +- public/translations/uk/default.json | 5 +- public/translations/ur/default.json | 5 +- public/translations/vi/default.json | 5 +- public/translations/zh/default.json | 5 +- src/components/post-form/post-form.tsx | 59 ++---- src/components/reply-modal/reply-modal.tsx | 62 +++---- src/hooks/__tests__/use-file-upload.test.ts | 180 +++++++++++++++++++ src/hooks/use-file-upload.ts | 104 +++++++++++ src/lib/utils/__tests__/catbox-utils.test.ts | 51 ++++++ src/lib/utils/catbox-utils.ts | 25 +++ vitest.config.ts | 7 + 42 files changed, 545 insertions(+), 118 deletions(-) create mode 100644 src/hooks/__tests__/use-file-upload.test.ts create mode 100644 src/hooks/use-file-upload.ts create mode 100644 src/lib/utils/__tests__/catbox-utils.test.ts create mode 100644 src/lib/utils/catbox-utils.ts create mode 100644 vitest.config.ts diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index 568ddf18..3d1fe744 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "يتم تحديث المنشورات تلقائياً كل ~2 دقيقة. لا يمكن تعطيل هذا في الوقت الحالي.", "board_address_tooltip": "عنوان عقدة الند للند لهذه اللوحة", "vote_button_unavailable_intro": "غير متاح حتى الآن. سيتمكن المستخدمون من إرسال لوحاتهم الخاصة والتصويت عليها للمنافسة على فتحات الدليل، مثل /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "تصبح /{{boardIdentifier}}/ الأكثر تصويتاً هي /{{boardIdentifier}}/ الرسمية." + "vote_button_unavailable_outro": "تصبح /{{boardIdentifier}}/ الأكثر تصويتاً هي /{{boardIdentifier}}/ الرسمية.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index 0f6ee7be..087833e5 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "পোস্টগুলি প্রতি ~2 মিনিটে স্বয়ংক্রিয়ভাবে আপডেট হয়। বর্তমানে এটি অক্ষম করা সম্ভব নয়।", "board_address_tooltip": "এই বোর্ডের পিয়ার-টু-পিয়ার নোডের ঠিকানা", "vote_button_unavailable_intro": "এখনও উপলব্ধ নয়। ব্যবহারকারীরা তাদের নিজস্ব বোর্ড জমা দিতে এবং সেগুলির জন্য ভোট দিতে সক্ষম হবে, যেমন /{{boardIdentifier}}/ এর জন্য ডিরেক্টরি স্লটের জন্য প্রতিযোগিতা করতে।", - "vote_button_unavailable_outro": "সর্বাধিক ভোটপ্রাপ্ত /{{boardIdentifier}}/ আনুষ্ঠানিক /{{boardIdentifier}}/ হয়ে ওঠে।" + "vote_button_unavailable_outro": "সর্বাধিক ভোটপ্রাপ্ত /{{boardIdentifier}}/ আনুষ্ঠানিক /{{boardIdentifier}}/ হয়ে ওঠে।", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index 65e9383c..25bd34d4 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Příspěvky se aktualizují automaticky přibližně každých ~2 minut. V současné době není možné tuto funkci zakázat.", "board_address_tooltip": "Adresa uzlu peer-to-peer této desky", "vote_button_unavailable_intro": "Zatím není k dispozici. Uživatelé budou moci odesílat vlastní desky a hlasovat pro ně, aby konkurovali o místa v adresáři, jako je /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Nejvíce hlasovaná /{{boardIdentifier}}/ se stane oficiální /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Nejvíce hlasovaná /{{boardIdentifier}}/ se stane oficiální /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/da/default.json b/public/translations/da/default.json index 5484834f..1a160bd5 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Indlæg opdateres automatisk hver ~2 minut. Det er ikke muligt at deaktivere dette i øjeblikket.", "board_address_tooltip": "Adressen til dette boards peer-to-peer-node", "vote_button_unavailable_intro": "Ikke tilgængelig endnu. Brugere vil kunne indsende deres egne boards og stemme for dem for at konkurrere om katalogpladser, såsom /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest stemmer bliver den officielle /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest stemmer bliver den officielle /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/de/default.json b/public/translations/de/default.json index 75e9b07e..ceb2883b 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Beiträge werden automatisch etwa alle ~2 Minuten aktualisiert. Es ist derzeit nicht möglich, dies zu deaktivieren.", "board_address_tooltip": "Die Adresse des Peer-to-Peer-Knotens dieses Boards", "vote_button_unavailable_intro": "Noch nicht verfügbar. Benutzer können ihre eigenen Boards einreichen und dafür abstimmen, um um Verzeichnisplätze zu konkurrieren, wie /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Das am meisten abgestimmte /{{boardIdentifier}}/ wird zum offiziellen /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Das am meisten abgestimmte /{{boardIdentifier}}/ wird zum offiziellen /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/el/default.json b/public/translations/el/default.json index b6e7241b..d37e8653 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Οι δημοσιεύσεις ενημερώνονται αυτόματα περίπου κάθε ~2 λεπτά. Δεν είναι δυνατό να απενεργοποιήσετε αυτό τη στιγμή.", "board_address_tooltip": "Η διεύθυνση του κόμβου peer-to-peer αυτού του πίνακα", "vote_button_unavailable_intro": "Δεν είναι διαθέσιμο ακόμα. Οι χρήστες θα μπορούν να υποβάλουν τις δικές τους σανίδες και να ψηφίσουν γι' αυτές ώστε να ανταγωνίζονται για θέσεις σε φακέλους, όπως /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Η /{{boardIdentifier}}/ με τους περισσότερους ψήφους γίνεται η επίσημη /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Η /{{boardIdentifier}}/ με τους περισσότερους ψήφους γίνεται η επίσημη /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 60ca5fb1..103497e8 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -281,5 +281,8 @@ "copy_direct_link": "Copy direct link", "board_address_tooltip": "The address of this board's peer-to-peer node", "vote_button_unavailable_intro": "Not available yet. Users will be able to submit their own boards, and vote for them, to compete for directory slots, like /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "The highest-voted /{{boardIdentifier}}/ becomes the official /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "The highest-voted /{{boardIdentifier}}/ becomes the official /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/es/default.json b/public/translations/es/default.json index 53c6f9f4..ba8aecc1 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Los posts se actualizan automáticamente cada ~2 minutos. Por el momento, no es posible desactivar esto.", "board_address_tooltip": "La dirección del nodo peer-to-peer de este tablón", "vote_button_unavailable_intro": "Aún no disponible. Los usuarios podrán enviar sus propios tableros y votar por ellos para competir por espacios de directorio, como /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "El tablero /{{boardIdentifier}}/ más votado se convierte en el oficial /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "El tablero /{{boardIdentifier}}/ más votado se convierte en el oficial /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index 6dcbbaaa..2f3a6c40 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "پست‌ها هر ~2 دقیقه به‌طور خودکار به‌روز می‌شوند. فعلاً امکان غیرفعال کردن آن وجود ندارد.", "board_address_tooltip": "آدرس گره هم‌تا-همتای این تخته", "vote_button_unavailable_intro": "هنوز در دسترس نیست. کاربران می‌توانند بوردهای خود را ارسال کنند و برای آنها رای دهند تا برای شکاف‌های دایرکتوری رقابت کنند، مانند /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "بیشترین رای‌شده /{{boardIdentifier}}/ به /{{boardIdentifier}}/ رسمی تبدیل می‌شود." + "vote_button_unavailable_outro": "بیشترین رای‌شده /{{boardIdentifier}}/ به /{{boardIdentifier}}/ رسمی تبدیل می‌شود.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index f71226a7..a3042f0e 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Viestit päivittyvät automaattisesti noin 2 minuutin välein. Tätä ei ole mahdollista poistaa käytöstä tällä hetkellä.", "board_address_tooltip": "Tämän laudan vertaisverkko-solmun osoite", "vote_button_unavailable_intro": "Ei vielä käytettävissä. Käyttäjät voivat lähettää omia lautojaan ja äänestää niitä kilpaillakseen hakemistopaikoista, kuten /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Eniten ääniä saanut /{{boardIdentifier}}/ tulee viralliseksi /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Eniten ääniä saanut /{{boardIdentifier}}/ tulee viralliseksi /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index 5b7636d8..ea7da842 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Ang mga post ay awtomatikong nag-update bawat ~2 minuto. Kasalukuyang hindi posible na i-disable ito.", "board_address_tooltip": "Ang address ng peer-to-peer node ng board na ito", "vote_button_unavailable_intro": "Hindi pa available. Ang mga user ay makakagawa ng kanilang sariling mga board at mag-boto para sa kanila upang makipagkompetensya para sa mga slot sa directory, tulad ng /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Ang /{{boardIdentifier}}/ na may pinakamataas na boto ay nagiging ang opisyal na /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Ang /{{boardIdentifier}}/ na may pinakamataas na boto ay nagiging ang opisyal na /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index 48be4ee0..ceff6e30 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Les messages se mettent à jour automatiquement toutes les ~2 minutes. Il n'est pas possible de désactiver cela pour le moment.", "board_address_tooltip": "L'adresse du nœud pair-à-pair de ce tableau", "vote_button_unavailable_intro": "Pas encore disponible. Les utilisateurs pourront soumettre leurs propres tableaux et voter pour eux pour rivaliser pour les emplacements du répertoire, comme /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Le tableau /{{boardIdentifier}}/ le plus voté devient le tableau officiel /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Le tableau /{{boardIdentifier}}/ le plus voté devient le tableau officiel /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/he/default.json b/public/translations/he/default.json index e7065902..0c2036b6 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "הפוסטים מתעדכנים באופן אוטומטי בערך כל ~2 דקות. כרגע לא ניתן להשבית זאת.", "board_address_tooltip": "כתובת צומת ה-P2P של הלוח הזה", "vote_button_unavailable_intro": "עדיין לא זמין. משתמשים יוכלו להגיש לוחות משלהם ולהצביע עליהם כדי להתחרות על משבצות בספרייה, כגון /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "/{{boardIdentifier}}/ בעל ההצבעות הרבות ביותר הופך ל- /{{boardIdentifier}}/ הרשמי." + "vote_button_unavailable_outro": "/{{boardIdentifier}}/ בעל ההצבעות הרבות ביותר הופך ל- /{{boardIdentifier}}/ הרשמי.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index 23a5d629..e1813dc7 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "पोस्ट्स हर ~2 मिनट में स्वचालित रूप से अपडेट होते हैं। फिलहाल इसे अक्षम करना संभव नहीं है।", "board_address_tooltip": "इस बोर्ड के पीयर-टू-पीयर नोड का पता", "vote_button_unavailable_intro": "अभी उपलब्ध नहीं है। उपयोगकर्ता अपने स्वयं के बोर्ड जमा कर सकेंगे और उनके लिए वोट कर सकेंगे, जैसे /{{boardIdentifier}}/ के लिए निर्देशिका स्लॉट के लिए प्रतिस्पर्धा कर सकेंगे।", - "vote_button_unavailable_outro": "सर्वाधिक मतदान प्राप्त /{{boardIdentifier}}/ आधिकारिक /{{boardIdentifier}}/ बन जाता है।" + "vote_button_unavailable_outro": "सर्वाधिक मतदान प्राप्त /{{boardIdentifier}}/ आधिकारिक /{{boardIdentifier}}/ बन जाता है।", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index 5d978eb3..024a5eae 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "A bejegyzések kb. 2 percenként automatikusan frissülnek. Jelenleg nem lehetséges ezt letiltani.", "board_address_tooltip": "Ennek a táblának a peer-to-peer csomópontja címe", "vote_button_unavailable_intro": "Még nem érhető el. A felhasználók majd küldhetnek saját táblákat és szavazhatnak rájuk, hogy versenyezzenek a könyvtári helyekért, például /{{boardIdentifier}}/ esetén.", - "vote_button_unavailable_outro": "A legtöbb szavazatot kapott /{{boardIdentifier}}/ lesz a hivatalos /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "A legtöbb szavazatot kapott /{{boardIdentifier}}/ lesz a hivatalos /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/id/default.json b/public/translations/id/default.json index 7b7dc57d..481b58e3 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Posting diperbarui secara otomatis setiap ~2 menit. Saat ini tidak mungkin untuk menonaktifkan ini.", "board_address_tooltip": "Alamat node peer-to-peer papan ini", "vote_button_unavailable_intro": "Belum tersedia. Pengguna akan dapat mengirimkan papan mereka sendiri dan memilih mereka untuk bersaing mendapatkan slot direktori, seperti /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "/{{boardIdentifier}}/ dengan suara terbanyak menjadi /{{boardIdentifier}}/ resmi." + "vote_button_unavailable_outro": "/{{boardIdentifier}}/ dengan suara terbanyak menjadi /{{boardIdentifier}}/ resmi.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/it/default.json b/public/translations/it/default.json index a0c50d52..f610999e 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "I post si aggiornano automaticamente ogni ~2 minuti. Non è possibile disabilitare questa funzione al momento.", "board_address_tooltip": "L'indirizzo del nodo peer-to-peer di questa bacheca", "vote_button_unavailable_intro": "Non ancora disponibile. Gli utenti potranno inviare i loro board e votarli per competere per gli slot della directory, come /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Il /{{boardIdentifier}}/ più votato diventa il /{{boardIdentifier}}/ ufficiale." + "vote_button_unavailable_outro": "Il /{{boardIdentifier}}/ più votato diventa il /{{boardIdentifier}}/ ufficiale.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 61da13cc..5581a979 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "投稿は約2分ごとに自動更新されます。現在、これを無効にすることはできません。", "board_address_tooltip": "この板のピアツーピアノードのアドレス", "vote_button_unavailable_intro": "まだ利用できません。ユーザーは独自のボードを送信し、投票してディレクトリスロットを競うことができます。例えば /{{boardIdentifier}}/ のように。", - "vote_button_unavailable_outro": "最も投票された /{{boardIdentifier}}/ が公式の /{{boardIdentifier}}/ になります。" + "vote_button_unavailable_outro": "最も投票された /{{boardIdentifier}}/ が公式の /{{boardIdentifier}}/ になります。", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index 902fedba..4c63288d 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "게시물은 약 2분마다 자동으로 업데이트됩니다. 현재 이를 비활성화할 수 없습니다.", "board_address_tooltip": "이 게시판의 P2P 노드 주소", "vote_button_unavailable_intro": "아직 사용할 수 없습니다. 사용자는 자신의 보드를 제출하고 투표하여 /{{boardIdentifier}}/와 같은 디렉토리 슬롯을 놓고 경쟁할 수 있습니다.", - "vote_button_unavailable_outro": "가장 많은 투표를 받은 /{{boardIdentifier}}/이 공식 /{{boardIdentifier}}/이 됩니다." + "vote_button_unavailable_outro": "가장 많은 투표를 받은 /{{boardIdentifier}}/이 공식 /{{boardIdentifier}}/이 됩니다.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index 3b9e250a..712009f2 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "पोस्ट प्रत्येक ~2 मिनिटात स्वयंचलितपणे अपडेट होतात. सध्या हे अक्षम करणे शक्य नाही.", "board_address_tooltip": "या बोर्डच्या पीअर-टू-पीअर नोडचा पत्ता", "vote_button_unavailable_intro": "अद्याप उपलब्ध नाही. वापरकर्ते त्यांचे स्वतःचे बोर्ड सबमिट करू शकतील आणि /{{boardIdentifier}}/ सारख्या डायरेक्टरी स्लॉटसाठी स्पर्धा करण्यासाठी त्यांच्यासाठी व्होट करू शकतील.", - "vote_button_unavailable_outro": "सर्वाधिक मतदान केलेले /{{boardIdentifier}}/ अधिकृत /{{boardIdentifier}}/ बन जाते." + "vote_button_unavailable_outro": "सर्वाधिक मतदान केलेले /{{boardIdentifier}}/ अधिकृत /{{boardIdentifier}}/ बन जाते.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index d45ecb51..6edcf9a9 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Berichten worden automatisch ongeveer elke ~2 minuten bijgewerkt. Het is momenteel niet mogelijk dit uit te schakelen.", "board_address_tooltip": "Het adres van de peer-to-peer-node van dit bord", "vote_button_unavailable_intro": "Nog niet beschikbaar. Gebruikers kunnen hun eigen borden indienen en erop stemmen om te concurreren voor directorysleuven, zoals /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Het /{{boardIdentifier}}/ met de meeste stemmen wordt het officiële /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Het /{{boardIdentifier}}/ met de meeste stemmen wordt het officiële /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/no/default.json b/public/translations/no/default.json index 0d9f9a4b..8f6e9160 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Innlegg oppdateres automatisk omtrent hver ~2 minutt. Det er ikke mulig å deaktivere dette for øyeblikket.", "board_address_tooltip": "Adressen til denne tavlens peer-to-peer-node", "vote_button_unavailable_intro": "Ikke tilgjengelig ennå. Brukere vil kunne sende sine egne brett og stemme for dem for å konkurrere om katalogplasser, som /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest stemmer blir det offisielle /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest stemmer blir det offisielle /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 989bcddf..02436e92 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Posty aktualizują się automatycznie co ~2 minuty. Chwilowo nie jest możliwe wyłączenie tej funkcji.", "board_address_tooltip": "Adres węzła peer-to-peer tej tablicy", "vote_button_unavailable_intro": "Niedostępne. Użytkownicy będą mogli przesyłać własne tablice i głosować na nie, aby konkurować o miejsca w katalogu, takie jak /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Tablica /{{boardIdentifier}}/ z największą liczbą głosów staje się oficjalną /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Tablica /{{boardIdentifier}}/ z największą liczbą głosów staje się oficjalną /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 2d009f9f..6b2f6880 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Posts são atualizados automaticamente a cada ~2 minutos. Não é possível desabilitar isso no momento.", "board_address_tooltip": "O endereço do nó peer-to-peer desta placa", "vote_button_unavailable_intro": "Ainda não disponível. Os usuários poderão enviar seus próprios boards e votar neles para competir por slots de diretório, como /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "O /{{boardIdentifier}}/ mais votado se torna o /{{boardIdentifier}}/ oficial." + "vote_button_unavailable_outro": "O /{{boardIdentifier}}/ mais votado se torna o /{{boardIdentifier}}/ oficial.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index bda20d88..1bd2d1a0 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Postările se actualizează automat la fiecare ~2 minute. În prezent, nu este posibil să dezactivezi aceasta.", "board_address_tooltip": "Adresa nodului peer-to-peer al acestei plăci", "vote_button_unavailable_intro": "Nu este disponibil deocamdată. Utilizatorii vor putea trimite propriile tablouri și vota pentru ele pentru a concura pentru locuri în director, cum ar fi /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Tabloul /{{boardIdentifier}}/ cu cele mai multe voturi devine /{{boardIdentifier}}/ oficial." + "vote_button_unavailable_outro": "Tabloul /{{boardIdentifier}}/ cu cele mai multe voturi devine /{{boardIdentifier}}/ oficial.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index 9a850154..aa60d9c0 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Посты обновляются автоматически примерно каждые ~2 минуты. В данный момент невозможно отключить эту функцию.", "board_address_tooltip": "Адрес пирингового узла этой доски", "vote_button_unavailable_intro": "Пока недоступно. Пользователи смогут отправлять собственные доски и голосовать за них, чтобы конкурировать за места в каталоге, например /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Набравший наибольшее количество голосов /{{boardIdentifier}}/ становится официальным /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Набравший наибольшее количество голосов /{{boardIdentifier}}/ становится официальным /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index 0008ddcc..d5ed3b00 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Postimet përditësohen automatikisht çdo ~2 minuta. Nuk është e mundur ta çaktivizoni këtë për momentin.", "board_address_tooltip": "Adresa e nyjës peer-to-peer të kësaj tabele", "vote_button_unavailable_intro": "Ende jo i disponueshëm. Përdoruesit do të jenë në gjendje të dërgojnë bordet e tyre dhe të votojnë për to për të konkurruar për vende në drejtori, si /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "/{{boardIdentifier}}/ me më shumë vota bëhet /{{boardIdentifier}}/ zyrtare." + "vote_button_unavailable_outro": "/{{boardIdentifier}}/ me më shumë vota bëhet /{{boardIdentifier}}/ zyrtare.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index f6e1193f..048c3ad4 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Inlägg uppdateras automatiskt ungefär var ~2:e minut. Det är för närvarande inte möjligt att inaktivera detta.", "board_address_tooltip": "Adressen till denna tavlas peer-to-peer-nod", "vote_button_unavailable_intro": "Inte tillgänglig ännu. Användare kommer att kunna skicka in sina egna kort och rösta för dem för att konkurrera om katalogplatser, som /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest röster blir det officiella /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Det /{{boardIdentifier}}/ med flest röster blir det officiella /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 63db8d14..107a39fb 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "పోస్టులు ప్రతి ~2 నిమిషాలకు స్వయంచాలకంగా నవీకరించబడతాయి. ప్రస్తుతం దీనిని నిలిపివేయడం సম్భవం కాదు.", "board_address_tooltip": "ఈ బోర్డ్ యొక్క పీర్-టు-పీర్ నోడ్ యొక్క చిరునామా", "vote_button_unavailable_intro": "ఇంకా అందుబాటులో లేదు. వినియోగదారులు తమ స్వంత బోర్డులను సమర్పించవచ్చు మరియు /{{boardIdentifier}}/ వంటి డైరెక్టరీ స్లాట్‌ల కోసం వాటికి ఓటు వేయవచ్చు.", - "vote_button_unavailable_outro": "సర్వాధిక ఓట్లను పొందిన /{{boardIdentifier}}/ అధికారిక /{{boardIdentifier}}/ అవుతుంది." + "vote_button_unavailable_outro": "సర్వాధిక ఓట్లను పొందిన /{{boardIdentifier}}/ అధికారిక /{{boardIdentifier}}/ అవుతుంది.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/th/default.json b/public/translations/th/default.json index bc82f4c3..dcec5926 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "โพสต์จะอัปเดตโดยอัตโนมัติทุก ~2 นาที ไม่สามารถปิดการใช้งานนี้ได้ในขณะนี้", "board_address_tooltip": "ที่อยู่โหนด P2P ของบอร์ดนี้", "vote_button_unavailable_intro": "ยังไม่พร้อมใช้งาน ผู้ใช้จะสามารถส่งบอร์ดของตนเองและโหวตเพื่อแข่งขันเพื่อช่องในไดเรกทอรี เช่น /{{boardIdentifier}}/ ได้", - "vote_button_unavailable_outro": "/{{boardIdentifier}}/ ที่ได้โหวตมากที่สุดจะกลายเป็น /{{boardIdentifier}}/ อย่างเป็นทางการ" + "vote_button_unavailable_outro": "/{{boardIdentifier}}/ ที่ได้โหวตมากที่สุดจะกลายเป็น /{{boardIdentifier}}/ อย่างเป็นทางการ", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index 1cc94bf8..40b3e941 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Gönderiler her ~2 dakikada otomatik olarak güncellenir. Şu anda bunu devre dışı bırakmak mümkün değildir.", "board_address_tooltip": "Bu panonun eşler arası düğüm adresi", "vote_button_unavailable_intro": "Henüz mevcut değil. Kullanıcılar kendi panolarını gönderebilecek ve /{{boardIdentifier}}/ gibi dizin yuvaları için rekabet etmek üzere oy verebilecekler.", - "vote_button_unavailable_outro": "En çok oy alan /{{boardIdentifier}}/ resmi /{{boardIdentifier}}/ olur." + "vote_button_unavailable_outro": "En çok oy alan /{{boardIdentifier}}/ resmi /{{boardIdentifier}}/ olur.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index 87b9590a..a9e2b1e3 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Дописи оновлюються автоматично приблизно кожні ~2 хвилини. В даний момент неможливо вимкнути цю функцію.", "board_address_tooltip": "Адреса пірінгового вузла цієї дошки", "vote_button_unavailable_intro": "Поки недоступно. Користувачі зможуть подавати власні дошки та голосувати за них, щоб змагатися за місця в каталозі, як-от /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "Найбільш проголосована /{{boardIdentifier}}/ стає офіційною /{{boardIdentifier}}/." + "vote_button_unavailable_outro": "Найбільш проголосована /{{boardIdentifier}}/ стає офіційною /{{boardIdentifier}}/.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index 90c426e9..b16eb6df 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "پوسٹس ہر ~2 منٹ میں خود بخود اپ ڈیٹ ہوتے ہیں۔ فی الوقت اس کو غیر فعال کرنا ممکن نہیں ہے۔", "board_address_tooltip": "اس بورڈ کے پیر ٹو پیر نوڈ کا پتہ", "vote_button_unavailable_intro": "ابھی دستیاب نہیں۔ صارفین اپنے خود کے بورڈز جمع کر سکیں گے اور ان کے لیے ووٹ دے سکیں گے، جیسے /{{boardIdentifier}}/ کے لیے ڈائریکٹری سلاٹس کے لیے مقابلہ کرنے کے لیے۔", - "vote_button_unavailable_outro": "سب سے زیادہ ووٹ والا /{{boardIdentifier}}/ سرکاری /{{boardIdentifier}}/ بن جاتا ہے۔" + "vote_button_unavailable_outro": "سب سے زیادہ ووٹ والا /{{boardIdentifier}}/ سرکاری /{{boardIdentifier}}/ بن جاتا ہے۔", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index 569f7d34..f3cad968 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "Bài đăng được cập nhật tự động cứ ~2 phút một lần. Hiện tại không thể tắt tính năng này.", "board_address_tooltip": "Địa chỉ nút peer-to-peer của bảng này", "vote_button_unavailable_intro": "Chưa có sẵn. Người dùng sẽ có thể gửi các bảng của riêng họ và bình chọn cho chúng để cạnh tranh các vị trí thư mục, như /{{boardIdentifier}}/.", - "vote_button_unavailable_outro": "/{{boardIdentifier}}/ được bình chọn nhiều nhất trở thành /{{boardIdentifier}}/ chính thức." + "vote_button_unavailable_outro": "/{{boardIdentifier}}/ được bình chọn nhiều nhất trở thành /{{boardIdentifier}}/ chính thức.", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index 8c41c2d4..e67d638f 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -281,5 +281,8 @@ "posts_auto_update_info": "帖子每约2分钟自动更新一次。目前无法禁用此功能。", "board_address_tooltip": "此板块的点对点节点地址", "vote_button_unavailable_intro": "尚不可用。用户将能够提交自己的板块,投票支持他们,以竞争目录插槽,如 /{{boardIdentifier}}/。", - "vote_button_unavailable_outro": "投票最多的 /{{boardIdentifier}}/ 将成为官方 /{{boardIdentifier}}/。" + "vote_button_unavailable_outro": "投票最多的 /{{boardIdentifier}}/ 将成为官方 /{{boardIdentifier}}/。", + "upload_failed": "Upload failed", + "upload_not_supported_web": "Uploading media isn't supported by your browser due to technical limitations (CORS). It is supported in the 5chan Android app and Mac/Linux/Windows desktop app. Download from the official release page: https://github.com/bitsocialhq/5chan/releases/latest", + "file": "File" } diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx index 4fc8b088..9b87de21 100644 --- a/src/components/post-form/post-form.tsx +++ b/src/components/post-form/post-form.tsx @@ -15,13 +15,10 @@ import useFetchGifFirstFrame from '../../hooks/use-fetch-gif-first-frame'; import useIsSubplebbitOffline from '../../hooks/use-is-subplebbit-offline'; import usePublishPost from '../../hooks/use-publish-post'; import usePublishReply from '../../hooks/use-publish-reply'; -import FileUploader from '../../plugins/file-uploader'; +import { useFileUpload } from '../../hooks/use-file-upload'; import styles from './post-form.module.css'; -import { Capacitor } from '@capacitor/core'; import { capitalize, debounce } from 'lodash'; -const isAndroid = Capacitor.getPlatform() === 'android'; - // Separate component for offline alert to isolate rerenders from updatingState // Only this component will rerender when updatingState changes, not the whole PostForm const OfflineAlert = ({ subplebbitAddress }: { subplebbitAddress: string | undefined }) => { @@ -197,35 +194,17 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: } }, [replyIndex, resetPublishReplyOptions, closeForm]); - // on android, auto upload file to image hosting sites with open api - const [isUploading, setIsUploading] = useState(false); - const [uploadedFileName, setUploadedFileName] = useState(null); - const handleUpload = async () => { - try { - setIsUploading(true); - const result = await FileUploader.pickAndUploadMedia(); - console.log('Upload result:', result); - if (result.url) { - setUrl(result.url); + const { isUploading, uploadedFileName, handleUpload } = useFileUpload({ + onUploadComplete: (uploadedUrl: string) => { + if (uploadedUrl) { + setUrl(uploadedUrl); if (urlRef.current) { - urlRef.current.value = result.url; - } - isInPostView ? setPublishReplyOptions({ link: result.url || undefined }) : setPublishPostOptions({ link: result.url || undefined }); - if (result.fileName) { - setUploadedFileName(result.fileName); + urlRef.current.value = uploadedUrl; } + isInPostView ? setPublishReplyOptions({ link: uploadedUrl }) : setPublishPostOptions({ link: uploadedUrl }); } - } catch (error) { - console.error('Upload failed:', error); - if (error instanceof Error && error.message !== 'File selection cancelled') { - alert(`${t('upload_failed')}: ${error.message}`); - } else if (typeof error === 'string' && error !== 'File selection cancelled') { - alert(`${t('upload_failed')}: ${error}`); - } - } finally { - setIsUploading(false); - } - }; + }, + }); const hasInitializedDisplayName = useRef(false); useEffect(() => { @@ -306,17 +285,15 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: {url && } - {isAndroid && ( - - {t('file')} - - - {uploadedFileName ? uploadedFileName : t('no_file_chosen')} - - - )} + + {t('file')} + + + {isUploading ? t('uploading') : uploadedFileName || t('no_file_chosen')} + + {t('options')} diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index d7d8ea8f..769e36bc 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -11,16 +11,13 @@ import useSelectedTextStore from '../../stores/use-selected-text-store'; import useReplyModalStore from '../../stores/use-reply-modal-store'; import usePublishReply from '../../hooks/use-publish-reply'; import useIsMobile from '../../hooks/use-is-mobile'; +import { useFileUpload } from '../../hooks/use-file-upload'; import styles from './reply-modal.module.css'; import { LinkTypePreviewer } from '../post-form'; import { capitalize, debounce } from 'lodash'; -import FileUploader from '../../plugins/file-uploader'; -import { Capacitor } from '@capacitor/core'; import { useSpring, animated } from '@react-spring/web'; import { useDrag } from '@use-gesture/react'; -const isAndroid = Capacitor.getPlatform() === 'android'; - interface ReplyModalProps { closeModal: () => void; showReplyModal: boolean; @@ -263,35 +260,17 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa checkContentLength(formattedContent, t); }, [showReplyModal, quoteInsertRequestId, quoteInsertNumber, quoteInsertSelectedText, setPublishReplyOptions, checkContentLength, t]); - // on android, auto upload file to image hosting sites with open api - const [isUploading, setIsUploading] = useState(false); - const [uploadedFileName, setUploadedFileName] = useState(null); - const handleUpload = async () => { - try { - setIsUploading(true); - const result = await FileUploader.pickAndUploadMedia(); - console.log('Upload result:', result); - if (result.url) { - setUrl(result.url); + const { isUploading, uploadedFileName, handleUpload } = useFileUpload({ + onUploadComplete: (uploadedUrl: string) => { + if (uploadedUrl) { + setUrl(uploadedUrl); if (urlRef.current) { - urlRef.current.value = result.url; - } - setPublishReplyOptions({ link: result.url || undefined }); - if (result.fileName) { - setUploadedFileName(result.fileName); + urlRef.current.value = uploadedUrl; } + setPublishReplyOptions({ link: uploadedUrl }); } - } catch (error) { - console.error('Upload failed, ', error); - if (error instanceof Error && error.message !== 'File selection cancelled') { - setError(`${t('upload_failed')}, ${error.message}`); - } else if (typeof error === 'string' && error !== 'File selection cancelled') { - setError(`${t('upload_failed')}, ${error}`); - } - } finally { - setIsUploading(false); - } - }; + }, + }); const hasInitializedDisplayName = useRef(false); useEffect(() => { @@ -339,6 +318,7 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa type='text' ref={urlRef} placeholder={capitalize(t('link'))} + disabled={isUploading} onChange={(e) => { setUrl(e.target.value); setPublishReplyOptions({ link: e.target.value }); @@ -365,23 +345,21 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, parentNumber, threa />
- {url && !isAndroid && ( + {url && ( <> {t('link_type')}: )} - {isAndroid && ( - - - - - - {uploadedFileName ? uploadedFileName : t('no_file_chosen')} - + + + - )} + + {isUploading ? t('uploading') : uploadedFileName || t('no_file_chosen')} + + [