From f59ac63dfe9abbaf3cb4d893ae1f9e8604efe75f Mon Sep 17 00:00:00 2001 From: Varun Gujarathi Date: Sat, 30 Nov 2024 15:32:13 -0500 Subject: [PATCH] fix(social): set federation enabled state after confirmation (#4038) * feat(integerations): add route to get user details * Commit updated API documentation * test(integrations): implement unit test for get user details * fix(social): set federation enabled state after confirmation set federation enabled state only after confirmation in modal * Javascript formatting autofixes * chore(social): use variable instead of explicitly setting path value * Javascript formatting autofixes --------- Co-authored-by: Owncast Co-authored-by: Gabe Kangas --- web/pages/admin/config-federation.tsx | 35 ++++++++++++++++++++++++++- web/utils/config-constants.tsx | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/web/pages/admin/config-federation.tsx b/web/pages/admin/config-federation.tsx index e48cf841d..9bc6a5d82 100644 --- a/web/pages/admin/config-federation.tsx +++ b/web/pages/admin/config-federation.tsx @@ -37,7 +37,7 @@ const FederationInfoModal: FC = ({ cancelPressed, okPr @@ -125,6 +125,17 @@ const ConfigFederation = () => { const handleEnabledSwitchChange = (value: boolean) => { if (!value) { + postConfigUpdateToAPI({ + apiPath: FIELD_PROPS_ENABLE_FEDERATION.apiPath, + data: { value: false }, + onSuccess: () => { + setFieldInConfigState({ + fieldName: 'enabled', + value: false, + path: FIELD_PROPS_ENABLE_FEDERATION.configPath, + }); + }, + }); setFormDataValues({ ...formDataValues, enabled: false, @@ -153,6 +164,17 @@ const ConfigFederation = () => { function federationInfoModalCancelPressed() { setIsInfoModalOpen(false); + postConfigUpdateToAPI({ + apiPath: FIELD_PROPS_ENABLE_FEDERATION.apiPath, + data: { value: false }, + onSuccess: () => { + setFieldInConfigState({ + fieldName: 'enabled', + value: false, + path: FIELD_PROPS_ENABLE_FEDERATION.configPath, + }); + }, + }); setFormDataValues({ ...formDataValues, enabled: false, @@ -161,6 +183,17 @@ const ConfigFederation = () => { function federationInfoModalOkPressed() { setIsInfoModalOpen(false); + postConfigUpdateToAPI({ + apiPath: FIELD_PROPS_ENABLE_FEDERATION.apiPath, + data: { value: false }, + onSuccess: () => { + setFieldInConfigState({ + fieldName: 'enabled', + value: true, + path: FIELD_PROPS_ENABLE_FEDERATION.configPath, + }); + }, + }); setFormDataValues({ ...formDataValues, enabled: true, diff --git a/web/utils/config-constants.tsx b/web/utils/config-constants.tsx index 28f35503d..dfcee0252 100644 --- a/web/utils/config-constants.tsx +++ b/web/utils/config-constants.tsx @@ -313,7 +313,7 @@ export const FIELD_PROPS_ENABLE_FEDERATION = { configPath: 'federation', label: 'Enable Social Features', tip: 'Send and receive activities on the Fediverse.', - useSubmit: true, + useSubmit: false, }; export const FIELD_PROPS_FEDERATION_IS_PRIVATE = {