Added commands to add/remove the current theme to favorites (#3682) varunKT001

* Added 'Add current theme to favorite...' command

* Remove toggle for 'Add current theme to favorite...' command

* Added 'Remove current theme from favorite...' command

* Merge add/remove commands in a single file

* removed dots

* updated icon

* only showing favorite commands if custom theme is disabled

Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
Varun Tiwari 2022-10-25 17:08:57 +05:30 committed by GitHub
parent 6adbdb19fd
commit 1afca8204a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View file

@ -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...",

View file

@ -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;