Apply all API enhancements

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 23:55:18 +00:00
parent 8f4110d890
commit d40f0f13aa
10 changed files with 435 additions and 45 deletions

View File

@@ -34,6 +34,7 @@ import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import { useOpenGraph } from '@/hooks/useOpenGraph';
import { useProfileActivity } from '@/hooks/profile/useProfileActivity';
import { useProfileStats } from '@/hooks/profile/useProfileStats';
import { useQueryInvalidation } from '@/lib/queryInvalidation';
// Activity type definitions
interface SubmissionActivity {
@@ -150,6 +151,9 @@ export default function Profile() {
const [avatarUrl, setAvatarUrl] = useState<string>('');
const [avatarImageId, setAvatarImageId] = useState<string>('');
// Query invalidation for cache updates
const { invalidateProfileActivity, invalidateProfileStats } = useQueryInvalidation();
// User role checking
const { isModerator, loading: rolesLoading } = useUserRole();
@@ -325,6 +329,13 @@ export default function Profile() {
error
} = await supabase.from('profiles').update(updateData).eq('user_id', currentUser.id);
if (error) throw error;
// Invalidate profile caches across the app
if (currentUser.id) {
invalidateProfileActivity(currentUser.id);
invalidateProfileStats(currentUser.id);
}
setProfile(prev => prev ? {
...prev,
...updateData
@@ -374,6 +385,11 @@ export default function Profile() {
}).eq('user_id', currentUser.id);
if (error) throw error;
// Invalidate profile activity cache (avatar shows in activity)
if (currentUser.id) {
invalidateProfileActivity(currentUser.id);
}
// Update local profile state
setProfile(prev => prev ? {
...prev,