-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Profile Syncing #9994
Fix: Profile Syncing #9994
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||||
import careConfig from "@careConfig"; | ||||||
import { useQueryClient } from "@tanstack/react-query"; | ||||||
import { useState } from "react"; | ||||||
import { useTranslation } from "react-i18next"; | ||||||
import { toast } from "sonner"; | ||||||
|
@@ -30,6 +31,7 @@ export default function UserAvatar({ | |||||
const { t } = useTranslation(); | ||||||
const [editAvatar, setEditAvatar] = useState(false); | ||||||
const authUser = useAuthUser(); | ||||||
const queryClient = useQueryClient(); | ||||||
|
||||||
const { data: userData, loading: isLoading } = useTanStackQueryInstead( | ||||||
routes.getUserDetails, | ||||||
|
@@ -58,6 +60,7 @@ export default function UserAvatar({ | |||||
if (xhr.status === 200) { | ||||||
await sleep(1000); | ||||||
refetchUserData?.(); | ||||||
await queryClient.invalidateQueries({ queryKey: ["currentUser"] }); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too |
||||||
toast.success(t("avatar_updated_success")); | ||||||
setEditAvatar(false); | ||||||
} | ||||||
|
@@ -74,8 +77,9 @@ export default function UserAvatar({ | |||||
pathParams: { username }, | ||||||
}); | ||||||
if (res?.ok) { | ||||||
toast.success(t("profile_picture_deleted")); | ||||||
refetchUserData?.(); | ||||||
await queryClient.invalidateQueries({ queryKey: ["currentUser"] }); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can skip awaiting the query invalidation. toast can be shown right after the mutation has upload/delete has completed without waiting for invalidation to complete.
Suggested change
|
||||||
toast.success(t("profile_picture_deleted")); | ||||||
setEditAvatar(false); | ||||||
} else { | ||||||
onError(); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we are invalidating the query, do we need to call
refetchUserData
?check what the callees are doing with it and see if we can remove this.