Skip to content

Commit

Permalink
Account for new preference in skillmap
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Mar 6, 2025
1 parent 665e722 commit 11e9b41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions skillmap/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ class AppImpl extends React.Component<AppProps, AppState> {
protected async initColorThemeAsync() {
// Load theme colors
const prefThemeId = await authClient.getColorThemeIdAsync();
let initialTheme = this.props.highContrast ?
pxt.appTarget?.appTheme?.highContrastColorTheme :
prefThemeId ?? pxt.appTarget?.appTheme?.defaultColorTheme;
let initialTheme = this.props.highContrast
? pxt.appTarget?.appTheme?.highContrastColorTheme
: prefThemeId && this.themeManager.isKnownTheme(prefThemeId)
? prefThemeId
: pxt.appTarget?.appTheme?.defaultColorTheme;

if (initialTheme) {
if (initialTheme !== this.themeManager.getCurrentColorTheme()?.id) {
Expand Down Expand Up @@ -420,7 +422,6 @@ class AppImpl extends React.Component<AppProps, AppState> {
changeTheme(theme: pxt.ColorThemeInfo) {
pxt.tickEvent(`skillmap.menu.theme.changetheme`, { theme: theme.id });
this.themeManager.switchColorTheme(theme.id);
this.props.dispatchSetUserPreferences({ themeId: theme.id });
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion skillmap/src/lib/authClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export async function getBadgeStateAsync(): Promise<pxt.auth.UserBadgeState | un
export async function getColorThemeIdAsync(): Promise<string | undefined> {
const cli = await clientAsync();
const prefs = await cli?.userPreferencesAsync();
return prefs?.themeId;
return prefs?.colorThemeIds?.[pxt.appTarget.id];
}

export async function userPreferencesAsync(): Promise<pxt.auth.UserPreferences | undefined> {
Expand Down

0 comments on commit 11e9b41

Please sign in to comment.