Skip to content

Commit 016d35f

Browse files
committed
use readonly in themeservice
1 parent 51ff418 commit 016d35f

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

src/vs/workbench/services/themes/common/themeService.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ export const VS_LIGHT_THEME = 'vs';
1414
export const VS_DARK_THEME = 'vs-dark';
1515
export const VS_HC_THEME = 'hc-black';
1616

17-
export class IColorTheme {
18-
id: string;
19-
label: string;
20-
description?: string;
21-
isLoaded: boolean;
22-
settings?: IThemeSetting[];
17+
export interface IColorTheme {
18+
readonly id: string;
19+
readonly label: string;
20+
readonly description?: string;
21+
readonly isLoaded: boolean;
22+
readonly settings?: IThemeSetting[];
2323
}
2424

2525
export interface IFileIconTheme {
26-
id: string;
27-
label: string;
28-
description?: string;
29-
isLoaded: boolean;
30-
hasFileIcons?: boolean;
31-
hasFolderIcons?: boolean;
26+
readonly id: string;
27+
readonly label: string;
28+
readonly description?: string;
29+
readonly isLoaded: boolean;
30+
readonly hasFileIcons?: boolean;
31+
readonly hasFolderIcons?: boolean;
3232
}
3333

3434
export interface IThemeService {

src/vs/workbench/services/themes/electron-browser/themeService.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,24 @@ let iconThemeExtPoint = ExtensionsRegistry.registerExtensionPoint<IThemeExtensio
101101
}
102102
});
103103

104-
interface IInternalColorThemeData extends IColorTheme {
104+
class IInternalColorThemeData implements IColorTheme {
105+
id: string;
106+
label: string;
107+
description?: string;
108+
settings?: IThemeSetting[];
109+
isLoaded: boolean;
105110
path?: string;
106111
styleSheetContent?: string;
107112
extensionData: ExtensionData;
108113
}
109114

110-
interface IInternalIconThemeData extends IFileIconTheme {
115+
class IInternalIconThemeData implements IFileIconTheme {
116+
id: string;
117+
label: string;
118+
description?: string;
119+
hasFileIcons?: boolean;
120+
hasFolderIcons?: boolean;
121+
isLoaded: boolean;
111122
path?: string;
112123
styleSheetContent?: string;
113124
extensionData: ExtensionData;
@@ -294,7 +305,6 @@ export class ThemeService implements IThemeService {
294305
$(this.container).addClass(newThemeId);
295306
}
296307
this.currentColorTheme = newTheme;
297-
newTheme.isLoaded = true;
298308

299309
this.storageService.store(COLOR_THEME_PREF, newThemeId, StorageScope.GLOBAL);
300310
if (broadcastToAllWindows) {
@@ -462,7 +472,6 @@ export class ThemeService implements IThemeService {
462472
let onApply = (newIconTheme: IInternalIconThemeData) => {
463473
if (newIconTheme) {
464474
this.currentIconTheme = newIconTheme;
465-
newIconTheme.isLoaded = true;
466475
} else {
467476
this.currentIconTheme = noFileIconTheme;
468477
}
@@ -510,6 +519,7 @@ function _applyIconTheme(data: IInternalIconThemeData, onApply: (theme: IInterna
510519
data.styleSheetContent = result.content;
511520
data.hasFileIcons = result.hasFileIcons;
512521
data.hasFolderIcons = result.hasFolderIcons;
522+
data.isLoaded = true;
513523
_applyRules(data.styleSheetContent, iconThemeRulesClassName);
514524
return onApply(data);
515525
}, error => {
@@ -699,6 +709,7 @@ function applyTheme(theme: IInternalColorThemeData, onApply: (theme: IInternalCo
699709
theme.settings = themeSettings;
700710
let styleSheetContent = _processThemeObject(theme.id, themeSettings);
701711
theme.styleSheetContent = styleSheetContent;
712+
theme.isLoaded = true;
702713
_applyRules(styleSheetContent, colorThemeRulesClassName);
703714
return onApply(theme);
704715
}, error => {

0 commit comments

Comments
 (0)