From 5372a30558ee78cdf18f87dfdfd0e6f7d872f9e8 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 13 Apr 2026 11:03:11 +0200 Subject: [PATCH] Add banned user handling in profile and messaging components. --- common/messages/de.json | 2 ++ common/messages/fr.json | 2 ++ web/components/profile-grid.tsx | 24 +++++++++++++++-------- web/components/profiles/profiles-home.tsx | 11 +++++++++++ web/pages/messages/[channelId].tsx | 15 ++++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/common/messages/de.json b/common/messages/de.json index fe130ffa..f167ddba 100644 --- a/common/messages/de.json +++ b/common/messages/de.json @@ -466,6 +466,8 @@ "messages.action.delete": "Löschen", "messages.action.edit": "Bearbeiten", "messages.cannot_message_deleted": "Sie können ihnen keine Nachricht senden, da sie ihr Konto gelöscht haben.", + "messages.cannot_message_banned": "Sie können ihnen keine Nachricht senden, da sie gesperrt wurden.", + "messages.cannot_message_you_banned": "Sie können ihnen keine Nachricht senden, da Sie gesperrt wurden.", "messages.create": "Erstellen", "messages.delete_confirm": "Sind Sie sicher, dass Sie diese Nachricht löschen möchten?", "messages.delete_failed": "Löschen der Nachricht fehlgeschlagen", diff --git a/common/messages/fr.json b/common/messages/fr.json index c923098d..6bb2dc0e 100644 --- a/common/messages/fr.json +++ b/common/messages/fr.json @@ -466,6 +466,8 @@ "messages.action.delete": "Supprimer", "messages.action.edit": "Modifier", "messages.cannot_message_deleted": "Vous ne pouvez pas leur envoyer de message car ils ont supprimé leur compte.", + "messages.cannot_message_banned": "Vous ne pouvez pas leur envoyer de message car ils ont été bannis.", + "messages.cannot_message_you_banned": "Vous ne pouvez pas leur envoyer de message car vous avez été banni.", "messages.create": "Créer", "messages.delete_confirm": "Êtes-vous sûr de vouloir supprimer ce message ?", "messages.delete_failed": "Échec de la suppression du message", diff --git a/web/components/profile-grid.tsx b/web/components/profile-grid.tsx index b0152c16..36d0dd43 100644 --- a/web/components/profile-grid.tsx +++ b/web/components/profile-grid.tsx @@ -111,16 +111,24 @@ export const ProfileGrid = (props: { )} - {!isLoadingMore && !isReloading && other_profiles.length === 0 && ( + {user?.isBannedFromPosting ? (
-

{t('profile_grid.no_profiles', 'No profiles found.')}

-

- {t( - 'profile_grid.notification_cta', - "Feel free to click on Get Notified and we'll notify you when new users match your search!", - )} -

+

You can't see profiles as you got banned.

+ ) : ( + !isLoadingMore && + !isReloading && + other_profiles.length === 0 && ( +
+

{t('profile_grid.no_profiles', 'No profiles found.')}

+

+ {t( + 'profile_grid.notification_cta', + "Feel free to click on Get Notified and we'll notify you when new users match your search!", + )} +

+
+ ) )} ) diff --git a/web/components/profiles/profiles-home.tsx b/web/components/profiles/profiles-home.tsx index e84b4123..e38a71a4 100644 --- a/web/components/profiles/profiles-home.tsx +++ b/web/components/profiles/profiles-home.tsx @@ -92,6 +92,11 @@ export function ProfilesHome() { const id = useRef(0) useEffect(() => { if (!user) return + if (user.isBannedFromPosting) { + setProfiles([]) + setProfileCount(0) + return + } setIsReloading(true) const current = ++id.current const args = removeNullOrUndefinedProps({ @@ -123,6 +128,12 @@ export function ProfilesHome() { const limit = 20 const loadMore = useCallback(async () => { + if (!user) return false + if (user.isBannedFromPosting) { + setProfiles([]) + setProfileCount(0) + return false + } if (!profiles || isLoadingMore) return false if (fromSignup && isClearedFilters && sendScrollWarning) { setSendScrollWarning(false) diff --git a/web/pages/messages/[channelId].tsx b/web/pages/messages/[channelId].tsx index e8f14b12..063cf7d0 100644 --- a/web/pages/messages/[channelId].tsx +++ b/web/pages/messages/[channelId].tsx @@ -147,6 +147,9 @@ export const PrivateChat = (props: { const members = filterDefined(otherUsers?.filter((user) => memberIds.includes(user.id)) ?? []) const router = useRouter() + // Check ban status for messaging restrictions + const allUsersBanned = members.length > 0 && members.every((member) => member.isBannedFromPosting) + const {topVisibleRef, showMessages, innerDiv, outerDiv} = usePaginatedScrollingMessages( messages, user?.id, @@ -436,6 +439,18 @@ export const PrivateChat = (props: { )} + ) : allUsersBanned ? ( +
+ + {t('messages.cannot_message_banned', "You can't text them as they got banned.")} + +
+ ) : user.isBannedFromPosting ? ( +
+ + {t('messages.cannot_message_you_banned', "You can't text them as you got banned.")} + +
) : (