mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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<string | null>(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:
|
||||
<span className={styles.linkType}> {url && <LinkTypePreviewer link={url} />}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{isAndroid && (
|
||||
<tr className={styles.uploadButton}>
|
||||
<td>{t('file')}</td>
|
||||
<td>
|
||||
<button onClick={handleUpload} disabled={isUploading}>
|
||||
{isUploading ? t('uploading') : t('choose_file')}
|
||||
</button>
|
||||
<span>{uploadedFileName ? uploadedFileName : t('no_file_chosen')}</span>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr className={styles.uploadButton}>
|
||||
<td>{t('file')}</td>
|
||||
<td>
|
||||
<button onClick={handleUpload} disabled={isUploading}>
|
||||
{t('choose_file')}
|
||||
</button>
|
||||
<span>{isUploading ? t('uploading') : uploadedFileName || t('no_file_chosen')}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr className={styles.spoilerButton}>
|
||||
<td>{t('options')}</td>
|
||||
<td>
|
||||
|
||||
@@ -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<string | null>(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
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.footer}>
|
||||
{url && !isAndroid && (
|
||||
{url && (
|
||||
<>
|
||||
{t('link_type')}: <LinkTypePreviewer link={url} />
|
||||
</>
|
||||
)}
|
||||
{isAndroid && (
|
||||
<span className={styles.uploadContainer}>
|
||||
<span className={styles.uploadButton}>
|
||||
<button onClick={handleUpload} disabled={isUploading}>
|
||||
{isUploading ? t('uploading') : t('choose_file')}
|
||||
</button>
|
||||
</span>
|
||||
<span className={styles.uploadFileName} title={uploadedFileName ? uploadedFileName : t('no_file_chosen')}>
|
||||
{uploadedFileName ? uploadedFileName : t('no_file_chosen')}
|
||||
</span>
|
||||
<span className={styles.uploadContainer}>
|
||||
<span className={styles.uploadButton}>
|
||||
<button onClick={handleUpload} disabled={isUploading}>
|
||||
{t('choose_file')}
|
||||
</button>
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.uploadFileName} title={uploadedFileName || t('no_file_chosen')}>
|
||||
{isUploading ? t('uploading') : uploadedFileName || t('no_file_chosen')}
|
||||
</span>
|
||||
</span>
|
||||
<span className={styles.spoilerButton}>
|
||||
[
|
||||
<label>
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
import * as React from 'react';
|
||||
import { createElement } from 'react';
|
||||
import { createRoot, Root } from 'react-dom/client';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import FileUploader from '../../plugins/file-uploader';
|
||||
import { uploadToCatbox } from '../../lib/utils/catbox-utils';
|
||||
import { useFileUpload } from '../use-file-upload';
|
||||
|
||||
// Enable React's act environment for hook state updates in tests.
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
||||
const act = (React as any).act as (callback: () => void | Promise<void>) => void | Promise<void>;
|
||||
|
||||
vi.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
vi.mock('@capacitor/core', () => ({
|
||||
Capacitor: { getPlatform: vi.fn(() => 'web') },
|
||||
}));
|
||||
|
||||
vi.mock('../../plugins/file-uploader', () => ({
|
||||
default: { pickAndUploadMedia: vi.fn() },
|
||||
}));
|
||||
|
||||
vi.mock('../../lib/utils/catbox-utils', () => ({
|
||||
uploadToCatbox: vi.fn(),
|
||||
}));
|
||||
|
||||
type HookSnapshot = ReturnType<typeof useFileUpload>;
|
||||
|
||||
let latestHook: HookSnapshot | null = null;
|
||||
let root: Root;
|
||||
let container: HTMLDivElement;
|
||||
|
||||
const HookHarness = ({ onUploadComplete }: { onUploadComplete: (url: string, fileName: string) => void }) => {
|
||||
latestHook = useFileUpload({ onUploadComplete });
|
||||
return null;
|
||||
};
|
||||
|
||||
const getHook = (): HookSnapshot => {
|
||||
if (!latestHook) {
|
||||
throw new Error('Hook is not mounted');
|
||||
}
|
||||
return latestHook;
|
||||
};
|
||||
|
||||
const mountHook = (onUploadComplete = vi.fn()) => {
|
||||
act(() => {
|
||||
root.render(createElement(HookHarness, { onUploadComplete }));
|
||||
});
|
||||
return { onUploadComplete, hook: getHook };
|
||||
};
|
||||
|
||||
const selectFileFromHiddenInput = async (file: File | null) => {
|
||||
const picker = document.querySelector('input[type="file"]') as HTMLInputElement | null;
|
||||
expect(picker).not.toBeNull();
|
||||
Object.defineProperty(picker as HTMLInputElement, 'files', {
|
||||
configurable: true,
|
||||
value: file ? [file] : [],
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
picker?.dispatchEvent(new Event('change'));
|
||||
});
|
||||
};
|
||||
|
||||
describe('useFileUpload', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
latestHook = null;
|
||||
container = document.createElement('div');
|
||||
document.body.append(container);
|
||||
root = createRoot(container);
|
||||
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('web');
|
||||
window.electronApi = undefined;
|
||||
vi.spyOn(window, 'alert').mockImplementation(() => undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
act(() => {
|
||||
root.unmount();
|
||||
});
|
||||
container.remove();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('uploads via Android plugin and updates state', async () => {
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('android');
|
||||
vi.mocked(FileUploader.pickAndUploadMedia).mockResolvedValue({
|
||||
url: 'https://files.catbox.moe/android.jpg',
|
||||
fileName: 'android.jpg',
|
||||
});
|
||||
|
||||
const { onUploadComplete, hook } = mountHook();
|
||||
|
||||
await act(async () => {
|
||||
await hook().handleUpload();
|
||||
});
|
||||
|
||||
expect(FileUploader.pickAndUploadMedia).toHaveBeenCalledOnce();
|
||||
expect(onUploadComplete).toHaveBeenCalledWith('https://files.catbox.moe/android.jpg', 'android.jpg');
|
||||
expect(hook().uploadedFileName).toBe('android.jpg');
|
||||
expect(hook().isUploading).toBe(false);
|
||||
});
|
||||
|
||||
it('uploads via Electron file picker + catbox utility', async () => {
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('ios');
|
||||
window.electronApi = { isElectron: true } as any;
|
||||
vi.mocked(uploadToCatbox).mockResolvedValue('https://files.catbox.moe/electron.png');
|
||||
|
||||
const selectedFile = new File(['abc'], 'electron.png', { type: 'image/png' });
|
||||
const { onUploadComplete, hook } = mountHook();
|
||||
|
||||
let uploadPromise: Promise<void> | undefined;
|
||||
await act(async () => {
|
||||
uploadPromise = hook().handleUpload();
|
||||
});
|
||||
await selectFileFromHiddenInput(selectedFile);
|
||||
await act(async () => {
|
||||
await uploadPromise;
|
||||
});
|
||||
|
||||
expect(uploadToCatbox).toHaveBeenCalledWith(selectedFile);
|
||||
expect(onUploadComplete).toHaveBeenCalledWith('https://files.catbox.moe/electron.png', 'electron.png');
|
||||
expect(hook().uploadedFileName).toBe('electron.png');
|
||||
expect(hook().isUploading).toBe(false);
|
||||
});
|
||||
|
||||
it('shows web fallback alert and does not upload', async () => {
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('web');
|
||||
window.electronApi = undefined;
|
||||
const { onUploadComplete, hook } = mountHook();
|
||||
|
||||
await act(async () => {
|
||||
await hook().handleUpload();
|
||||
});
|
||||
|
||||
expect(window.alert).toHaveBeenCalledWith('upload_not_supported_web');
|
||||
expect(uploadToCatbox).not.toHaveBeenCalled();
|
||||
expect(FileUploader.pickAndUploadMedia).not.toHaveBeenCalled();
|
||||
expect(onUploadComplete).not.toHaveBeenCalled();
|
||||
expect(hook().isUploading).toBe(false);
|
||||
});
|
||||
|
||||
it('silently ignores file selection cancellation', async () => {
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('ios');
|
||||
window.electronApi = { isElectron: true } as any;
|
||||
const { onUploadComplete, hook } = mountHook();
|
||||
|
||||
let uploadPromise: Promise<void> | undefined;
|
||||
await act(async () => {
|
||||
uploadPromise = hook().handleUpload();
|
||||
});
|
||||
await selectFileFromHiddenInput(null);
|
||||
await act(async () => {
|
||||
await uploadPromise;
|
||||
});
|
||||
|
||||
expect(uploadToCatbox).not.toHaveBeenCalled();
|
||||
expect(window.alert).not.toHaveBeenCalled();
|
||||
expect(onUploadComplete).not.toHaveBeenCalled();
|
||||
expect(hook().isUploading).toBe(false);
|
||||
});
|
||||
|
||||
it('alerts on upload failure and resets uploading state', async () => {
|
||||
vi.mocked(Capacitor.getPlatform).mockReturnValue('android');
|
||||
vi.mocked(FileUploader.pickAndUploadMedia).mockRejectedValue(new Error('boom'));
|
||||
const { onUploadComplete, hook } = mountHook();
|
||||
|
||||
await act(async () => {
|
||||
await hook().handleUpload();
|
||||
});
|
||||
|
||||
expect(window.alert).toHaveBeenCalledWith('upload_failed: boom');
|
||||
expect(onUploadComplete).not.toHaveBeenCalled();
|
||||
expect(hook().isUploading).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import FileUploader from '../plugins/file-uploader';
|
||||
import { uploadToCatbox } from '../lib/utils/catbox-utils';
|
||||
|
||||
const FILE_SELECTION_CANCELLED_ERROR = 'File selection cancelled';
|
||||
|
||||
export interface UseFileUploadOptions {
|
||||
onUploadComplete: (url: string, fileName: string) => void;
|
||||
}
|
||||
|
||||
function selectFileViaInput(): Promise<File | null> {
|
||||
return new Promise((resolve) => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = 'image/jpeg,image/png,video/mp4,video/webm';
|
||||
input.style.display = 'none';
|
||||
|
||||
const cleanup = () => {
|
||||
input.remove();
|
||||
window.removeEventListener('focus', onFocus);
|
||||
};
|
||||
|
||||
const onFocus = () => {
|
||||
window.removeEventListener('focus', onFocus);
|
||||
setTimeout(() => {
|
||||
if (input.files && input.files.length > 0) {
|
||||
return;
|
||||
}
|
||||
cleanup();
|
||||
resolve(null);
|
||||
}, 100);
|
||||
};
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
window.removeEventListener('focus', onFocus);
|
||||
if (input.files && input.files.length > 0) {
|
||||
const file = input.files[0];
|
||||
cleanup();
|
||||
resolve(file);
|
||||
} else {
|
||||
cleanup();
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('focus', onFocus);
|
||||
document.body.appendChild(input);
|
||||
input.click();
|
||||
});
|
||||
}
|
||||
|
||||
export function useFileUpload(options: UseFileUploadOptions) {
|
||||
const { t } = useTranslation();
|
||||
const { onUploadComplete } = options;
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const [uploadedFileName, setUploadedFileName] = useState<string | null>(null);
|
||||
|
||||
const handleUpload = useCallback(async () => {
|
||||
try {
|
||||
setIsUploading(true);
|
||||
setUploadedFileName(null);
|
||||
|
||||
if (Capacitor.getPlatform() === 'android') {
|
||||
const result = await FileUploader.pickAndUploadMedia();
|
||||
if (result.url) {
|
||||
if (result.fileName) {
|
||||
setUploadedFileName(result.fileName);
|
||||
}
|
||||
onUploadComplete(result.url, result.fileName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.electronApi?.isElectron) {
|
||||
const file = await selectFileViaInput();
|
||||
if (!file) {
|
||||
throw new Error(FILE_SELECTION_CANCELLED_ERROR);
|
||||
}
|
||||
|
||||
const url = await uploadToCatbox(file);
|
||||
setUploadedFileName(file.name);
|
||||
onUploadComplete(url, file.name);
|
||||
return;
|
||||
}
|
||||
|
||||
window.alert(t('upload_not_supported_web'));
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
if (errorMessage !== FILE_SELECTION_CANCELLED_ERROR) {
|
||||
window.alert(`${t('upload_failed')}: ${errorMessage}`);
|
||||
}
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
}, [onUploadComplete, t]);
|
||||
|
||||
return {
|
||||
isUploading,
|
||||
uploadedFileName,
|
||||
handleUpload,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { uploadToCatbox } from '../catbox-utils';
|
||||
|
||||
describe('uploadToCatbox', () => {
|
||||
const originalFetch = global.fetch;
|
||||
beforeEach(() => {
|
||||
global.fetch = originalFetch;
|
||||
});
|
||||
|
||||
it('POSTs file to catbox API and returns trimmed URL', async () => {
|
||||
const mockFile = new File(['content'], 'test.png', { type: 'image/png' });
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
text: () => Promise.resolve(' https://files.catbox.moe/abc123.png '),
|
||||
}),
|
||||
);
|
||||
|
||||
const url = await uploadToCatbox(mockFile);
|
||||
expect(url).toBe('https://files.catbox.moe/abc123.png');
|
||||
|
||||
const call = (global.fetch as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
expect(call[0]).toBe('https://catbox.moe/user/api.php');
|
||||
expect(call[1]?.method).toBe('POST');
|
||||
const body = call[1]?.body as FormData;
|
||||
expect(body.get('reqtype')).toBe('fileupload');
|
||||
expect(body.get('fileToUpload')).toBe(mockFile);
|
||||
});
|
||||
|
||||
it('throws Error on non-ok response', async () => {
|
||||
const mockFile = new File(['x'], 'x.txt', { type: 'text/plain' });
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: false,
|
||||
status: 500,
|
||||
statusText: 'Internal Server Error',
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(uploadToCatbox(mockFile)).rejects.toThrow('Upload failed: 500 Internal Server Error');
|
||||
});
|
||||
|
||||
it('throws when fetch rejects with a network error', async () => {
|
||||
const mockFile = new File(['x'], 'x.txt', { type: 'text/plain' });
|
||||
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('Network down')));
|
||||
|
||||
await expect(uploadToCatbox(mockFile)).rejects.toThrow('Network down');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
const CATBOX_API = 'https://catbox.moe/user/api.php';
|
||||
|
||||
/**
|
||||
* Upload a file to catbox.moe.
|
||||
* @param file - The file to upload
|
||||
* @returns The URL of the uploaded file
|
||||
* @throws Error when the response is not ok
|
||||
*/
|
||||
export async function uploadToCatbox(file: File): Promise<string> {
|
||||
const formData = new FormData();
|
||||
formData.append('reqtype', 'fileupload');
|
||||
formData.append('fileToUpload', file);
|
||||
|
||||
const response = await fetch(CATBOX_API, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Upload failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
const text = await response.text();
|
||||
return text.trim();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user