mirror of https://github.com/morpheus65535/bazarr
Add submithooks to the providers section of the settings page
This commit is contained in:
parent
1766ceeabc
commit
f60449aad5
|
@ -28,6 +28,10 @@ import {
|
||||||
useStagedValues,
|
useStagedValues,
|
||||||
} from "../utilities/FormValues";
|
} from "../utilities/FormValues";
|
||||||
import { useSettingValue } from "../utilities/hooks";
|
import { useSettingValue } from "../utilities/hooks";
|
||||||
|
import {
|
||||||
|
SubmitHooksProvider,
|
||||||
|
useSubmitHooksSource,
|
||||||
|
} from "../utilities/HooksProvider";
|
||||||
import { SettingsProvider, useSettings } from "../utilities/SettingsProvider";
|
import { SettingsProvider, useSettings } from "../utilities/SettingsProvider";
|
||||||
import { ProviderInfo, ProviderList } from "./list";
|
import { ProviderInfo, ProviderList } from "./list";
|
||||||
|
|
||||||
|
@ -129,6 +133,8 @@ const ProviderTool: FunctionComponent<ProviderToolProps> = ({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const submitHooks = useSubmitHooksSource();
|
||||||
|
|
||||||
const deletePayload = useCallback(() => {
|
const deletePayload = useCallback(() => {
|
||||||
if (payload && enabledProviders) {
|
if (payload && enabledProviders) {
|
||||||
const idx = enabledProviders.findIndex((v) => v === payload.key);
|
const idx = enabledProviders.findIndex((v) => v === payload.key);
|
||||||
|
@ -152,11 +158,14 @@ const ProviderTool: FunctionComponent<ProviderToolProps> = ({
|
||||||
changes[ProviderKey] = newProviders;
|
changes[ProviderKey] = newProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply submit hooks
|
||||||
|
submitHooks.invoke(changes);
|
||||||
|
|
||||||
onChangeRef.current(changes);
|
onChangeRef.current(changes);
|
||||||
modals.closeAll();
|
modals.closeAll();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[info, enabledProviders, modals]
|
[info, enabledProviders, submitHooks, modals]
|
||||||
);
|
);
|
||||||
|
|
||||||
const canSave = info !== null;
|
const canSave = info !== null;
|
||||||
|
@ -249,6 +258,7 @@ const ProviderTool: FunctionComponent<ProviderToolProps> = ({
|
||||||
return (
|
return (
|
||||||
<SettingsProvider value={settings}>
|
<SettingsProvider value={settings}>
|
||||||
<FormContext.Provider value={form}>
|
<FormContext.Provider value={form}>
|
||||||
|
<SubmitHooksProvider value={submitHooks}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
<Selector
|
<Selector
|
||||||
|
@ -281,6 +291,7 @@ const ProviderTool: FunctionComponent<ProviderToolProps> = ({
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</SubmitHooksProvider>
|
||||||
</FormContext.Provider>
|
</FormContext.Provider>
|
||||||
</SettingsProvider>
|
</SettingsProvider>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue