From 78bc883667024faba5e812bb9a8b8ad5bef3e073 Mon Sep 17 00:00:00 2001 From: Manuel Ruwe Date: Sat, 31 Dec 2022 14:11:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20tile=20delete=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Dashboard/Tiles/Apps/AppMenu.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/Dashboard/Tiles/Apps/AppMenu.tsx b/src/components/Dashboard/Tiles/Apps/AppMenu.tsx index 0b960d1c5..fea3a6e2c 100644 --- a/src/components/Dashboard/Tiles/Apps/AppMenu.tsx +++ b/src/components/Dashboard/Tiles/Apps/AppMenu.tsx @@ -1,3 +1,5 @@ +import { useConfigContext } from '../../../../config/provider'; +import { useConfigStore } from '../../../../config/store'; import { openContextModalGeneric } from '../../../../tools/mantineModalManagerExtensions'; import { AppType } from '../../../../types/app'; import { GenericTileMenu } from '../GenericTileMenu'; @@ -7,6 +9,9 @@ interface TileMenuProps { } export const AppMenu = ({ app }: TileMenuProps) => { + const { config, name: configName } = useConfigContext(); + const { updateConfig } = useConfigStore(); + const handleClickEdit = () => { openContextModalGeneric<{ app: AppType; allowAppNamePropagation: boolean }>({ modal: 'editApp', @@ -37,7 +42,16 @@ export const AppMenu = ({ app }: TileMenuProps) => { }); }; - const handleClickDelete = () => {}; + const handleClickDelete = () => { + if (configName === undefined) { + return; + } + + updateConfig(configName, (previousConfig) => ({ + ...previousConfig, + apps: previousConfig.apps.filter((a) => a.id !== app.id), + })); + }; return (