Skip to content

Commit

Permalink
feat(search bar): alert 'invalid subplebbit address' if the user forg…
Browse files Browse the repository at this point in the history
…ot to type the tld
  • Loading branch information
plebeius-eth committed May 23, 2024
1 parent f286edd commit f4798f3
Show file tree
Hide file tree
Showing 37 changed files with 76 additions and 36 deletions.
3 changes: 2 additions & 1 deletion public/translations/ar/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "اظهر",
"plebbit_options": "خيارات plebbit",
"general": "عام",
"own_communities": "المجتمعات الخاصة بي"
"own_communities": "المجتمعات الخاصة بي",
"invalid_community_address": "عنوان المجتمع غير صالح"
}
3 changes: 2 additions & 1 deletion public/translations/bn/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "দেখান",
"plebbit_options": "প্লেবিট বিকল্প",
"general": "সাধারণ",
"own_communities": "নিজস্ব সম্প্রদায়"
"own_communities": "নিজস্ব সম্প্রদায়",
"invalid_community_address": "অবৈধ সম্প্রদায় ঠিকানা"
}
3 changes: 2 additions & 1 deletion public/translations/cs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "ukázat",
"plebbit_options": "plebbit možnosti",
"general": "obecné",
"own_communities": "vlastní komunity"
"own_communities": "vlastní komunity",
"invalid_community_address": "Neplatná adresa komunity"
}
3 changes: 2 additions & 1 deletion public/translations/da/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "vise",
"plebbit_options": "plebbit indstillinger",
"general": "almindelig",
"own_communities": "egne fællesskaber"
"own_communities": "egne fællesskaber",
"invalid_community_address": "Ugyldig fællesskabsadresse"
}
3 changes: 2 additions & 1 deletion public/translations/de/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "zeigen",
"plebbit_options": "plebbit optionen",
"general": "allgemein",
"own_communities": "eigene Gemeinschaften"
"own_communities": "eigene Gemeinschaften",
"invalid_community_address": "Ungültige Gemeindeadresse"
}
3 changes: 2 additions & 1 deletion public/translations/el/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "εμφάνιση",
"plebbit_options": "επιλογές plebbit",
"general": "γενικός",
"own_communities": "δικές μου κοινότητες"
"own_communities": "δικές μου κοινότητες",
"invalid_community_address": "Μη έγκυρη διεύθυνση κοινότητας"
}
3 changes: 2 additions & 1 deletion public/translations/en/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "show",
"plebbit_options": "plebbit options",
"general": "general",
"own_communities": "own communities"
"own_communities": "own communities",
"invalid_community_address": "Invalid community address"
}
3 changes: 2 additions & 1 deletion public/translations/es/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "mostrar",
"plebbit_options": "opciones plebbit",
"general": "general",
"own_communities": "comunidades propias"
"own_communities": "comunidades propias",
"invalid_community_address": "Dirección de comunidad no válida"
}
3 changes: 2 additions & 1 deletion public/translations/fa/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "نمایش",
"plebbit_options": "گزینه های plebbit",
"general": "عمومی",
"own_communities": "انجمن‌های خودم"
"own_communities": "انجمن‌های خودم",
"invalid_community_address": "آدرس انجمن نامعتبر است"
}
3 changes: 2 additions & 1 deletion public/translations/fi/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "näyttää",
"plebbit_options": "plebbit-vaihtoehdot",
"general": "yleinen",
"own_communities": "omat yhteisöt"
"own_communities": "omat yhteisöt",
"invalid_community_address": "Virheellinen yhteisön osoite"
}
3 changes: 2 additions & 1 deletion public/translations/fil/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "ipakita",
"plebbit_options": "mga pagpipilian ng plebbit",
"general": "pangkalahatan",
"own_communities": "sariling mga pamayanan"
"own_communities": "sariling mga pamayanan",
"invalid_community_address": "Hindi wastong address ng pamayanan"
}
3 changes: 2 additions & 1 deletion public/translations/fr/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "montrer",
"plebbit_options": "options plebbit",
"general": "général",
"own_communities": "communautés propres"
"own_communities": "communautés propres",
"invalid_community_address": "Adresse de la communauté non valide"
}
3 changes: 2 additions & 1 deletion public/translations/he/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "תצוגה",
"plebbit_options": "אפשרויות plebbit",
"general": "כללי",
"own_communities": "הקהילות שלי"
"own_communities": "הקהילות שלי",
"invalid_community_address": "כתובת הקהילה אינה חוקית"
}
3 changes: 2 additions & 1 deletion public/translations/hi/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "दिखाएँ",
"plebbit_options": "plebbit विकल्प",
"general": "सामान्य",
"own_communities": "खुद की समुदायें"
"own_communities": "खुद की समुदायें",
"invalid_community_address": "अमान्य समुदाय पता"
}
3 changes: 2 additions & 1 deletion public/translations/hu/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "mutat",
"plebbit_options": "plebbit lehetőségek",
"general": "általános",
"own_communities": "saját közösségek"
"own_communities": "saját közösségek",
"invalid_community_address": "Érvénytelen közösségi cím"
}
3 changes: 2 additions & 1 deletion public/translations/id/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "menunjukkan",
"plebbit_options": "opsi plebbit",
"general": "umum",
"own_communities": "komunitas sendiri"
"own_communities": "komunitas sendiri",
"invalid_community_address": "Alamat komunitas tidak valid"
}
3 changes: 2 additions & 1 deletion public/translations/it/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "mostra",
"plebbit_options": "opzioni plebbit",
"general": "generali",
"own_communities": "comunità che possiedo"
"own_communities": "comunità che possiedo",
"invalid_community_address": "Indirizzo comunità non valido"
}
3 changes: 2 additions & 1 deletion public/translations/ja/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "表示",
"plebbit_options": "plebbitのオプション",
"general": "一般的な",
"own_communities": "自分のコミュニティ"
"own_communities": "自分のコミュニティ",
"invalid_community_address": "無効なコミュニティアドレス"
}
3 changes: 2 additions & 1 deletion public/translations/ko/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "보여주다",
"plebbit_options": "plebbit 옵션",
"general": "일반",
"own_communities": "나의 커뮤니티"
"own_communities": "나의 커뮤니티",
"invalid_community_address": "잘못된 커뮤니티 주소"
}
3 changes: 2 additions & 1 deletion public/translations/mr/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "दाखवा",
"plebbit_options": "प्लेबिट पर्याय",
"general": "सामान्य",
"own_communities": "स्वत: समुदाये"
"own_communities": "स्वत: समुदाये",
"invalid_community_address": "अवैध समुदाय पत्ता"
}
3 changes: 2 additions & 1 deletion public/translations/nl/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "tonen",
"plebbit_options": "plebbit-opties",
"general": "algemeen",
"own_communities": "eigen gemeenschappen"
"own_communities": "eigen gemeenschappen",
"invalid_community_address": "Ongeldig gemeenschapsadres"
}
3 changes: 2 additions & 1 deletion public/translations/no/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "vise",
"plebbit_options": "plebbit alternativer",
"general": "generell",
"own_communities": "egne fellesskap"
"own_communities": "egne fellesskap",
"invalid_community_address": "Ugyldig fellesskapsadresse"
}
3 changes: 2 additions & 1 deletion public/translations/pl/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "pokazać",
"plebbit_options": "opcje plebbit",
"general": "ogólny",
"own_communities": "własne społeczności"
"own_communities": "własne społeczności",
"invalid_community_address": "Nieprawidłowy adres społeczności"
}
3 changes: 2 additions & 1 deletion public/translations/pt/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "mostrar",
"plebbit_options": "opções plebbit",
"general": "geral",
"own_communities": "comunidades próprias"
"own_communities": "comunidades próprias",
"invalid_community_address": "Endereço da comunidade inválido"
}
3 changes: 2 additions & 1 deletion public/translations/ro/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "arată",
"plebbit_options": "opțiuni plebbit",
"general": "general",
"own_communities": "comunități proprii"
"own_communities": "comunități proprii",
"invalid_community_address": "Adresă comunitară nevalidă"
}
3 changes: 2 additions & 1 deletion public/translations/ru/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "показать",
"plebbit_options": "опции plebbit",
"general": "общий",
"own_communities": "собственные сообщества"
"own_communities": "собственные сообщества",
"invalid_community_address": "Недействительный адрес сообщества"
}
3 changes: 2 additions & 1 deletion public/translations/sq/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "shfaq",
"plebbit_options": "opsione plebbit",
"general": "i përgjithshëm",
"own_communities": "komunitete të mia"
"own_communities": "komunitete të mia",
"invalid_community_address": "Adresa e komunitetit e pavlefshme"
}
3 changes: 2 additions & 1 deletion public/translations/sv/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "visa",
"plebbit_options": "plebbit-alternativ",
"general": "allmän",
"own_communities": "egna samhällen"
"own_communities": "egna samhällen",
"invalid_community_address": "Ogiltig samhällsadress"
}
3 changes: 2 additions & 1 deletion public/translations/te/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "చూపించు",
"plebbit_options": "plebbit ఎంపికలు",
"general": "సాధారణ",
"own_communities": "నా సముదాయాలు"
"own_communities": "నా సముదాయాలు",
"invalid_community_address": "అమాన్యమైన సముదాయ చిరునామా"
}
3 changes: 2 additions & 1 deletion public/translations/th/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "แสดง",
"plebbit_options": "ตัวเลือก plebbit",
"general": "ทั่วไป",
"own_communities": "ชุมชนของฉัน"
"own_communities": "ชุมชนของฉัน",
"invalid_community_address": "ที่อยู่ชุมชนไม่ถูกต้อง"
}
3 changes: 2 additions & 1 deletion public/translations/tr/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "göstermek",
"plebbit_options": "plebbit seçenekleri",
"general": "genel",
"own_communities": "kendi topluluklarım"
"own_communities": "kendi topluluklarım",
"invalid_community_address": "Geçersiz topluluk adresi"
}
3 changes: 2 additions & 1 deletion public/translations/uk/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "показати",
"plebbit_options": "плебіт варіанти",
"general": "загальний",
"own_communities": "власні спільноти"
"own_communities": "власні спільноти",
"invalid_community_address": "Недійсна адреса спільноти"
}
3 changes: 2 additions & 1 deletion public/translations/ur/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "دکھائیں",
"plebbit_options": "پلیبٹ اختیارات",
"general": "عام",
"own_communities": "اپنی کمیونٹیاں"
"own_communities": "اپنی کمیونٹیاں",
"invalid_community_address": "غیر درست مجتمع کا پتہ"
}
3 changes: 2 additions & 1 deletion public/translations/vi/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "hiển thị",
"plebbit_options": "tùy chọn plebbit",
"general": "chung",
"own_communities": "cộng đồng của riêng tôi"
"own_communities": "cộng đồng của riêng tôi",
"invalid_community_address": "Địa chỉ cộng đồng không hợp lệ"
}
3 changes: 2 additions & 1 deletion public/translations/zh/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,6 @@
"show": "显示",
"plebbit_options": "plebbit选项",
"general": "一般",
"own_communities": "自己的社区"
"own_communities": "自己的社区",
"invalid_community_address": "无效的社区地址"
}
2 changes: 1 addition & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CheckRouteParams = () => {

const isValidAccountCommentIndex = !accountCommentIndex || (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0);
const isValidCommentCid = !commentCid || /^Qm[a-zA-Z0-9]{44}$/.test(commentCid);
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3K[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3KooW[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
const isSortTypeValid = !sortType || sortTypes.includes(sortType);
const isTimeFilterNameValid = !timeFilterName || timeFilterNames.includes(timeFilterName as any);
const isAccountCommentIndexValid = !accountCommentIndex || !isNaN(parseInt(accountCommentIndex));
Expand Down
5 changes: 5 additions & 0 deletions src/components/search-bar/search-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ const SearchBar = ({ isFocused = false }: SearchBarProps) => {
}
const searchInput = searchInputRef.current?.value;
if (searchInput) {
const isValidSubplebbitAddress = searchInput.includes('.') || /^12D3KooW[a-zA-Z0-9]{44}$/.test(searchInput);
if (!isValidSubplebbitAddress) {
alert(t('invalid_community_address'));
return;
}
searchInputRef.current.value = '';
navigate(`/p/${searchInput}`);
}
Expand Down

0 comments on commit f4798f3

Please sign in to comment.