@@ -13,7 +13,7 @@ import { CameraIcon, Loader2 } from "lucide-react";
13
13
import { useEffect , useState } from "react" ;
14
14
import { toast } from "sonner" ;
15
15
16
- const MAX_AVATAR_SIZE = 1024 * 1024 * 1 ; // 1MB
16
+ const MAX_AVATAR_SIZE = 1024 * 1024 * 2 ; // 2MB
17
17
const ALLOWED_TYPES = new Set ( [ "image/png" , "image/jpeg" , "image/webp" ] ) ;
18
18
19
19
export const AccountAvatar = ( ) => {
@@ -23,19 +23,21 @@ export const AccountAvatar = () => {
23
23
24
24
const { mutate : mutateUserProfile , isPending : isMutatingUserProfile } =
25
25
useUploadUserAvatar ( {
26
- onSuccess : async ( ) => {
27
- await queryClient . invalidateQueries ( {
26
+ onSuccess : ( ) => {
27
+ return queryClient . invalidateQueries ( {
28
28
queryKey : [ UsersServerKeys . GET_USER_PROFILE ] ,
29
29
} ) ;
30
- setPreviewUrl ( null ) ;
31
30
} ,
32
31
} ) ;
33
32
33
+ // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
34
34
useEffect ( ( ) => {
35
35
return ( ) => {
36
- revokeBlobUrl ( previewUrl ) ;
36
+ if ( previewUrl ) {
37
+ revokeBlobUrl ( previewUrl ) ;
38
+ }
37
39
} ;
38
- } , [ previewUrl ] ) ;
40
+ } , [ ] ) ;
39
41
40
42
const handleUploadAvatar = ( e : React . ChangeEvent < HTMLInputElement > ) => {
41
43
const file = e . target . files ?. [ 0 ] ;
@@ -57,6 +59,7 @@ export const AccountAvatar = () => {
57
59
return ;
58
60
}
59
61
62
+ revokeBlobUrl ( previewUrl ) ;
60
63
const newPreviewUrl = URL . createObjectURL ( file ) ;
61
64
setPreviewUrl ( newPreviewUrl ) ;
62
65
@@ -65,7 +68,6 @@ export const AccountAvatar = () => {
65
68
{
66
69
onError : ( ) => {
67
70
toast . error ( "Failed to upload avatar. Please try again." ) ;
68
- setPreviewUrl ( null ) ;
69
71
} ,
70
72
} ,
71
73
) ;
@@ -102,7 +104,7 @@ export const AccountAvatar = () => {
102
104
}
103
105
} }
104
106
/>
105
- < AvatarFallback aria-label = "Avatar fallback ">
107
+ < AvatarFallback className = "bg-muted text-muted-foreground font-medium ">
106
108
{ userProfile ?. full_name ?. charAt ( 0 ) ?. toUpperCase ( ) }
107
109
</ AvatarFallback >
108
110
</ Avatar >
0 commit comments