From 13b7b94a534c79dc49b8a8ff895d9fcdd285beb8 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Wed, 6 Mar 2024 10:57:04 +0100 Subject: [PATCH 01/12] fix(inbox): show parent buttons were clickable outside of their space --- src/components/reply/reply.module.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/reply/reply.module.css b/src/components/reply/reply.module.css index 48be003b..3ef08ebf 100644 --- a/src/components/reply/reply.module.css +++ b/src/components/reply/reply.module.css @@ -270,6 +270,7 @@ cursor: pointer; font-weight: 700; color: var(--text-primary); + display: inline-block } .addMargin { @@ -322,6 +323,7 @@ font-size: 13px; color: var(--text-primary); cursor: pointer; + display: inline-block } @media (max-width: 768px) { From ff4a97b9b4e4ece27b98be84edcb4b05608642a6 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Wed, 6 Mar 2024 14:43:59 +0100 Subject: [PATCH 02/12] fix(posts): limit display name character count --- src/components/post/post.tsx | 3 ++- src/components/reply/reply.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index 607e3767..1eb7d54f 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -49,6 +49,7 @@ const PostAuthor = ({ const isAuthorModerator = authorRole === 'moderator'; const moderatorClass = `${isAuthorOwner ? styles.owner : isAuthorAdmin ? styles.admin : isAuthorModerator ? styles.moderator : ''}`; const authorRoleInitial = (isAuthorOwner && 'O') || (isAuthorAdmin && 'A') || (isAuthorModerator && 'M') || ''; + const shortDisplayName = displayName?.length > 20 ? displayName?.slice(0, 20) + '...' : displayName; return ( <> @@ -60,7 +61,7 @@ const PostAuthor = ({ ) : ( <> )} - {displayName && {displayName} } + {displayName && {shortDisplayName} } u/{shortAddress || shortAuthorAddress} u/{shortAuthorAddress} diff --git a/src/components/reply/reply.tsx b/src/components/reply/reply.tsx index a7e95ebf..3ba27802 100644 --- a/src/components/reply/reply.tsx +++ b/src/components/reply/reply.tsx @@ -39,6 +39,7 @@ const ReplyAuthor = ({ address, authorRole, cid, displayName, imageUrl, isAvatar const isAuthorModerator = authorRole === 'moderator'; const authorRoleInitial = (isAuthorOwner && 'O') || (isAuthorAdmin && 'A') || (isAuthorModerator && 'M') || ''; const moderatorClass = `${isAuthorOwner ? styles.owner : isAuthorAdmin ? styles.admin : isAuthorModerator ? styles.moderator : ''}`; + const shortDisplayName = displayName?.length > 20 ? displayName?.slice(0, 20) + '...' : displayName; return ( <> @@ -49,7 +50,7 @@ const ReplyAuthor = ({ address, authorRole, cid, displayName, imageUrl, isAvatar )} {displayName && ( - {displayName}{' '} + {shortDisplayName}{' '} )} From 29b5f72b241b184b787201d738febebf1edcda24 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Wed, 6 Mar 2024 22:15:05 +0100 Subject: [PATCH 03/12] fix(reply): spoiler styling couldn't be clicked --- src/components/post/thumbnail/thumbnail.module.css | 5 +++-- src/components/reply/reply.module.css | 9 +++++---- src/components/reply/reply.tsx | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/post/thumbnail/thumbnail.module.css b/src/components/post/thumbnail/thumbnail.module.css index 5fc7ab2c..dabbaac8 100644 --- a/src/components/post/thumbnail/thumbnail.module.css +++ b/src/components/post/thumbnail/thumbnail.module.css @@ -3,8 +3,9 @@ float: left; padding-right: 5px; padding-bottom: 2px; - width: var(--width, 70px); /* Fallback to 70px if variable not set */ - height: var(--height, 70px); /* Fallback to 70px if variable not set */ + width: var(--width, 70px); + height: var(--height, 70px); + z-index: 1; } .thumbnailHidden { diff --git a/src/components/reply/reply.module.css b/src/components/reply/reply.module.css index 3ef08ebf..23cd41fe 100644 --- a/src/components/reply/reply.module.css +++ b/src/components/reply/reply.module.css @@ -135,19 +135,20 @@ } .hideSpoiler { - width: 100%; - height: 100%; - position: absolute; background-color: black; color: black; cursor: pointer; + width: 400px; + z-index: 999; + height: 50px; } .showSpoilerButton { color: white; + background-color: black; text-transform: lowercase; position: absolute; - cursor: pointer; + font-size: 12px; top: 50%; left: 50%; transform: translate(-50%, -50%); diff --git a/src/components/reply/reply.tsx b/src/components/reply/reply.tsx index 3ba27802..00dff4c3 100644 --- a/src/components/reply/reply.tsx +++ b/src/components/reply/reply.tsx @@ -382,7 +382,9 @@ const Reply = ({ cidOfReplyWithContext, depth = 0, isSingleComment, isSingleRepl )} {!collapsed && (
{ spoiler && !showSpoiler && setShowSpoiler(true); }} From 400b4f2f43a506e4da90b7506c7c4aad2bacbafa Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 8 Mar 2024 16:23:34 +0100 Subject: [PATCH 04/12] fix(post): clicking near the 'comments' button would add the dotted border --- src/components/post/comment-tools/comment-tools.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/post/comment-tools/comment-tools.tsx b/src/components/post/comment-tools/comment-tools.tsx index 88486700..9c1eab4e 100644 --- a/src/components/post/comment-tools/comment-tools.tsx +++ b/src/components/post/comment-tools/comment-tools.tsx @@ -79,13 +79,17 @@ const PostTools = ({ } }; - const commentCountButton = failed ? {commentCount} : {commentCount}; + const commentCountButton = failed ? ( + {commentCount} + ) : ( + cid && handlePostClick?.()}> + {commentCount} + + ); return ( <> -
  • cid && handlePostClick?.()}> - {commentCountButton} -
  • +
  • {commentCountButton}
  • {/* TODO: Implement save functionality
  • From ed02146103bf3f5ec44e84338cd2cdd7e272ae1f Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 8 Mar 2024 19:07:43 +0100 Subject: [PATCH 05/12] fix(markdown): replies had incorrect white-space and double returns needed margin on posts --- src/components/markdown/markdown.module.css | 4 ++++ src/components/reply/reply.module.css | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/markdown/markdown.module.css b/src/components/markdown/markdown.module.css index 019e1e20..244e5c13 100644 --- a/src/components/markdown/markdown.module.css +++ b/src/components/markdown/markdown.module.css @@ -27,3 +27,7 @@ .markdown h2 { font-size: larger; } + +.markdown p { + margin-bottom: 5px; +} \ No newline at end of file diff --git a/src/components/reply/reply.module.css b/src/components/reply/reply.module.css index 23cd41fe..3b73db10 100644 --- a/src/components/reply/reply.module.css +++ b/src/components/reply/reply.module.css @@ -126,7 +126,6 @@ font-weight: 400; color: var(--text); max-width: 60em; - white-space: pre-wrap; word-wrap: break-word; } From 7fb2f79cefbb0f5d11c6bba1608ae3ce4b573538 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 8 Mar 2024 19:34:39 +0100 Subject: [PATCH 06/12] style(markdown): add line height to posts and replies only --- src/components/post/expando/expando.module.css | 1 + src/components/reply/reply.module.css | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/post/expando/expando.module.css b/src/components/post/expando/expando.module.css index c05e6d03..2624e519 100644 --- a/src/components/post/expando/expando.module.css +++ b/src/components/post/expando/expando.module.css @@ -25,6 +25,7 @@ max-width: 60em; word-wrap: break-word; font-size: 14px; + line-height: 20px; } .mediaPreview { diff --git a/src/components/reply/reply.module.css b/src/components/reply/reply.module.css index 3b73db10..f1138006 100644 --- a/src/components/reply/reply.module.css +++ b/src/components/reply/reply.module.css @@ -122,11 +122,12 @@ .md { margin-top: 5px; margin-bottom: 5px; - font-size: 1.0769230769230769em; + font-size: 14px; font-weight: 400; color: var(--text); max-width: 60em; word-wrap: break-word; + line-height: 20px; } .md a { From b9d050c87c45b2e1c541a4ac45e7f23b6e5490f7 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Mar 2024 12:06:40 +0100 Subject: [PATCH 07/12] feat(context): allow any number as post context, always showing the top level reply --- src/lib/utils/view-utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/view-utils.ts b/src/lib/utils/view-utils.ts index c850b4d1..633699e0 100644 --- a/src/lib/utils/view-utils.ts +++ b/src/lib/utils/view-utils.ts @@ -89,7 +89,12 @@ export const isPostView = (pathname: string, params: ParamsType): boolean => { }; export const isPostContextView = (pathname: string, params: ParamsType, search: string): boolean => { - return params.subplebbitAddress && params.commentCid ? `${pathname}${search}` === `/p/${params.subplebbitAddress}/c/${params.commentCid}?context=1` : false; + if (!params.subplebbitAddress || !params.commentCid) return false; + const expectedPathname = `/p/${params.subplebbitAddress}/c/${params.commentCid}`; + if (pathname !== expectedPathname) return false; + const searchParams = new URLSearchParams(search); + const context = searchParams.get('context'); + return context !== null && !isNaN(Number(context)); }; export const isProfileView = (pathname: string): boolean => { From 22beb4e0ea6a2c300422fa8a21b5f230af985ec0 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Mar 2024 15:44:50 +0100 Subject: [PATCH 08/12] feat(mod menu): community moderators can ban their users --- public/translations/ar/default.json | 3 +- public/translations/bn/default.json | 3 +- public/translations/cs/default.json | 3 +- public/translations/da/default.json | 3 +- public/translations/de/default.json | 3 +- public/translations/el/default.json | 3 +- public/translations/en/default.json | 3 +- public/translations/es/default.json | 3 +- public/translations/fa/default.json | 3 +- public/translations/fi/default.json | 3 +- public/translations/fil/default.json | 3 +- public/translations/fr/default.json | 3 +- public/translations/he/default.json | 3 +- public/translations/hi/default.json | 3 +- public/translations/hu/default.json | 3 +- public/translations/id/default.json | 3 +- public/translations/it/default.json | 3 +- public/translations/ja/default.json | 3 +- public/translations/ko/default.json | 3 +- public/translations/mr/default.json | 3 +- public/translations/nl/default.json | 3 +- public/translations/no/default.json | 3 +- public/translations/pl/default.json | 3 +- public/translations/pt/default.json | 3 +- public/translations/ro/default.json | 3 +- public/translations/ru/default.json | 3 +- public/translations/sq/default.json | 3 +- public/translations/sv/default.json | 3 +- public/translations/te/default.json | 3 +- public/translations/th/default.json | 3 +- public/translations/tr/default.json | 3 +- public/translations/uk/default.json | 3 +- public/translations/ur/default.json | 3 +- public/translations/vi/default.json | 3 +- public/translations/zh/default.json | 3 +- .../post/comment-tools/comment-tools.tsx | 49 ++++++++++++------- .../comment-tools/hide-menu/hide-menu.tsx | 6 +-- .../mod-menu/mod-menu.module.css | 2 +- .../post/comment-tools/mod-menu/mod-menu.tsx | 47 ++++++++++++++++-- 39 files changed, 148 insertions(+), 61 deletions(-) diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index c0b7084d..77bfa2ec 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -287,5 +287,6 @@ "missing_token_address": "عنوان الرمز المفقود", "missing_token_id": "معرف الرمز المفقود", "missing_signature": "التوقيع المفقود", - "edited_timestamp": "تم التحرير {{timestamp}}" + "edited_timestamp": "تم التحرير {{timestamp}}", + "ban_user_for": "حظر المستخدم لمدة <1> يوم(أيام)" } \ No newline at end of file diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index c8959008..7f653bbf 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -287,5 +287,6 @@ "missing_token_address": "নিখোঁজ টোকেন ঠিকানা", "missing_token_id": "নিখোঁজ টোকেন আইডি", "missing_signature": "নিখোঁজ স্বাক্ষর", - "edited_timestamp": "সম্পাদনা করা হয়েছে {{timestamp}}" + "edited_timestamp": "সম্পাদনা করা হয়েছে {{timestamp}}", + "ban_user_for": "ব্যবহারকারীকে <1> দিনের জন্য বন্ধ করুন" } \ No newline at end of file diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index d19c8e03..6f95e2f5 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Chybějící tokenová adresa", "missing_token_id": "Chybějící ID tokenu", "missing_signature": "Chybějící podpis", - "edited_timestamp": "Upraveno {{timestamp}}" + "edited_timestamp": "Upraveno {{timestamp}}", + "ban_user_for": "Zakázat uživatele na <1> den (dní)" } \ No newline at end of file diff --git a/public/translations/da/default.json b/public/translations/da/default.json index d01f6b20..bced100c 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Manglende tokensadresse", "missing_token_id": "Manglende token-id", "missing_signature": "Manglende signatur", - "edited_timestamp": "Redigeret {{timestamp}}" + "edited_timestamp": "Redigeret {{timestamp}}", + "ban_user_for": "Udeluk brugeren i <1> dag(e)" } \ No newline at end of file diff --git a/public/translations/de/default.json b/public/translations/de/default.json index b2c20df8..b2ec389f 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Fehlende Tokenadresse", "missing_token_id": "Fehlende Token-ID", "missing_signature": "Fehlende Signatur", - "edited_timestamp": "Bearbeitet {{timestamp}}" + "edited_timestamp": "Bearbeitet {{timestamp}}", + "ban_user_for": "Benutzer für <1> Tag(e) sperren" } \ No newline at end of file diff --git a/public/translations/el/default.json b/public/translations/el/default.json index 54fb4e48..c25591ab 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Ελλειπτική διεύθυνση του token", "missing_token_id": "Ελλειπτικό αναγνωριστικό token", "missing_signature": "Ελλειπτική υπογραφή", - "edited_timestamp": "Επεξεργάστηκε {{timestamp}}" + "edited_timestamp": "Επεξεργάστηκε {{timestamp}}", + "ban_user_for": "Αποκλεισμός χρήστη για <1> ημέρα(ες)" } \ No newline at end of file diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 634136dd..617aa635 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Missing token address", "missing_token_id": "Missing token ID", "missing_signature": "Missing signature", - "edited_timestamp": "Edited {{timestamp}}" + "edited_timestamp": "Edited {{timestamp}}", + "ban_user_for": "Ban user for <1> day(s)" } \ No newline at end of file diff --git a/public/translations/es/default.json b/public/translations/es/default.json index b4755036..023f7ac4 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Falta de dirección de token", "missing_token_id": "Falta de ID de token", "missing_signature": "Falta de firma", - "edited_timestamp": "Editado {{timestamp}}" + "edited_timestamp": "Editado {{timestamp}}", + "ban_user_for": "Prohibir al usuario durante <1> día(s)" } \ No newline at end of file diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index 5d1d6fba..3e163c46 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -287,5 +287,6 @@ "missing_token_address": "آدرس توکن گم شده", "missing_token_id": "شناسه توکن گم شده", "missing_signature": "امضای گم شده", - "edited_timestamp": "ویرایش شده {{timestamp}}" + "edited_timestamp": "ویرایش شده {{timestamp}}", + "ban_user_for": "بستن کاربر برای <1> روز" } \ No newline at end of file diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index c0af8b92..b18bade7 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Puuttuva token-osoite", "missing_token_id": "Puuttuva token-id", "missing_signature": "Puuttuva allekirjoitus", - "edited_timestamp": "Muokattu {{timestamp}}" + "edited_timestamp": "Muokattu {{timestamp}}", + "ban_user_for": "Estä käyttäjä <1> päiväksi" } \ No newline at end of file diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index c6e1d826..93934d7e 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Kulang na address ng token", "missing_token_id": "Kulang na ID ng token", "missing_signature": "Kulang na lagda", - "edited_timestamp": "Na-edit na ang {{timestamp}}" + "edited_timestamp": "Na-edit na ang {{timestamp}}", + "ban_user_for": "I-ban ang user para sa <1> araw" } \ No newline at end of file diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index ed16c715..0e028afa 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Adresse de token manquante", "missing_token_id": "ID de token manquant", "missing_signature": "Signature manquante", - "edited_timestamp": "Édité {{timestamp}}" + "edited_timestamp": "Édité {{timestamp}}", + "ban_user_for": "Bannir l'utilisateur pendant <1> jour(s)" } \ No newline at end of file diff --git a/public/translations/he/default.json b/public/translations/he/default.json index af942e88..10890b70 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -287,5 +287,6 @@ "missing_token_address": "כתובת הטוקן חסרה", "missing_token_id": "מזהה הטוקן חסר", "missing_signature": "חתימה חסרה", - "edited_timestamp": "נערך {{timestamp}}" + "edited_timestamp": "נערך {{timestamp}}", + "ban_user_for": "אסור למשתמש למשך <1> יום" } \ No newline at end of file diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index 6ed30be5..82662964 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "गायब टोकन पता", "missing_token_id": "गायब टोकन आईडी", "missing_signature": "गायब हस्ताक्षर", - "edited_timestamp": "संपादित {{timestamp}}" + "edited_timestamp": "संपादित {{timestamp}}", + "ban_user_for": "उपयोगकर्ता को <1> दिनों के लिए प्रतिबंधित करें" } \ No newline at end of file diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index fa295e3d..f1a07ff7 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Hiányzó token cím", "missing_token_id": "Hiányzó token azonosító", "missing_signature": "Hiányzó aláírás", - "edited_timestamp": "Szerkesztve {{timestamp}}" + "edited_timestamp": "Szerkesztve {{timestamp}}", + "ban_user_for": "Felhasználó letiltása <1> napra" } \ No newline at end of file diff --git a/public/translations/id/default.json b/public/translations/id/default.json index a83e1692..ffb08ac5 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Alamat token yang hilang", "missing_token_id": "ID token yang hilang", "missing_signature": "Tanda tangan yang hilang", - "edited_timestamp": "Diedit {{timestamp}}" + "edited_timestamp": "Diedit {{timestamp}}", + "ban_user_for": "Blokir pengguna selama <1> hari" } \ No newline at end of file diff --git a/public/translations/it/default.json b/public/translations/it/default.json index e8d3146d..773e421b 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Indirizzo del token mancante", "missing_token_id": "ID del token mancante", "missing_signature": "Firma mancante", - "edited_timestamp": "Modificato {{timestamp}}" + "edited_timestamp": "Modificato {{timestamp}}", + "ban_user_for": "Banna l'utente per <1> giorno/i" } \ No newline at end of file diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 17356953..4ad8c532 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -287,5 +287,6 @@ "missing_token_address": "不足しているトークンアドレス", "missing_token_id": "不足しているトークンID", "missing_signature": "不足している署名", - "edited_timestamp": "編集済み {{timestamp}}" + "edited_timestamp": "編集済み {{timestamp}}", + "ban_user_for": "ユーザーを<1>日間禁止する" } \ No newline at end of file diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index bf78366b..25ae4bbd 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -287,5 +287,6 @@ "missing_token_address": "부재중인 토큰 주소", "missing_token_id": "부재중인 토큰 ID", "missing_signature": "부재중인 서명", - "edited_timestamp": "편집됨 {{timestamp}}" + "edited_timestamp": "편집됨 {{timestamp}}", + "ban_user_for": "사용자를 <1>일 동안 차단하기" } \ No newline at end of file diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index f4873e78..31f45b7a 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "गुमलेला टोकन पत्ता", "missing_token_id": "गुमलेला टोकन आयडी", "missing_signature": "गुमलेली स्वाक्षरे", - "edited_timestamp": "{{timestamp}} संपादित" + "edited_timestamp": "{{timestamp}} संपादित", + "ban_user_for": "वापरकर्ता ब्लॉक करा <1> दिवस" } \ No newline at end of file diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index 4509ff7c..13401ca9 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Ontbrekend tokenadres", "missing_token_id": "Ontbrekend token-ID", "missing_signature": "Ontbrekende handtekening", - "edited_timestamp": "Bewerkt {{timestamp}}" + "edited_timestamp": "Bewerkt {{timestamp}}", + "ban_user_for": "Gebruiker verbannen voor <1> dag(en)" } \ No newline at end of file diff --git a/public/translations/no/default.json b/public/translations/no/default.json index de91716d..262fa4a5 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Manglende tokenadresse", "missing_token_id": "Manglende token-ID", "missing_signature": "Manglende signatur", - "edited_timestamp": "Redigert {{timestamp}}" + "edited_timestamp": "Redigert {{timestamp}}", + "ban_user_for": "Blokker bruker i <1> dag(er)" } \ No newline at end of file diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 29479df6..f370195b 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Brakujący adres tokena", "missing_token_id": "Brakujące ID tokenu", "missing_signature": "Brakujący podpis", - "edited_timestamp": "Edytowane {{timestamp}}" + "edited_timestamp": "Edytowane {{timestamp}}", + "ban_user_for": "Zablokuj użytkownika na <1> dzień (dni)" } \ No newline at end of file diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 431a66d9..b877a9fc 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Endereço do token em falta", "missing_token_id": "ID de token em falta", "missing_signature": "Assinatura em falta", - "edited_timestamp": "Editado {{timestamp}}" + "edited_timestamp": "Editado {{timestamp}}", + "ban_user_for": "Banir usuário por <1> dia(s)" } \ No newline at end of file diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index 871572cd..1ba194c3 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Lipsește adresa tokenului", "missing_token_id": "Lipsește ID-ul tokenului", "missing_signature": "Lipsește semnătura", - "edited_timestamp": "Editat {{timestamp}}" + "edited_timestamp": "Editat {{timestamp}}", + "ban_user_for": "Interzice utilizatorul pentru <1> zi(zile)" } \ No newline at end of file diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index b01c1b69..488f7ee7 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Отсутствующий адрес токена", "missing_token_id": "Отсутствующий идентификатор токена", "missing_signature": "Отсутствующая подпись", - "edited_timestamp": "Отредактировано {{timestamp}}" + "edited_timestamp": "Отредактировано {{timestamp}}", + "ban_user_for": "Заблокировать пользователя на <1> день(дней)" } \ No newline at end of file diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index d736ee7b..1bd609c5 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Adresa e munguar e tokenit", "missing_token_id": "ID e munguar e tokenit", "missing_signature": "Nënshkrimi i munguar", - "edited_timestamp": "Redaktuar {{timestamp}}" + "edited_timestamp": "Redaktuar {{timestamp}}", + "ban_user_for": "Ndalo përdoruesin për <1> ditë" } \ No newline at end of file diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index c25cf8a2..f3bec0e9 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Saknad tokenadress", "missing_token_id": "Saknad token-ID", "missing_signature": "Saknad signatur", - "edited_timestamp": "Redigerat {{timestamp}}" + "edited_timestamp": "Redigerat {{timestamp}}", + "ban_user_for": "Blockera användaren i <1> dag(ar)" } \ No newline at end of file diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 789972ef..86b33e1a 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -287,5 +287,6 @@ "missing_token_address": "తప్పని టోకెన్ చిరునామా", "missing_token_id": "తప్పని టోకెన్ ఐడి", "missing_signature": "తప్పని సంతకం", - "edited_timestamp": "{{timestamp}} ముందు సవరించబడింది" + "edited_timestamp": "{{timestamp}} ముందు సవరించబడింది", + "ban_user_for": "<1> రోజుల కోసం వాడుకరినీ బ్యాన్ చేయండి" } \ No newline at end of file diff --git a/public/translations/th/default.json b/public/translations/th/default.json index 26fb3790..3f4dfe5d 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -287,5 +287,6 @@ "missing_token_address": "เหตุที่หายไปของที่อยู่โทเค็น", "missing_token_id": "เหตุที่หายไปของรหัสของโทเค็น", "missing_signature": "เหตุที่หายไปของลายเซ็น", - "edited_timestamp": "แก้ไขเมื่อ {{timestamp}}" + "edited_timestamp": "แก้ไขเมื่อ {{timestamp}}", + "ban_user_for": "แบนผู้ใช้ <1> วัน" } \ No newline at end of file diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index b0e13344..8d72b8f8 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Eksik token adresi", "missing_token_id": "Eksik token kimliği", "missing_signature": "Eksik imza", - "edited_timestamp": "{{timestamp}} önce düzenlendi" + "edited_timestamp": "{{timestamp}} önce düzenlendi", + "ban_user_for": "Kullanıcıyı <1> gün boyunca yasakla" } \ No newline at end of file diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index 735c1a30..13abede6 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Відсутня адреса токена", "missing_token_id": "Відсутній ідентифікатор токена", "missing_signature": "Відсутній підпис", - "edited_timestamp": "Відредаговано {{timestamp}}" + "edited_timestamp": "Відредаговано {{timestamp}}", + "ban_user_for": "Заборонити користувача на <1> день (днів)" } \ No newline at end of file diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index 7eb017ad..5fee55c7 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -287,5 +287,6 @@ "missing_token_address": "گمشدہ ٹوکن ایڈریس", "missing_token_id": "گمشدہ ٹوکن شناختی نمبر", "missing_signature": "گمشدہ دستخط", - "edited_timestamp": "{{timestamp}} پہلے ترمیم شدہ" + "edited_timestamp": "{{timestamp}} پہلے ترمیم شدہ", + "ban_user_for": "<1> دنوں کے لیے صارف کو پابندی عائد کریں" } \ No newline at end of file diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index 7d04ae1b..f5041668 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -287,5 +287,6 @@ "missing_token_address": "Địa chỉ token bị thiếu", "missing_token_id": "Thiếu ID của token", "missing_signature": "Thiếu chữ ký", - "edited_timestamp": "Đã chỉnh sửa {{timestamp}}" + "edited_timestamp": "Đã chỉnh sửa {{timestamp}}", + "ban_user_for": "Cấm người dùng trong <1> ngày" } \ No newline at end of file diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index 3d7047a0..ff4133d3 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -287,5 +287,6 @@ "missing_token_address": "缺失的代币地址", "missing_token_id": "缺失的代币ID", "missing_signature": "缺失的签名", - "edited_timestamp": "编辑于{{timestamp}}" + "edited_timestamp": "编辑于{{timestamp}}", + "ban_user_for": "封禁用户 <1> 天" } \ No newline at end of file diff --git a/src/components/post/comment-tools/comment-tools.tsx b/src/components/post/comment-tools/comment-tools.tsx index 9c1eab4e..a6ff279f 100644 --- a/src/components/post/comment-tools/comment-tools.tsx +++ b/src/components/post/comment-tools/comment-tools.tsx @@ -18,7 +18,8 @@ interface CommentToolsProps { hasLabel?: boolean; index?: number; isAuthor?: boolean; - isMod?: boolean; + isAccountMod?: boolean; + isCommentAuthorMod?: boolean; isReply?: boolean; isSingleReply?: boolean; parentCid?: string; @@ -34,14 +35,15 @@ interface CommentToolsProps { interface ModOrReportButtonProps { cid: string; isAuthor: boolean | undefined; - isMod: boolean | undefined; + isAccountMod: boolean | undefined; + isCommentAuthorMod?: boolean; } -const ModOrReportButton = ({ cid, isAuthor, isMod }: ModOrReportButtonProps) => { +const ModOrReportButton = ({ cid, isAuthor, isAccountMod, isCommentAuthorMod }: ModOrReportButtonProps) => { const { t } = useTranslation(); - return isMod ? ( - + return isAccountMod ? ( + ) : ( !isAuthor && (
  • @@ -58,7 +60,8 @@ const PostTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, subplebbitAddress, replyCount = 0, showCommentEditForm, @@ -97,13 +100,13 @@ const PostTools = ({
  • */} {isAuthor && } - + {/* TODO: Implement crosspost functionality
  • {t('crosspost')}
  • */} - + ); }; @@ -115,7 +118,8 @@ const ReplyTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, showReplyForm, subplebbitAddress, showCommentEditForm, @@ -135,11 +139,11 @@ const ReplyTools = ({ */} {isAuthor && } - +
  • cid && showReplyForm?.()}>{t('reply_reply')}
  • - + ); }; @@ -150,7 +154,8 @@ const SingleReplyTools = ({ hasLabel, index, isAuthor, - isMod, + isAccountMod, + isCommentAuthorMod, parentCid, postCid, showReplyForm, @@ -192,11 +197,11 @@ const SingleReplyTools = ({ {isAuthor && }
  • {contextButton}
  • {fullCommentsButton}
  • - +
  • cid && showReplyForm?.()}>{t('reply_reply')}
  • - + ); }; @@ -241,8 +246,11 @@ const CommentTools = ({ }: CommentToolsProps) => { const account = useAccount(); const isAuthor = account?.author?.address === author?.address; - const authorRole = useSubplebbit({ subplebbitAddress })?.roles?.[account?.author?.address]?.role; - const isMod = authorRole === 'admin' || authorRole === 'owner' || authorRole === 'moderator'; + const subplebbit = useSubplebbit({ subplebbitAddress }); + const accountAuthorRole = subplebbit?.roles?.[account?.author?.address]?.role; + const commentAuthorRole = subplebbit?.roles?.[author?.address]?.role; + const isAccountMod = accountAuthorRole === 'admin' || accountAuthorRole === 'owner' || accountAuthorRole === 'moderator'; + const isCommentAuthorMod = commentAuthorRole === 'admin' || commentAuthorRole === 'owner' || commentAuthorRole === 'moderator'; const isInInboxView = isInboxView(useLocation().pathname); return ( @@ -256,7 +264,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} parentCid={parentCid} postCid={postCid} showCommentEditForm={showCommentEditForm} @@ -272,7 +281,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} showCommentEditForm={showCommentEditForm} showReplyForm={showReplyForm} spoiler={spoiler} @@ -298,7 +308,8 @@ const CommentTools = ({ hasLabel={hasLabel} index={index} isAuthor={isAuthor} - isMod={isMod} + isAccountMod={isAccountMod} + isCommentAuthorMod={isCommentAuthorMod} replyCount={replyCount} showCommentEditForm={showCommentEditForm} spoiler={spoiler} diff --git a/src/components/post/comment-tools/hide-menu/hide-menu.tsx b/src/components/post/comment-tools/hide-menu/hide-menu.tsx index 18bf3932..c4ee7ac9 100644 --- a/src/components/post/comment-tools/hide-menu/hide-menu.tsx +++ b/src/components/post/comment-tools/hide-menu/hide-menu.tsx @@ -8,7 +8,7 @@ import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; type HideMenuProps = { author?: Author | undefined; cid?: string; - isMod?: boolean; + isAccountMod?: boolean; toggleIsMenuOpen?: () => void; subplebbitAddress?: string; }; @@ -52,7 +52,7 @@ const BlockCommentButton = ({ cid }: HideMenuProps) => { ); }; -const HideMenu = ({ author, cid, isMod, subplebbitAddress }: HideMenuProps) => { +const HideMenu = ({ author, cid, isAccountMod, subplebbitAddress }: HideMenuProps) => { const { t } = useTranslation(); const [isHideMenuOpen, setIsHideMenuOpen] = useState(false); const toggleIsMenuOpen = () => setIsHideMenuOpen(!isHideMenuOpen); @@ -85,7 +85,7 @@ const HideMenu = ({ author, cid, isMod, subplebbitAddress }: HideMenuProps) => { - {!isMod &&
    {t('report')}
    } + {!isAccountMod &&
    {t('report')}
    }
    diff --git a/src/components/post/comment-tools/mod-menu/mod-menu.module.css b/src/components/post/comment-tools/mod-menu/mod-menu.module.css index f0497fef..e92bfe47 100644 --- a/src/components/post/comment-tools/mod-menu/mod-menu.module.css +++ b/src/components/post/comment-tools/mod-menu/mod-menu.module.css @@ -14,7 +14,7 @@ color: var(--text); font-size: 12px; border: 1px solid var(--border-text); - width: 200px; + min-width: 200px; } .modal input[type="checkbox"] { diff --git a/src/components/post/comment-tools/mod-menu/mod-menu.tsx b/src/components/post/comment-tools/mod-menu/mod-menu.tsx index 1d576a91..ef6ae24c 100644 --- a/src/components/post/comment-tools/mod-menu/mod-menu.tsx +++ b/src/components/post/comment-tools/mod-menu/mod-menu.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { autoUpdate, flip, FloatingFocusManager, offset, shift, useClick, useDismiss, useFloating, useId, useInteractions, useRole } from '@floating-ui/react'; -import { useTranslation } from 'react-i18next'; +import { Trans, useTranslation } from 'react-i18next'; import { PublishCommentEditOptions, useComment, useEditedComment, usePublishCommentEdit } from '@plebbit/plebbit-react-hooks'; import styles from './mod-menu.module.css'; import { alertChallengeVerificationFailed } from '../../../../lib/utils/challenge-utils'; @@ -10,9 +10,10 @@ const { addChallenge } = challengesStore.getState(); type ModMenuProps = { cid: string; + isCommentAuthorMod?: boolean; }; -const ModMenu = ({ cid }: ModMenuProps) => { +const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { const { t } = useTranslation(); let post: any; @@ -31,6 +32,7 @@ const ModMenu = ({ cid }: ModMenuProps) => { locked: post?.locked, spoiler: post?.spoiler, pinned: post?.pinned, + banExpiresAt: post?.banExpiresAt, commentCid: post?.cid, subplebbitAddress: post?.subplebbitAddress, onChallenge: (...args: any) => addChallenge([...args, post]), @@ -44,7 +46,34 @@ const ModMenu = ({ cid }: ModMenuProps) => { const [publishCommentEditOptions, setPublishCommentEditOptions] = useState(defaultPublishOptions); const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); - const onCheckbox = (e: React.ChangeEvent) => setPublishCommentEditOptions((state) => ({ ...state, [e.target.id]: e.target.checked })); + const [banDuration, setBanDuration] = useState(1); + + const daysToTimestampInSeconds = (days: number) => { + const now = new Date(); + now.setDate(now.getDate() + days); + return Math.floor(now.getTime() / 1000); + }; + + const onCheckbox = (e: React.ChangeEvent) => { + const { id, checked } = e.target; + if (id === 'banUser') { + setPublishCommentEditOptions((state) => ({ + ...state, + banExpiresAt: checked ? daysToTimestampInSeconds(banDuration) : undefined, + })); + } else { + setPublishCommentEditOptions((state) => ({ ...state, [id]: checked })); + } + }; + + const onBanDurationChange = (e: React.ChangeEvent) => { + const days = parseInt(e.target.value, 10) || 1; + setBanDuration(days); + setPublishCommentEditOptions((state) => ({ + ...state, + banExpiresAt: daysToTimestampInSeconds(days), + })); + }; const onReason = (e: React.ChangeEvent) => setPublishCommentEditOptions((state) => ({ ...state, reason: e.target.value ? e.target.value : undefined })); @@ -105,6 +134,18 @@ const ModMenu = ({ cid }: ModMenuProps) => { {isReply ? t('stickied_comment') : t('announcement')} + {!isCommentAuthorMod && ( +
    + +
    + )}
    {t('reason')} ({t('optional')}) From de1d09116c094b29be3e51f1c17afaffe262fbcf Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Mar 2024 15:54:56 +0100 Subject: [PATCH 09/12] Update mod-menu.tsx --- src/components/post/comment-tools/mod-menu/mod-menu.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/post/comment-tools/mod-menu/mod-menu.tsx b/src/components/post/comment-tools/mod-menu/mod-menu.tsx index ef6ae24c..8b09e472 100644 --- a/src/components/post/comment-tools/mod-menu/mod-menu.tsx +++ b/src/components/post/comment-tools/mod-menu/mod-menu.tsx @@ -32,7 +32,7 @@ const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { locked: post?.locked, spoiler: post?.spoiler, pinned: post?.pinned, - banExpiresAt: post?.banExpiresAt, + commentAuthor: { banExpiresAt: post?.banExpiresAt }, commentCid: post?.cid, subplebbitAddress: post?.subplebbitAddress, onChallenge: (...args: any) => addChallenge([...args, post]), @@ -59,7 +59,7 @@ const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { if (id === 'banUser') { setPublishCommentEditOptions((state) => ({ ...state, - banExpiresAt: checked ? daysToTimestampInSeconds(banDuration) : undefined, + commentAuthor: { ...state.commentAuthor, banExpiresAt: checked ? daysToTimestampInSeconds(banDuration) : undefined }, })); } else { setPublishCommentEditOptions((state) => ({ ...state, [id]: checked })); @@ -71,7 +71,7 @@ const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { setBanDuration(days); setPublishCommentEditOptions((state) => ({ ...state, - banExpiresAt: daysToTimestampInSeconds(days), + commentAuthor: { ...state.commentAuthor, banExpiresAt: daysToTimestampInSeconds(days) }, })); }; @@ -137,7 +137,7 @@ const ModMenu = ({ cid, isCommentAuthorMod }: ModMenuProps) => { {!isCommentAuthorMod && (
    - {t('token_address_whitelist')} + + + ), + }} + /> + Date: Sat, 9 Mar 2024 20:02:22 +0100 Subject: [PATCH 11/12] fix warning --- src/views/settings/avatar-settings/avatar-settings.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/views/settings/avatar-settings/avatar-settings.tsx b/src/views/settings/avatar-settings/avatar-settings.tsx index a0162828..3eeb36b8 100644 --- a/src/views/settings/avatar-settings/avatar-settings.tsx +++ b/src/views/settings/avatar-settings/avatar-settings.tsx @@ -1,4 +1,5 @@ import { useEffect, useMemo, useState } from 'react'; +import { Link } from 'react-router-dom'; import { setAccount, useAccount, useAuthorAvatar } from '@plebbit/plebbit-react-hooks'; import styles from './avatar-settings.module.css'; import { Trans, useTranslation } from 'react-i18next'; @@ -143,8 +144,8 @@ const AvatarSettings = () => { shouldUnescape={true} components={{ 1: ( - From d15fe5d518741ba66b0f575048eb09edd50b1f1e Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 9 Mar 2024 20:41:33 +0100 Subject: [PATCH 12/12] remove redundant useEffect --- src/views/settings/avatar-settings/avatar-settings.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/views/settings/avatar-settings/avatar-settings.tsx b/src/views/settings/avatar-settings/avatar-settings.tsx index 3eeb36b8..1ca9b6fd 100644 --- a/src/views/settings/avatar-settings/avatar-settings.tsx +++ b/src/views/settings/avatar-settings/avatar-settings.tsx @@ -67,11 +67,6 @@ const AvatarSettings = () => { }; const [hasCopied, setHasCopied] = useState(false); - useEffect(() => { - if (hasCopied) { - setTimeout(() => setHasCopied(false), 2000); - } - }, [hasCopied]); const copyMessageToSign = () => { if (!chainTicker) { @@ -89,6 +84,9 @@ const AvatarSettings = () => { setTimestamp(newTimestamp); navigator.clipboard.writeText(messageToSign); setHasCopied(true); + setTimeout(() => { + setHasCopied(false); + }, 2000); }; // how to resolve and verify NFT signatures https://github.com/plebbit/plebbit-js/blob/master/docs/nft.md