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 <owncast@owncast.online>
Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Varun Gujarathi
2024-11-30 15:32:13 -05:00
committed by GitHub
parent ff1f201798
commit f59ac63dfe
2 changed files with 35 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ const FederationInfoModal: FC<FederationInfoModalProps> = ({ cancelPressed, okPr
<Modal
width="70%"
title="Enable Social Features"
visible
open
onCancel={cancelPressed}
footer={
<div>
@@ -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,