mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 08:11:13 -05:00
Fix profile privacy and simplify code
This commit is contained in:
@@ -24,7 +24,6 @@ import { profileEditSchema } from '@/lib/validation';
|
||||
import { LocationDisplay } from '@/components/profile/LocationDisplay';
|
||||
import { UserBlockButton } from '@/components/profile/UserBlockButton';
|
||||
import { PersonalLocationDisplay } from '@/components/profile/PersonalLocationDisplay';
|
||||
import { useProfileFieldAccess } from '@/hooks/useProfileFieldAccess';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
|
||||
export default function Profile() {
|
||||
@@ -59,9 +58,6 @@ export default function Profile() {
|
||||
});
|
||||
const [recentActivity, setRecentActivity] = useState<any[]>([]);
|
||||
const [activityLoading, setActivityLoading] = useState(false);
|
||||
|
||||
// Profile field access checking
|
||||
const { canViewField, loading: fieldAccessLoading } = useProfileFieldAccess(profile?.user_id);
|
||||
|
||||
// User role checking
|
||||
const { isModerator, loading: rolesLoading } = useUserRole();
|
||||
@@ -489,9 +485,9 @@ export default function Profile() {
|
||||
variant="avatar"
|
||||
maxFiles={1}
|
||||
maxSizeMB={1}
|
||||
existingPhotos={canViewField('avatar_url') && profile.avatar_url ? [profile.avatar_url] : []}
|
||||
existingPhotos={profile.avatar_url ? [profile.avatar_url] : []}
|
||||
onUploadComplete={handleAvatarUpload}
|
||||
currentImageId={avatarImageId}
|
||||
currentImageId={avatarImageId}
|
||||
onError={error => {
|
||||
toast({
|
||||
title: "Upload Error",
|
||||
@@ -577,7 +573,7 @@ export default function Profile() {
|
||||
{profile.display_name && <Badge variant="secondary" className="cursor-pointer hover:bg-secondary/80" onClick={() => navigate(`/profile/${profile.username}`)}>@{profile.username}</Badge>}
|
||||
</div>
|
||||
|
||||
{canViewField('bio') && profile.bio && (
|
||||
{profile.bio && (
|
||||
<p className="text-muted-foreground mb-4 max-w-2xl">
|
||||
{profile.bio}
|
||||
</p>
|
||||
@@ -592,31 +588,23 @@ export default function Profile() {
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Show pronouns if enabled and privacy allows */}
|
||||
{profile.show_pronouns && canViewField('preferred_pronouns') && profile.preferred_pronouns && (
|
||||
{/* Show pronouns if enabled and present (privacy already enforced by get_filtered_profile) */}
|
||||
{profile.show_pronouns && profile.preferred_pronouns && (
|
||||
<div className="flex items-center gap-1">
|
||||
<User className="w-4 h-4" />
|
||||
{profile.preferred_pronouns}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Show personal location if available and privacy allows */}
|
||||
{canViewField('personal_location') && profile.personal_location && (
|
||||
<PersonalLocationDisplay
|
||||
personalLocation={profile.personal_location}
|
||||
userId={profile.user_id}
|
||||
isOwnProfile={isOwnProfile}
|
||||
/>
|
||||
)}
|
||||
{/* Show personal location (privacy already enforced by get_filtered_profile) */}
|
||||
<PersonalLocationDisplay
|
||||
personalLocation={profile.personal_location}
|
||||
/>
|
||||
|
||||
{/* Show location only if privacy allows */}
|
||||
{canViewField('location_id') && profile.location && (
|
||||
<LocationDisplay
|
||||
location={profile.location}
|
||||
userId={profile.user_id}
|
||||
isOwnProfile={isOwnProfile}
|
||||
/>
|
||||
)}
|
||||
{/* Show location (privacy already enforced by get_filtered_profile) */}
|
||||
<LocationDisplay
|
||||
location={profile.location}
|
||||
/>
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user