From 10dca58cc44c15bd35177fe19768df20d93a84d9 Mon Sep 17 00:00:00 2001 From: Ben Loe Date: Tue, 2 Jul 2024 15:45:42 -0400 Subject: [PATCH] delete unused hook --- .../hooks/useSaveStandaloneModComponent.ts | 72 ------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/pageEditor/hooks/useSaveStandaloneModComponent.ts diff --git a/src/pageEditor/hooks/useSaveStandaloneModComponent.ts b/src/pageEditor/hooks/useSaveStandaloneModComponent.ts deleted file mode 100644 index afaa7fab64..0000000000 --- a/src/pageEditor/hooks/useSaveStandaloneModComponent.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2024 PixieBrix, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import { useSelector } from "react-redux"; -import { useState } from "react"; -import useUpsertModComponentFormState from "@/pageEditor/hooks/useUpsertModComponentFormState"; -import { selectSessionId } from "@/pageEditor/slices/sessionSelectors"; -import reportEvent from "@/telemetry/reportEvent"; -import { Events } from "@/telemetry/events"; -import notify from "@/utils/notify"; -import { type ModComponentFormState } from "@/pageEditor/starterBricks/formStateTypes"; - -type ModComponentSaver = { - save: (modComponentFormState: ModComponentFormState) => Promise; - isSaving: boolean; -}; - -function useSaveStandaloneModComponent(): ModComponentSaver { - const [isSaving, setIsSaving] = useState(false); - const upsertModComponentFormState = useUpsertModComponentFormState(); - const sessionId = useSelector(selectSessionId); - - async function save( - modComponentFormState: ModComponentFormState, - ): Promise { - setIsSaving(true); - - try { - const error = await upsertModComponentFormState({ - modComponentFormState, - options: { - pushToCloud: true, - checkPermissions: true, - notifySuccess: true, - reactivateEveryTab: true, - }, - }); - - if (error) { - notify.error(error); - } else { - reportEvent(Events.PAGE_EDITOR_STANDALONE_MOD_COMPONENT_UPDATE, { - sessionId, - extensionId: modComponentFormState.uuid, - }); - } - } finally { - setIsSaving(false); - } - } - - return { - save, - isSaving, - }; -} - -export default useSaveStandaloneModComponent;