From f3babbcb19f6104fec76de8dce9ddfb4b14f9854 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 20 Mar 2025 10:53:34 -0400 Subject: [PATCH] if statements -> switch statements --- crates/desktop/src-tauri/tauri.conf.json | 5 +- .../NodesManagers/ToolbarNodeUtilities.ts | 213 +++++++++--------- 2 files changed, 107 insertions(+), 111 deletions(-) diff --git a/crates/desktop/src-tauri/tauri.conf.json b/crates/desktop/src-tauri/tauri.conf.json index efc6948567..f408df7602 100644 --- a/crates/desktop/src-tauri/tauri.conf.json +++ b/crates/desktop/src-tauri/tauri.conf.json @@ -32,9 +32,6 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ], - "resources": { - "../../../windows_dlls/*.dll": "." - } + ] } } diff --git a/frontend/realtime/src/KonvaApp/NodesManagers/ToolbarNodeUtilities.ts b/frontend/realtime/src/KonvaApp/NodesManagers/ToolbarNodeUtilities.ts index 0c14479ac3..95c55cd7c5 100644 --- a/frontend/realtime/src/KonvaApp/NodesManagers/ToolbarNodeUtilities.ts +++ b/frontend/realtime/src/KonvaApp/NodesManagers/ToolbarNodeUtilities.ts @@ -46,29 +46,29 @@ export function getImageNodeButtonStates( return buttonStates; } - // hidden buttons - if ( - buttonName === ButtonNames.AI_STYLIZE || - buttonName === ButtonNames.SEGMENTATION || - buttonName === ButtonNames.DOWNLOAD || - buttonName === ButtonNames.CHROMA || - buttonName === ButtonNames.COLOR - ) { - buttonStates[buttonName] = { - disabled: true, - hidden: true, - active: false, - }; - return buttonStates; - } + switch (buttonName) { + case ButtonNames.AI_STYLIZE: + case ButtonNames.SEGMENTATION: + case ButtonNames.DOWNLOAD: + case ButtonNames.CHROMA: + case ButtonNames.COLOR: + // hidden buttons + buttonStates[buttonName] = { + disabled: true, + hidden: true, + active: false, + }; + return buttonStates; - // all other buttons - buttonStates[buttonName] = { - disabled: false, - hidden: false, - active: false, - }; - return buttonStates; + default: + // all other buttons + buttonStates[buttonName] = { + disabled: false, + hidden: false, + active: false, + }; + return buttonStates; + } }, {} as ContextualToolbarProps["buttonStates"], ); @@ -89,29 +89,29 @@ export function getTextNodeButtonStates( return buttonStates; } - // hidden buttons - if ( - buttonName === ButtonNames.AI_STYLIZE || - buttonName === ButtonNames.SEGMENTATION || - buttonName === ButtonNames.DOWNLOAD || - buttonName === ButtonNames.CHROMA || - buttonName === ButtonNames.REMOVE_BACKGROUND - ) { - buttonStates[buttonName] = { - disabled: true, - hidden: true, - active: false, - }; - return buttonStates; - } + switch (buttonName) { + case ButtonNames.AI_STYLIZE: + case ButtonNames.SEGMENTATION: + case ButtonNames.DOWNLOAD: + case ButtonNames.CHROMA: + case ButtonNames.REMOVE_BACKGROUND: + // hidden buttons + buttonStates[buttonName] = { + disabled: true, + hidden: true, + active: false, + }; + return buttonStates; - // all other buttons - buttonStates[buttonName] = { - disabled: false, - hidden: false, - active: false, - }; - return buttonStates; + default: + // all other buttons + buttonStates[buttonName] = { + disabled: false, + hidden: false, + active: false, + }; + return buttonStates; + } }, {} as ContextualToolbarProps["buttonStates"], ); @@ -131,25 +131,26 @@ export function getVideoNodeButtonStates( }; return buttonStates; } - // soon to come feature is disabled - if (buttonName === ButtonNames.AI_STYLIZE || - buttonName === ButtonNames.COLOR || - buttonName === ButtonNames.REMOVE_BACKGROUND - ) { - buttonStates[buttonName] = { - disabled: true, - hidden: true, - active: false, - }; - return buttonStates; + switch (buttonName) { + case ButtonNames.AI_STYLIZE: + case ButtonNames.COLOR: + case ButtonNames.REMOVE_BACKGROUND: + // soon to come feature is disabled + buttonStates[buttonName] = { + disabled: true, + hidden: true, + active: false, + }; + return buttonStates; + default: + // all other buttons + buttonStates[buttonName] = { + disabled: false, + hidden: false, + active: false, + }; + return buttonStates; } - // all other buttons - buttonStates[buttonName] = { - disabled: false, - hidden: false, - active: false, - }; - return buttonStates; }, {} as ContextualToolbarProps["buttonStates"], ); @@ -171,29 +172,28 @@ export function getShapeNodeButtonStates( return buttonStates; } - // hidden buttons - if ( - buttonName === ButtonNames.AI_STYLIZE || - buttonName === ButtonNames.SEGMENTATION || - buttonName === ButtonNames.DOWNLOAD || - buttonName === ButtonNames.CHROMA || - buttonName === ButtonNames.REMOVE_BACKGROUND - ) { - buttonStates[buttonName] = { - disabled: true, - hidden: true, - active: false, - }; - return buttonStates; + switch (buttonName) { + case ButtonNames.AI_STYLIZE: + case ButtonNames.SEGMENTATION: + case ButtonNames.DOWNLOAD: + case ButtonNames.CHROMA: + case ButtonNames.REMOVE_BACKGROUND: + // hidden buttons + buttonStates[buttonName] = { + disabled: true, + hidden: true, + active: false, + }; + return buttonStates; + default: + // all other buttons + buttonStates[buttonName] = { + disabled: false, + hidden: false, + active: false, + }; + return buttonStates; } - - // all other buttons - buttonStates[buttonName] = { - disabled: false, - hidden: false, - active: false, - }; - return buttonStates; }, {} as ContextualToolbarProps["buttonStates"], ); @@ -215,30 +215,29 @@ export function getMultiSelectButtonStates( return buttonStates; } - // hidden buttons - if ( - buttonName === ButtonNames.AI_STYLIZE || - buttonName === ButtonNames.SEGMENTATION || - buttonName === ButtonNames.DOWNLOAD || - buttonName === ButtonNames.CHROMA || - buttonName === ButtonNames.COLOR || - buttonName === ButtonNames.REMOVE_BACKGROUND - ) { - buttonStates[buttonName] = { - disabled: true, - hidden: true, - active: false, - }; - return buttonStates; + switch (buttonName) { + case ButtonNames.AI_STYLIZE: + case ButtonNames.SEGMENTATION: + case ButtonNames.DOWNLOAD: + case ButtonNames.CHROMA: + case ButtonNames.COLOR: + case ButtonNames.REMOVE_BACKGROUND: + // hidden buttons + buttonStates[buttonName] = { + disabled: true, + hidden: true, + active: false, + }; + return buttonStates; + default: + // all other buttons + buttonStates[buttonName] = { + disabled: false, + hidden: false, + active: false, + }; + return buttonStates; } - - // all other buttons - buttonStates[buttonName] = { - disabled: false, - hidden: false, - active: false, - }; - return buttonStates; }, {} as ContextualToolbarProps["buttonStates"], );