Add banned user handling in profile and messaging components.

This commit is contained in:
MartinBraquet
2026-04-13 11:03:11 +02:00
parent 430f54f925
commit 5372a30558
5 changed files with 46 additions and 8 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -111,16 +111,24 @@ export const ProfileGrid = (props: {
</div>
)}
{!isLoadingMore && !isReloading && other_profiles.length === 0 && (
{user?.isBannedFromPosting ? (
<div className="py-8 text-center">
<p>{t('profile_grid.no_profiles', 'No profiles found.')}</p>
<p>
{t(
'profile_grid.notification_cta',
"Feel free to click on Get Notified and we'll notify you when new users match your search!",
)}
</p>
<p>You can't see profiles as you got banned.</p>
</div>
) : (
!isLoadingMore &&
!isReloading &&
other_profiles.length === 0 && (
<div className="py-8 text-center">
<p>{t('profile_grid.no_profiles', 'No profiles found.')}</p>
<p>
{t(
'profile_grid.notification_cta',
"Feel free to click on Get Notified and we'll notify you when new users match your search!",
)}
</p>
</div>
)
)}
</div>
)

View File

@@ -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)

View File

@@ -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: {
)}
</span>
</div>
) : allUsersBanned ? (
<div className="border-ink-200 p-4 text-center">
<span className="text-ink-600">
{t('messages.cannot_message_banned', "You can't text them as they got banned.")}
</span>
</div>
) : user.isBannedFromPosting ? (
<div className="border-ink-200 p-4 text-center">
<span className="text-ink-600">
{t('messages.cannot_message_you_banned', "You can't text them as you got banned.")}
</span>
</div>
) : (
<CommentInputTextArea
editor={editor}