From 25d9513a7bac675f18a083771041489d7f1e24b8 Mon Sep 17 00:00:00 2001 From: Varun Tiwari Date: Tue, 25 Oct 2022 15:16:42 +0530 Subject: [PATCH 1/7] Added 'Add current theme to favorite...' command --- frontend/src/ts/commandline/commands.ts | 2 ++ .../lists/add-theme-to-favorite.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 frontend/src/ts/commandline/lists/add-theme-to-favorite.ts diff --git a/frontend/src/ts/commandline/commands.ts b/frontend/src/ts/commandline/commands.ts index f2a46f3736b0..636a4bb10c14 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 AddThemeToFavorite from "./lists/add-theme-to-favorite"; import TagsCommands from "./lists/tags"; import CustomThemesListCommands from "./lists/custom-themes-list"; @@ -248,6 +249,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { ...CustomThemesListCommands, ...FlipTestColorsCommands, ...ColorfulModeCommands, + ...AddThemeToFavorite, { id: "changeCustomBackground", display: "Custom background...", diff --git a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts new file mode 100644 index 000000000000..b5f0a7d144a1 --- /dev/null +++ b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts @@ -0,0 +1,20 @@ +import Config, * as UpdateConfig from "../../config"; + +const commands: MonkeyTypes.Command[] = [ + { + id: "addThemeToFavorite", + display: "Add current theme to favorite...", + icon: "fa-heart", + exec: (): void => { + const { theme, favThemes } = Config; + console.log(theme); + if (favThemes.includes(theme)) { + UpdateConfig.setFavThemes([...favThemes.filter((t) => t !== theme)]); + } else { + UpdateConfig.setFavThemes([...favThemes, theme]); + } + }, + }, +]; + +export default commands; From ee2592bc261c51232f13e632ab68d1891a1d790d Mon Sep 17 00:00:00 2001 From: Varun Tiwari Date: Tue, 25 Oct 2022 15:58:49 +0530 Subject: [PATCH 2/7] Remove toggle for 'Add current theme to favorite...' command --- frontend/src/ts/commandline/lists/add-theme-to-favorite.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts index b5f0a7d144a1..d782a048a2c5 100644 --- a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts +++ b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts @@ -7,10 +7,7 @@ const commands: MonkeyTypes.Command[] = [ icon: "fa-heart", exec: (): void => { const { theme, favThemes } = Config; - console.log(theme); - if (favThemes.includes(theme)) { - UpdateConfig.setFavThemes([...favThemes.filter((t) => t !== theme)]); - } else { + if (!favThemes.includes(theme)) { UpdateConfig.setFavThemes([...favThemes, theme]); } }, From a40804d8e5f7fae084d0c6048b28232377012bec Mon Sep 17 00:00:00 2001 From: Varun Tiwari Date: Tue, 25 Oct 2022 16:32:52 +0530 Subject: [PATCH 3/7] Added 'Remove current theme from favorite...' command --- frontend/src/ts/commandline/commands.ts | 2 ++ .../lists/add-theme-to-favorite.ts | 7 +++++-- .../lists/remove-theme-from-favorite.ts | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts diff --git a/frontend/src/ts/commandline/commands.ts b/frontend/src/ts/commandline/commands.ts index 636a4bb10c14..da638eb752b2 100644 --- a/frontend/src/ts/commandline/commands.ts +++ b/frontend/src/ts/commandline/commands.ts @@ -66,6 +66,7 @@ import NavigationCommands from "./lists/navigation"; import FontSizeCommands from "./lists/font-size"; import ResultScreenCommands from "./lists/result-screen"; import AddThemeToFavorite from "./lists/add-theme-to-favorite"; +import RemoveThemeFromFavorite from "./lists/remove-theme-from-favorite"; import TagsCommands from "./lists/tags"; import CustomThemesListCommands from "./lists/custom-themes-list"; @@ -250,6 +251,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { ...FlipTestColorsCommands, ...ColorfulModeCommands, ...AddThemeToFavorite, + ...RemoveThemeFromFavorite, { id: "changeCustomBackground", display: "Custom background...", diff --git a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts index d782a048a2c5..e1d125baea6b 100644 --- a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts +++ b/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts @@ -5,9 +5,12 @@ const commands: MonkeyTypes.Command[] = [ id: "addThemeToFavorite", display: "Add current theme to favorite...", icon: "fa-heart", + available: (): boolean => { + return !Config.favThemes.includes(Config.theme); + }, exec: (): void => { - const { theme, favThemes } = Config; - if (!favThemes.includes(theme)) { + const { theme, favThemes, customTheme } = Config; + if (!customTheme && !favThemes.includes(theme)) { UpdateConfig.setFavThemes([...favThemes, theme]); } }, diff --git a/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts b/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts new file mode 100644 index 000000000000..22e760be1853 --- /dev/null +++ b/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts @@ -0,0 +1,20 @@ +import Config, * as UpdateConfig from "../../config"; + +const commands: MonkeyTypes.Command[] = [ + { + id: "removeThemeToFavorite", + display: "Remove current theme to favorite...", + icon: "fa-trash", + available: (): boolean => { + return 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; From 9c299c7df50757b72024c6c8227de27a0ee5b3de Mon Sep 17 00:00:00 2001 From: Varun Tiwari Date: Tue, 25 Oct 2022 16:55:02 +0530 Subject: [PATCH 4/7] Merge add/remove commands in a single file --- frontend/src/ts/commandline/commands.ts | 6 ++---- ...ts => add-or-remove-theme-to-favorites.ts} | 14 +++++++++++++ .../lists/remove-theme-from-favorite.ts | 20 ------------------- 3 files changed, 16 insertions(+), 24 deletions(-) rename frontend/src/ts/commandline/lists/{add-theme-to-favorite.ts => add-or-remove-theme-to-favorites.ts} (55%) delete mode 100644 frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts diff --git a/frontend/src/ts/commandline/commands.ts b/frontend/src/ts/commandline/commands.ts index da638eb752b2..b134175003fa 100644 --- a/frontend/src/ts/commandline/commands.ts +++ b/frontend/src/ts/commandline/commands.ts @@ -65,8 +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 AddThemeToFavorite from "./lists/add-theme-to-favorite"; -import RemoveThemeFromFavorite from "./lists/remove-theme-from-favorite"; +import AddOrRemoveThemeToFavorite from "./lists/add-or-remove-theme-to-favorites"; import TagsCommands from "./lists/tags"; import CustomThemesListCommands from "./lists/custom-themes-list"; @@ -250,8 +249,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = { ...CustomThemesListCommands, ...FlipTestColorsCommands, ...ColorfulModeCommands, - ...AddThemeToFavorite, - ...RemoveThemeFromFavorite, + ...AddOrRemoveThemeToFavorite, { id: "changeCustomBackground", display: "Custom background...", diff --git a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts b/frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts similarity index 55% rename from frontend/src/ts/commandline/lists/add-theme-to-favorite.ts rename to frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts index e1d125baea6b..a539a2ca048b 100644 --- a/frontend/src/ts/commandline/lists/add-theme-to-favorite.ts +++ b/frontend/src/ts/commandline/lists/add-or-remove-theme-to-favorites.ts @@ -15,6 +15,20 @@ const commands: MonkeyTypes.Command[] = [ } }, }, + { + id: "removeThemeFromFavorite", + display: "Remove current theme from favorite...", + icon: "fa-trash", + available: (): boolean => { + return 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; diff --git a/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts b/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts deleted file mode 100644 index 22e760be1853..000000000000 --- a/frontend/src/ts/commandline/lists/remove-theme-from-favorite.ts +++ /dev/null @@ -1,20 +0,0 @@ -import Config, * as UpdateConfig from "../../config"; - -const commands: MonkeyTypes.Command[] = [ - { - id: "removeThemeToFavorite", - display: "Remove current theme to favorite...", - icon: "fa-trash", - available: (): boolean => { - return 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; From b586011d8736bdd08eb859a735cd464f3b49551c Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 25 Oct 2022 13:32:03 +0200 Subject: [PATCH 5/7] removed dots --- .../ts/commandline/lists/add-or-remove-theme-to-favorites.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index a539a2ca048b..ec388883d2b1 100644 --- 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 @@ -3,7 +3,7 @@ import Config, * as UpdateConfig from "../../config"; const commands: MonkeyTypes.Command[] = [ { id: "addThemeToFavorite", - display: "Add current theme to favorite...", + display: "Add current theme to favorite", icon: "fa-heart", available: (): boolean => { return !Config.favThemes.includes(Config.theme); @@ -17,7 +17,7 @@ const commands: MonkeyTypes.Command[] = [ }, { id: "removeThemeFromFavorite", - display: "Remove current theme from favorite...", + display: "Remove current theme from favorite", icon: "fa-trash", available: (): boolean => { return Config.favThemes.includes(Config.theme); From c3c45f9cacfb47fd7e4294bb6332f95de5108655 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 25 Oct 2022 13:34:27 +0200 Subject: [PATCH 6/7] updated icon --- .../ts/commandline/lists/add-or-remove-theme-to-favorites.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ec388883d2b1..4e6d95bd55f4 100644 --- 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 @@ -18,7 +18,7 @@ const commands: MonkeyTypes.Command[] = [ { id: "removeThemeFromFavorite", display: "Remove current theme from favorite", - icon: "fa-trash", + icon: "fa-heart-broken", available: (): boolean => { return Config.favThemes.includes(Config.theme); }, From 5bb354f2d0db67a7a29cc0835f019778ebf515bf Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 25 Oct 2022 13:35:51 +0200 Subject: [PATCH 7/7] only showing favorite commands if custom theme is disabled --- .../ts/commandline/lists/add-or-remove-theme-to-favorites.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 4e6d95bd55f4..d33f83cb4d55 100644 --- 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 @@ -6,7 +6,7 @@ const commands: MonkeyTypes.Command[] = [ display: "Add current theme to favorite", icon: "fa-heart", available: (): boolean => { - return !Config.favThemes.includes(Config.theme); + return !Config.customTheme && !Config.favThemes.includes(Config.theme); }, exec: (): void => { const { theme, favThemes, customTheme } = Config; @@ -20,7 +20,7 @@ const commands: MonkeyTypes.Command[] = [ display: "Remove current theme from favorite", icon: "fa-heart-broken", available: (): boolean => { - return Config.favThemes.includes(Config.theme); + return !Config.customTheme && Config.favThemes.includes(Config.theme); }, exec: (): void => { const { theme, favThemes, customTheme } = Config;