From 681944f7c59a7df41a8a08342c8a03ff773a79b9 Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Tue, 10 Jan 2023 21:21:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20categories=20and=20wrapper?= =?UTF-8?q?=20position=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bjorn Lammers --- .../Wrappers/Category/useCategoryActions.tsx | 25 +++++++++++++------ .../TorrentNetworkTrafficTile.tsx | 4 +-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/Dashboard/Wrappers/Category/useCategoryActions.tsx b/src/components/Dashboard/Wrappers/Category/useCategoryActions.tsx index 0c9b68bb6..777bdabf3 100644 --- a/src/components/Dashboard/Wrappers/Category/useCategoryActions.tsx +++ b/src/components/Dashboard/Wrappers/Category/useCategoryActions.tsx @@ -46,13 +46,13 @@ export const useCategoryActions = (configName: string | undefined, category: Cat ...aboveCategories, category, // Move categories below down - ...belowCategories.map((x) => ({ ...x, position: x.position + 2 })), + ...belowCategories.map((x) => ({ ...x, position: x.position + 1 })), ], wrappers: [ ...aboveWrappers, newWrapper, // Move wrappers below down - ...belowWrappers.map((x) => ({ ...x, position: x.position + 2 })), + ...belowWrappers.map((x) => ({ ...x, position: x.position + 1 })), ], }; }, @@ -127,12 +127,12 @@ export const useCategoryActions = (configName: string | undefined, category: Cat const currentItem = previous.categories.find((x) => x.id === category.id); if (!currentItem) return previous; - const upperItem = previous.categories.find((x) => x.position === currentItem.position - 2); + const upperItem = previous.categories.find((x) => x.position === currentItem.position - 1); if (!upperItem) return previous; - currentItem.position -= 2; - upperItem.position += 2; + currentItem.position -= 1; + upperItem.position += 1; return { ...previous, @@ -156,12 +156,12 @@ export const useCategoryActions = (configName: string | undefined, category: Cat const currentItem = previous.categories.find((x) => x.id === category.id); if (!currentItem) return previous; - const belowItem = previous.categories.find((x) => x.position === currentItem.position + 2); + const belowItem = previous.categories.find((x) => x.position === currentItem.position + 1); if (!belowItem) return previous; - currentItem.position += 2; - belowItem.position -= 2; + currentItem.position += 1; + belowItem.position -= 1; return { ...previous, @@ -196,6 +196,15 @@ export const useCategoryActions = (configName: string | undefined, category: Cat x.area = { type: 'wrapper', properties: { id: mainWrapper?.id ?? 'default' } }; }); + const widgetsToMove = previous.widgets.filter( + (x) => x.area && x.area.type === 'category' && x.area.properties.id === currentItem.id + ); + + widgetsToMove.forEach((x) => { + // eslint-disable-next-line no-param-reassign + x.area = { type: 'wrapper', properties: { id: mainWrapper?.id ?? 'default' } }; + }); + return { ...previous, apps: previous.apps, diff --git a/src/widgets/torrentNetworkTraffic/TorrentNetworkTrafficTile.tsx b/src/widgets/torrentNetworkTraffic/TorrentNetworkTrafficTile.tsx index ce9f6a01b..59a5e3ca6 100644 --- a/src/widgets/torrentNetworkTraffic/TorrentNetworkTrafficTile.tsx +++ b/src/widgets/torrentNetworkTraffic/TorrentNetworkTrafficTile.tsx @@ -20,8 +20,8 @@ const definition = defineWidget({ options: {}, gridstack: { - minWidth: 6, - minHeight: 6, + minWidth: 2, + minHeight: 2, maxWidth: 12, maxHeight: 6, },