Skip to content

Commit 9f1e334

Browse files
authored
Save Skillmap Theme Settings (microsoft#10450)
This change saves the user's preference when setting a theme in skillmaps, and it fixes an error where I was double-parsing the json string and hitting exceptions when it was empty. It's a bit of a shot in the dark, but I'm hoping this will fix microsoft/pxt-arcade#6808 by ensuring any skillmap-specific setting stays in-sync with the main editor setting. Hard to say for sure if that's what was happening though, since we don't have a concrete repro.
1 parent 425a6e3 commit 9f1e334

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

skillmap/src/components/makecodeFrame.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ class MakeCodeFrameImpl extends React.Component<MakeCodeFrameProps, MakeCodeFram
175175
{
176176
type: "pxteditor",
177177
action: "setcolorthemebyid",
178-
colorThemeId
178+
colorThemeId,
179+
savePreference: true
179180
} as pxt.editor.EditorMessageSetColorThemeRequest
180181
);
181182
}

webapp/src/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export async function setThemePrefAsync(themeId: string): Promise<void> {
256256
} else {
257257
// Identity not available, save this setting locally
258258
const currentPrefsStr = pxt.storage.getLocal(COLOR_THEME_IDS);
259-
const currentPrefs = pxt.U.jsonTryParse(JSON.parse(currentPrefsStr)) as pxt.auth.ColorThemeIdsState ?? {};
259+
const currentPrefs = pxt.U.jsonTryParse(currentPrefsStr) as pxt.auth.ColorThemeIdsState ?? {};
260260
const newColorThemePref = {
261261
...currentPrefs,
262262
[targetId]: themeId

0 commit comments

Comments
 (0)