UI refresh (#476)

This commit is contained in:
Luke Vella 2023-02-06 12:37:31 +00:00 committed by GitHub
parent e6a13c235d
commit bba880ff4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 1198 additions and 1014 deletions

View file

@ -52,11 +52,15 @@ export const UserProvider = (props: { children?: React.ReactNode }) => {
const { t } = useTranslation("app");
const queryClient = trpcNext.useContext();
const { data: user, isFetching } = trpcNext.whoami.get.useQuery();
const { data: user } = trpcNext.whoami.get.useQuery();
const [isUpdating, setIsUpdating] = React.useState(false);
const logout = trpcNext.whoami.destroy.useMutation({
onSuccess: () => {
queryClient.whoami.invalidate();
onSuccess: async () => {
setIsUpdating(true);
await queryClient.whoami.invalidate();
setIsUpdating(false);
},
});
@ -96,7 +100,7 @@ export const UserProvider = (props: { children?: React.ReactNode }) => {
return (
<UserContext.Provider
value={{
isUpdating: isFetching,
isUpdating,
user: { ...user, shortName },
refresh: () => {
return queryClient.whoami.invalidate();