Skip to content

Commit

Permalink
try fix useUpdateCurrentUserMutation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTugarev committed Nov 29, 2023
1 parent 0881a30 commit 4027ce4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"countries-list": "^2.6.1",
"crypto-browserify": "3.12.0",
"dayjs": "^1.11.5",
"deepmerge": "^4.2.2",
"file-saver": "^2.0.5",
"idb-keyval": "^6.2.0",
"js-cookie": "^3.0.1",
Expand Down
11 changes: 6 additions & 5 deletions components/dashboard/src/data/current-user/update-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
* See License.AGPL.txt in the project root for license information.
*/

import { User as UserProtocol } from "@gitpod/gitpod-protocol";
import { AdditionalUserData, User as UserProtocol } from "@gitpod/gitpod-protocol";
import { useMutation } from "@tanstack/react-query";
import { trackEvent } from "../../Analytics";
import { getGitpodService } from "../../service/service";
import { useAuthenticatedUser } from "./authenticated-user-query";
import { converter } from "../../service/public-api";
import deepmerge from "deepmerge";

type UpdateCurrentUserArgs = Partial<UserProtocol>;

Expand All @@ -20,10 +21,10 @@ export const useUpdateCurrentUserMutation = () => {
const update: UpdateCurrentUserArgs = {
id: current.id,
fullName: partialUser.fullName || current.fullName,
additionalData: {
...current.additionalData,
...partialUser.additionalData,
},
additionalData: deepmerge<AdditionalUserData>(
current.additionalData || {},
partialUser.additionalData || {},
),
};
const user = await getGitpodService().server.updateLoggedInUser(update);
return converter.toUser(user);
Expand Down

0 comments on commit 4027ce4

Please sign in to comment.