Skip to content

Commit a03f193

Browse files
authored
Uniq onboard answers before update (#20044)
1 parent aaa9de4 commit a03f193

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/dashboard/src/data/current-user/update-mutation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getGitpodService } from "../../service/service";
1111
import { useCurrentUser } from "../../user-context";
1212
import { converter } from "../../service/public-api";
1313
import deepmerge from "deepmerge";
14+
import uniq from "lodash/uniq";
1415

1516
type UpdateCurrentUserArgs = Partial<UserProtocol>;
1617

@@ -31,6 +32,15 @@ export const useUpdateCurrentUserMutation = () => {
3132
partialUser.additionalData || {},
3233
),
3334
};
35+
// deepmerge will try append array, so once data is defined, ignore previous value
36+
if (partialUser.additionalData?.profile?.explorationReasons) {
37+
update.additionalData!.profile!.explorationReasons = uniq(
38+
partialUser.additionalData.profile.explorationReasons,
39+
);
40+
}
41+
if (partialUser.additionalData?.profile?.signupGoals) {
42+
update.additionalData!.profile!.signupGoals = uniq(partialUser.additionalData.profile.signupGoals);
43+
}
3444
const user = await getGitpodService().server.updateLoggedInUser(update);
3545
return converter.toUser(user);
3646
},

0 commit comments

Comments
 (0)