Skip to content

Commit

Permalink
removed await && refetchUserData
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrin2005 committed Jan 15, 2025
1 parent 9a47823 commit 9deb319
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/components/Users/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ import useTanStackQueryInstead from "@/Utils/request/useQuery";
import { getAuthorizationHeader } from "@/Utils/request/utils";
import { formatDisplayName, sleep } from "@/Utils/utils";

export default function UserAvatar({
username,
refetchUserData,
}: {
username: string;
refetchUserData?: () => void;
}) {
export default function UserAvatar({ username }: { username: string }) {
const { t } = useTranslation();
const [editAvatar, setEditAvatar] = useState(false);
const authUser = useAuthUser();
Expand Down Expand Up @@ -59,8 +53,7 @@ export default function UserAvatar({
async (xhr: XMLHttpRequest) => {
if (xhr.status === 200) {
await sleep(1000);
refetchUserData?.();
await queryClient.invalidateQueries({ queryKey: ["currentUser"] });
queryClient.invalidateQueries({ queryKey: ["currentUser"] });
toast.success(t("avatar_updated_success"));
setEditAvatar(false);
}
Expand All @@ -77,8 +70,7 @@ export default function UserAvatar({
pathParams: { username },
});
if (res?.ok) {
refetchUserData?.();
await queryClient.invalidateQueries({ queryKey: ["currentUser"] });
queryClient.invalidateQueries({ queryKey: ["currentUser"] });
toast.success(t("profile_picture_deleted"));
setEditAvatar(false);
} else {
Expand Down

0 comments on commit 9deb319

Please sign in to comment.