Skip to content

Commit

Permalink
Use new object to avoid referential equality
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Mar 24, 2023
1 parent eda73b0 commit d5a0bd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/browser/icon-theme-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ export class IconThemeService {
const preference = this.schemaProvider.getSchemaProperty(ICON_THEME_PREFERENCE_KEY);
if (preference) {
const sortedThemes = Array.from(this.definitions).sort((a, b) => a.label.localeCompare(b.label));
preference.enum = sortedThemes.map(e => e.id);
preference.enumItemLabels = sortedThemes.map(e => e.label);
this.schemaProvider.updateSchemaProperty(ICON_THEME_PREFERENCE_KEY, preference);
this.schemaProvider.updateSchemaProperty(ICON_THEME_PREFERENCE_KEY, {
...preference,
enum: sortedThemes.map(e => e.id),
enumItemLabels: sortedThemes.map(e => e.label)
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
return this.combinedSchema.properties[key];
}

/**
* {@link property} will be assigned to field {@link key} in the schema.
* Pass a new object to invalidate old schema.
*/
updateSchemaProperty(key: string, property: PreferenceDataProperty): void {
this.updateSchemaProps(key, property);
this.fireDidPreferenceSchemaChanged();
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/browser/theming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ export class ThemeService {
const preference = this.schemaProvider.getSchemaProperty(COLOR_THEME_PREFERENCE_KEY);
if (preference) {
const sortedThemes = this.getThemes().sort((a, b) => a.label.localeCompare(b.label));
preference.enum = sortedThemes.map(e => e.id);
preference.enumItemLabels = sortedThemes.map(e => e.label);
this.schemaProvider.updateSchemaProperty(COLOR_THEME_PREFERENCE_KEY, preference);
this.schemaProvider.updateSchemaProperty(COLOR_THEME_PREFERENCE_KEY, {
...preference,
enum: sortedThemes.map(e => e.id),
enumItemLabels: sortedThemes.map(e => e.label)
});
}
}

Expand Down

0 comments on commit d5a0bd8

Please sign in to comment.