diff --git a/frontend/src/ts/commandline/commands.ts b/frontend/src/ts/commandline/commands.ts index f2a46f373..b13417500 100644 --- a/frontend/src/ts/commandline/commands.ts +++ b/frontend/src/ts/commandline/commands.ts @@ -65,6 +65,7 @@ import ResultSavingCommands from "./lists/result-saving"; import NavigationCommands from "./lists/navigation"; import FontSizeCommands from "./lists/font-size"; import ResultScreenCommands from "./lists/result-screen"; +import AddOrRemoveThemeToFavorite from "./lists/add-or-remove-theme-to-favorites"; import TagsCommands from "./lists/tags"; import CustomThemesListCommands from "./lists/custom-themes-list"; @@ -248,6 +249,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { ...CustomThemesListCommands, ...FlipTestColorsCommands, ...ColorfulModeCommands, + ...AddOrRemoveThemeToFavorite, { id: "changeCustomBackground", display: "Custom background...", diff --git a/frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts b/frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts new file mode 100644 index 000000000..d33f83cb4 --- /dev/null +++ b/frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts @@ -0,0 +1,34 @@ +import Config, * as UpdateConfig from "../../config"; + +const commands: MonkeyTypes.Command[] = [ + { + id: "addThemeToFavorite", + display: "Add current theme to favorite", + icon: "fa-heart", + available: (): boolean => { + return !Config.customTheme && !Config.favThemes.includes(Config.theme); + }, + exec: (): void => { + const { theme, favThemes, customTheme } = Config; + if (!customTheme && !favThemes.includes(theme)) { + UpdateConfig.setFavThemes([...favThemes, theme]); + } + }, + }, + { + id: "removeThemeFromFavorite", + display: "Remove current theme from favorite", + icon: "fa-heart-broken", + available: (): boolean => { + return !Config.customTheme && Config.favThemes.includes(Config.theme); + }, + exec: (): void => { + const { theme, favThemes, customTheme } = Config; + if (!customTheme && favThemes.includes(theme)) { + UpdateConfig.setFavThemes([...favThemes.filter((t) => t !== theme)]); + } + }, + }, +]; + +export default commands;