Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(ui): satisfy preset lint

joshistoasteaa1ce96072e
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetManagerDialogBody.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetManagerDialogBody.tsx
index 9815a901ef..3c8da5591e 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetManagerDialogBody.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetManagerDialogBody.tsx
@@ -33,13 +33,17 @@ export const LayoutPresetManagerDialogBody = () => {
const { t } = useTranslation();
const { layout } = useWorkbenchCommands();
const account = useWorkbenchSelector((snapshot) => snapshot.account);
- const presets = getOrderedLayoutPresets(account);
- const presetIds = presets.map(({ id }) => id);
- const overriddenPresetIds = new Set([
- ...Object.keys(account.layoutPresetMetadataOverrides ?? {}),
- ...Object.keys(account.layoutPresetOverrides ?? {}),
- ...Object.keys(account.layoutPresetRouteOverrides ?? {}),
- ]);
+ const presets = useMemo(() => getOrderedLayoutPresets(account), [account]);
+ const presetIds = useMemo(() => presets.map(({ id }) => id), [presets]);
+ const overriddenPresetIds = useMemo(
+ () =>
+ new Set([
+ ...Object.keys(account.layoutPresetMetadataOverrides ?? {}),
+ ...Object.keys(account.layoutPresetOverrides ?? {}),
+ ...Object.keys(account.layoutPresetRouteOverrides ?? {}),
+ ]),
+ [account.layoutPresetMetadataOverrides, account.layoutPresetOverrides, account.layoutPresetRouteOverrides]
+ );
const sensors = useSensors(
useSensor(PointerSensor, POINTER_SENSOR_OPTIONS),
useSensor(KeyboardSensor, KEYBOARD_SENSOR_OPTIONS)
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
index b62d02a625..6b1ddb08c4 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.browser.test.tsx
@@ -1,3 +1,5 @@
+import type * as LayoutPresetActivationModule from '@workbench/layoutPresetActivation';
+
import { ChakraProvider } from '@chakra-ui/react';
import { system } from '@theme/system';
import { createWorkbenchStore, type WorkbenchInternalStore } from '@workbench/workbenchStore';
@@ -35,7 +37,7 @@ vi.mock('@workbench/WorkbenchContext', () => {
});
vi.mock('@workbench/layoutPresetActivation', async (importOriginal) => {
- const actual = await importOriginal<typeof import('@workbench/layoutPresetActivation')>();
+ const actual = await importOriginal<typeof LayoutPresetActivationModule>();
return {
...actual,
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
index 26511beea3..26f2e4fea8 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx
@@ -64,8 +64,8 @@ export const LayoutPresetStrip = () => {
const account = useWorkbenchSelector((snapshot) => snapshot.account);
const invocation = useActiveProjectSelector((project) => project.invocation);
const sourceOptions = useActiveProjectSelector(selectPlacedGraphWidgetSources);
- const presets = getOrderedLayoutPresets(account);
- const presetIds = presets.map(({ id }) => id);
+ const presets = useMemo(() => getOrderedLayoutPresets(account), [account]);
+ const presetIds = useMemo(() => presets.map(({ id }) => id), [presets]);
const sensors = useSensors(useSensor(PointerSensor, POINTER_SENSOR_OPTIONS));
const saveAsDefaultRoute = useMemo(
() => ({ destination: invocation.destination, sourceId: invocation.sourceId }),