From fe41d7c26685a701a8d3fa3cf0bc496a05655238 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Fri, 1 Dec 2023 16:39:16 +0000 Subject: [PATCH 1/2] update useLatestVersion in autostart options --- components/dashboard/src/user-settings/SelectIDE.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/dashboard/src/user-settings/SelectIDE.tsx b/components/dashboard/src/user-settings/SelectIDE.tsx index 1cde2714d3338f..1f125819d6087d 100644 --- a/components/dashboard/src/user-settings/SelectIDE.tsx +++ b/components/dashboard/src/user-settings/SelectIDE.tsx @@ -37,9 +37,20 @@ export default function SelectIDE(props: SelectIDEProps) { const additionalData = user?.additionalData || {}; const ideSettings = additionalData.ideSettings || {}; + // update stored autostart options to match useLatestVersion value set here + const workspaceAutostartOptions = additionalData?.workspaceAutostartOptions?.map((option) => { + // TODO: don't mutate existing user directly + if (option.ideSettings) { + option.ideSettings.useLatestVersion = useLatestVersion; + } + + return option; + }); + const updates = { additionalData: { ...additionalData, + workspaceAutostartOptions, ideSettings: { ...ideSettings, settingVersion: "2.0", From 5ec09d5a621bef628ca48a5349e7fbda8f5f3428 Mon Sep 17 00:00:00 2001 From: Brad Harris Date: Fri, 1 Dec 2023 16:54:12 +0000 Subject: [PATCH 2/2] avoid mutating user directly --- components/dashboard/src/user-settings/SelectIDE.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/dashboard/src/user-settings/SelectIDE.tsx b/components/dashboard/src/user-settings/SelectIDE.tsx index 1f125819d6087d..e87ac85890ca7d 100644 --- a/components/dashboard/src/user-settings/SelectIDE.tsx +++ b/components/dashboard/src/user-settings/SelectIDE.tsx @@ -39,9 +39,15 @@ export default function SelectIDE(props: SelectIDEProps) { // update stored autostart options to match useLatestVersion value set here const workspaceAutostartOptions = additionalData?.workspaceAutostartOptions?.map((option) => { - // TODO: don't mutate existing user directly if (option.ideSettings) { - option.ideSettings.useLatestVersion = useLatestVersion; + const newOption = { + ...option, + ideSettings: { + ...option.ideSettings, + useLatestVersion, + }, + }; + return newOption; } return option;