Skip to content

Commit 6410ca8

Browse files
Sharann-delMiodec
authored andcommitted
impr(theme): display custom theme names in indicator (@Sharann-del) (monkeytypegame#7798)
Improves the theme indicator by displaying the actual custom theme name instead of the generic "custom". - Matches active custom theme using color comparison - Displays as: "themeName (custom)" - Falls back to "custom" if no match is found Notes: - Config does not store custom theme IDs, so matching is done via color arrays - Handles edge cases such as unsaved themes and missing DB snapshot - Does not affect preview or random theme behavior --------- Co-authored-by: Jack <jack@monkeytype.com>
1 parent 95eaae2 commit 6410ca8

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

frontend/src/ts/controllers/theme-controller.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,21 @@ function updateThemeIndicator(nameOverride?: string): void {
8585
//text
8686
let str: string = Config.theme;
8787
if (randomTheme !== null) str = randomTheme;
88-
if (Config.customTheme) str = "custom";
88+
89+
if (Config.customTheme && nameOverride === undefined) {
90+
// Match current custom theme by colors since Config does not store custom theme IDs
91+
const snapshot = DB.getSnapshot();
92+
const matchedTheme = snapshot?.customThemes?.find((ct) =>
93+
Arrays.areSortedArraysEqual(ct.colors, Config.customThemeColors),
94+
);
95+
96+
if (matchedTheme) {
97+
str = `${matchedTheme.name} (custom)`;
98+
} else {
99+
str = "custom";
100+
}
101+
}
102+
89103
if (nameOverride !== undefined && nameOverride !== "") str = nameOverride;
90104
str = str.replace(/_/g, " ");
91105

0 commit comments

Comments
 (0)