feat(reply modal): display errors in modal

This commit is contained in:
Tom (plebeius.eth)
2024-11-04 17:55:51 +01:00
parent fedada3957
commit 57684438a5
37 changed files with 94 additions and 40 deletions
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "لا تعرض الصور الرمزية بجانب أسماء المستخدمين",
"choose_file": "اختر ملف",
"uploading": "جاري التحميل...",
"no_file_chosen": "لم يتم اختيار أي ملف"
"no_file_chosen": "لم يتم اختيار أي ملف",
"error": "خطأ"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "ব্যবহারকারীর প্রদর্শন নামের পাশে অ্যাভাটারগুলি দেখান না",
"choose_file": "ফাইল নির্বাচন করুন",
"uploading": "আপলোড হচ্ছে...",
"no_file_chosen": "কোন ফাইল নির্বাচিত নয়"
"no_file_chosen": "কোন ফাইল নির্বাচিত নয়",
"error": "ত্রুটি"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Nezobrazovat avatary vedle jmen uživatelů",
"choose_file": "Vyberte soubor",
"uploading": "nahrávání...",
"no_file_chosen": "Žádný soubor není vybrán"
"no_file_chosen": "Žádný soubor není vybrán",
"error": "Chyba"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Vis ikke avatarer ved siden af brugernes visningsnavne",
"choose_file": "Vælg fil",
"uploading": "uploading...",
"no_file_chosen": "Ingen fil valgt"
"no_file_chosen": "Ingen fil valgt",
"error": "Fejl"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Keine Avatare neben den Benutzernamen anzeigen",
"choose_file": "Datei auswählen",
"uploading": "Hochladen...",
"no_file_chosen": "Keine Datei ausgewählt"
"no_file_chosen": "Keine Datei ausgewählt",
"error": "Fehler"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Μην εμφανίζετε τα avatar δίπλα στα ονόματα εμφάνισης χρηστών",
"choose_file": "Επιλέξτε αρχείο",
"uploading": "ανέβασμα...",
"no_file_chosen": "Δεν έχει επιλεγεί αρχείο"
"no_file_chosen": "Δεν έχει επιλεγεί αρχείο",
"error": "Σφάλμα"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Don't display avatars next to user display names",
"choose_file": "Choose File",
"uploading": "uploading...",
"no_file_chosen": "No file chosen"
"no_file_chosen": "No file chosen",
"error": "Error"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "No mostrar avatares junto a los nombres de usuario",
"choose_file": "Elige archivo",
"uploading": "subiendo...",
"no_file_chosen": "Ningún archivo elegido"
"no_file_chosen": "Ningún archivo elegido",
"error": "Error"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "تصاویر پروفایل را در کنار نام‌های نمایش کاربر نمایش ندهید",
"choose_file": "فایل را انتخاب کنید",
"uploading": "در حال بارگذاری...",
"no_file_chosen": "فایلی انتخاب نشده است"
"no_file_chosen": "فایلی انتخاب نشده است",
"error": "خطا"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Älä näytä avatareita käyttäjänäyttönimien vieressä",
"choose_file": "Valitse tiedosto",
"uploading": "lataaminen...",
"no_file_chosen": "Ei tiedostoa valittu"
"no_file_chosen": "Ei tiedostoa valittu",
"error": "Virhe"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Huwag ipakita ang mga avatar sa tabi ng mga display name ng gumagamit",
"choose_file": "Pumili ng File",
"uploading": "ina-upload...",
"no_file_chosen": "Walang napiling file"
"no_file_chosen": "Walang napiling file",
"error": "Error"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Ne pas afficher les avatars à côté des noms d'affichage des utilisateurs",
"choose_file": "Choisissez un fichier",
"uploading": "téléchargement...",
"no_file_chosen": "Aucun fichier choisi"
"no_file_chosen": "Aucun fichier choisi",
"error": "Erreur"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "אל תציג תמונות פרופיל לצד שמות המשתמשים",
"choose_file": "בחר קובץ",
"uploading": "מעלה...",
"no_file_chosen": "לא נבחר קובץ"
"no_file_chosen": "לא נבחר קובץ",
"error": "שגיאה"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "उपयोगकर्ता प्रदर्शित नामों के बगल में अवतार न दिखाएं",
"choose_file": "फाइल चुनें",
"uploading": "अपलोड हो रहा है...",
"no_file_chosen": "कोई फ़ाइल नहीं चुनी गई"
"no_file_chosen": "कोई फ़ाइल नहीं चुनी गई",
"error": "त्रुटि"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Ne jelenjen meg az avatárok a felhasználói megjelenítési nevek mellett",
"choose_file": "Válassza ki a fájlt",
"uploading": "feltöltés...",
"no_file_chosen": "Nincs fájl kiválasztva"
"no_file_chosen": "Nincs fájl kiválasztva",
"error": "Hiba"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Jangan tampilkan avatar di sebelah nama pengguna",
"choose_file": "Pilih Berkas",
"uploading": "mengupload...",
"no_file_chosen": "Tidak ada file yang dipilih"
"no_file_chosen": "Tidak ada file yang dipilih",
"error": "Kesalahan"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Non mostrare gli avatar accanto ai nomi visualizzati degli utenti",
"choose_file": "Scegli File",
"uploading": "caricamento...",
"no_file_chosen": "Nessun file scelto"
"no_file_chosen": "Nessun file scelto",
"error": "Errore"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "ユーザーの表示名の横にアバターを表示しない",
"choose_file": "ファイルを選択",
"uploading": "アップロード中...",
"no_file_chosen": "ファイルが選択されていません"
"no_file_chosen": "ファイルが選択されていません",
"error": "エラー"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "사용자 표시 이름 옆에 아바타를 표시하지 않음",
"choose_file": "파일 선택",
"uploading": "업로드 중...",
"no_file_chosen": "선택된 파일이 없습니다"
"no_file_chosen": "선택된 파일이 없습니다",
"error": "오류"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "युजर डिस्प्ले नावेच्या बरोबर अवतार दर्शवू नका",
"choose_file": "फाइल निवडा",
"uploading": "अपलोड करत आहे...",
"no_file_chosen": "कोणताही फाइल निवडलेली नाही"
"no_file_chosen": "कोणताही फाइल निवडलेली नाही",
"error": "त्रुटी"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Toon geen avatar naast de weergavenamen van gebruikers",
"choose_file": "Kies een bestand",
"uploading": "uploaden...",
"no_file_chosen": "Geen bestand gekozen"
"no_file_chosen": "Geen bestand gekozen",
"error": "Fout"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Vis ikke avatarer ved siden av brukernes visningsnavn",
"choose_file": "Velg fil",
"uploading": "laster opp...",
"no_file_chosen": "Ingen fil valgt"
"no_file_chosen": "Ingen fil valgt",
"error": "Feil"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Nie wyświetlaj avatarów obok nazw wyświetlających użytkowników",
"choose_file": "Wybierz plik",
"uploading": "ładowanie...",
"no_file_chosen": "Nie wybrano żadnego pliku"
"no_file_chosen": "Nie wybrano żadnego pliku",
"error": "Błąd"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Não exiba avatares ao lado dos nomes de exibição dos usuários",
"choose_file": "Escolher arquivo",
"uploading": "carregando...",
"no_file_chosen": "Nenhum arquivo escolhido"
"no_file_chosen": "Nenhum arquivo escolhido",
"error": "Erro"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Nu afișa avatare lângă numele de afișare ale utilizatorilor",
"choose_file": "Alegeți fișierul",
"uploading": "încărcare...",
"no_file_chosen": "Niciun fișier ales"
"no_file_chosen": "Niciun fișier ales",
"error": "Eroare"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Не показывать аватары рядом с именами пользователей",
"choose_file": "Выбрать файл",
"uploading": "загрузка...",
"no_file_chosen": "Файл не выбран"
"no_file_chosen": "Файл не выбран",
"error": "Ошибка"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Mos e tregoni avatarët pranë emrave të shfaqjes së përdoruesve",
"choose_file": "Zgjidhni skedarin",
"uploading": "duke ngarkuar...",
"no_file_chosen": "Nuk është zgjedhur asnjë skedar"
"no_file_chosen": "Nuk është zgjedhur asnjë skedar",
"error": "Gabim"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Visa inte avatarer bredvid användarnas visningsnamn",
"choose_file": "Välj fil",
"uploading": "laddar upp...",
"no_file_chosen": "Ingen fil vald"
"no_file_chosen": "Ingen fil vald",
"error": "Fel"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "వాడుకరి ప్రదర్శన పేర్ల పక్కన అవతార్లు ప్రదర్శించవద్దు",
"choose_file": "ఫైల్ ఎంపిక చేసుకోండి",
"uploading": "అప్‌లోడ్ అవుతోంది...",
"no_file_chosen": "ఎటువంటి ఫైల్ ఎంపిక చేయబడలేదు"
"no_file_chosen": "ఎటువంటి ఫైల్ ఎంపిక చేయబడలేదు",
"error": "దోషం"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "ไม่แสดงอวาตาร์ข้างชื่อผู้ใช้",
"choose_file": "เลือกไฟล์",
"uploading": "กำลังอัปโหลด...",
"no_file_chosen": "ไม่มีไฟล์ที่เลือก"
"no_file_chosen": "ไม่มีไฟล์ที่เลือก",
"error": "ข้อผิดพลาด"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Kullanıcı görünüm adlarının yanında avatarları gösterme",
"choose_file": "Dosya Seç",
"uploading": "yükleniyor...",
"no_file_chosen": "Hiçbir dosya seçilmedi"
"no_file_chosen": "Hiçbir dosya seçilmedi",
"error": "Hata"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Не показувати аватари поряд із іменами користувачів",
"choose_file": "Виберіть файл",
"uploading": "завантаження...",
"no_file_chosen": "Не вибрано жодного файлу"
"no_file_chosen": "Не вибрано жодного файлу",
"error": "Помилка"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "صارف کے ڈسپلے ناموں کے ساتھ اوتار نہ دکھائیں",
"choose_file": "فائل منتخب کریں",
"uploading": "اپ لوڈ ہو رہا ہے...",
"no_file_chosen": "کوئی فائل منتخب نہیں کی گئی"
"no_file_chosen": "کوئی فائل منتخب نہیں کی گئی",
"error": "غلطی"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "Không hiển thị hình đại diện bên cạnh tên hiển thị của người dùng",
"choose_file": "Chọn tệp",
"uploading": "đang tải lên...",
"no_file_chosen": "Không có tệp nào được chọn"
"no_file_chosen": "Không có tệp nào được chọn",
"error": "Lỗi"
}
+2 -1
View File
@@ -259,5 +259,6 @@
"hide_avatars_tip": "不显示用户显示名称旁边的头像",
"choose_file": "选择文件",
"uploading": "正在上传...",
"no_file_chosen": "未选择任何文件"
"no_file_chosen": "未选择任何文件",
"error": "错误"
}
@@ -138,4 +138,15 @@
.title {
cursor: default;
}
}
.error {
width: 294px;
font-family: monospace;
background-color: #E62020;
font-size: 12px;
color: white;
padding: 3px 5px;
margin-top: 1px;
text-shadow: 0 1px rgba(0, 0, 0, 0.20);
}
+13 -5
View File
@@ -72,20 +72,23 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
}
}, [address, getExistingSigner, getNewSigner, setPublishReplyOptions, anonMode, displayName]);
const [error, setError] = useState<string | null>(null);
const onPublishReply = () => {
const currentContent = textRef.current?.value.slice(contentPrefix.length).trim() || '';
const currentUrl = urlRef.current?.value.trim() || '';
if (!currentContent && !currentUrl) {
alert(t('empty_comment_alert'));
setError(t('empty_comment_alert'));
return;
}
if (currentUrl && !isValidURL(currentUrl)) {
alert(t('invalid_url_alert'));
setError(t('invalid_url_alert'));
return;
}
setError(null);
publishReply();
};
@@ -190,11 +193,11 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
}
}
} catch (error) {
console.error('Upload failed:', error);
console.error('Upload failed, ', error);
if (error instanceof Error && error.message !== 'File selection cancelled') {
alert(`${t('upload_failed')}: ${error.message}`);
setError(`${t('upload_failed')}, ${error.message}`);
} else if (typeof error === 'string' && error !== 'File selection cancelled') {
alert(`${t('upload_failed')}: ${error}`);
setError(`${t('upload_failed')}, ${error}`);
}
} finally {
setIsUploading(false);
@@ -279,6 +282,11 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
{t('post')}
</button>
</div>
{error && (
<div className={styles.error}>
{t('error')}: {error}
</div>
)}
</div>
</div>
);