Skip to content

Commit 1a0eb58

Browse files
committed
fix: theme issues when sent from graph
1 parent 9901039 commit 1a0eb58

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

api/src/unraid-api/graph/resolvers/customization/theme.model.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ export class Theme {
2828
@IsBoolean()
2929
showBannerGradient: boolean = false;
3030

31-
@Field(() => String, { description: 'The background color of the header' })
31+
@Field(() => Boolean, { description: 'Whether to show the description in the header' })
32+
@IsBoolean()
33+
showHeaderDescription: boolean = true;
34+
35+
@Field(() => String, { description: 'The background color of the header', nullable: true })
3236
@IsOptional()
3337
@IsString()
3438
@IsHexColor()
3539
headerBackgroundColor?: string;
3640

37-
@Field(() => Boolean, { description: 'Whether to show the description in the header' })
38-
@IsBoolean()
39-
showHeaderDescription: boolean = true;
40-
41-
@Field(() => String, { description: 'The text color of the header' })
41+
@Field(() => String, { description: 'The text color of the header', nullable: true })
4242
@IsOptional()
4343
@IsString()
4444
@IsHexColor()

web/store/theme.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,34 @@ export const useThemeStore = defineStore('theme', () => {
6666
if (data) {
6767
theme.value = data;
6868
} else {
69-
const result = await load();
70-
if (result) {
71-
if (result.publicTheme) {
69+
try {
70+
const result = await load();
71+
if (result && result.publicTheme) {
7272
theme.value = {
73-
name: result.publicTheme.name.toLowerCase(),
74-
banner: result.publicTheme.showBannerImage,
75-
bannerGradient: result.publicTheme.showBannerGradient,
76-
bgColor: result.publicTheme.headerBackgroundColor,
77-
descriptionShow: result.publicTheme.showHeaderDescription,
73+
name: result.publicTheme.name?.toLowerCase() || 'white',
74+
banner: result.publicTheme.showBannerImage ?? false,
75+
bannerGradient: result.publicTheme.showBannerGradient ?? false,
76+
bgColor: result.publicTheme.headerBackgroundColor || '',
77+
descriptionShow: result.publicTheme.showHeaderDescription ?? false,
7878
metaColor: result.publicTheme.headerSecondaryTextColor || '',
79-
textColor: result.publicTheme.headerPrimaryTextColor,
79+
textColor: result.publicTheme.headerPrimaryTextColor || '',
8080
};
81+
return;
8182
}
83+
} catch (error) {
84+
console.warn('Failed to load theme from server, using default:', error);
8285
}
86+
87+
// Single fallback for both no data and error cases
88+
theme.value = {
89+
name: 'white',
90+
banner: false,
91+
bannerGradient: false,
92+
bgColor: '',
93+
descriptionShow: false,
94+
metaColor: '',
95+
textColor: '',
96+
};
8397
}
8498
};
8599

0 commit comments

Comments
 (0)