🔧 More fixes for the react-refresh plugin bugs
This commit is contained in:
@@ -7,21 +7,15 @@ import { saveSettings } from "../../actions/settings.actions";
|
||||
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
||||
|
||||
export const AirDCPPHubsForm = (airDCPPClientUserSettings): ReactElement => {
|
||||
const { settings } = airDCPPClientUserSettings;
|
||||
const dispatch = useDispatch();
|
||||
const [hubList, setHubList] = useState([]);
|
||||
const { ADCPPSocket } = useContext(AirDCPPSocketContext);
|
||||
const airDCPPConfiguration = useContext(AirDCPPSocketContext);
|
||||
const { AirDCPPSocket, settings } = airDCPPConfiguration;
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (!isEmpty(settings)) {
|
||||
console.log(ADCPPSocket);
|
||||
await ADCPPSocket.connect(
|
||||
settings.directConnect.client.host.username,
|
||||
settings.directConnect.client.host.password,
|
||||
true,
|
||||
);
|
||||
const hubs = await ADCPPSocket.get(`hubs`);
|
||||
const hubs = await AirDCPPSocket.get(`hubs`);
|
||||
const hubSelectionOptions = hubs.map(({ hub_url, identity }) => ({
|
||||
value: hub_url,
|
||||
label: identity.name,
|
||||
|
||||
@@ -4,36 +4,20 @@ import { useDispatch } from "react-redux";
|
||||
import { saveSettings, deleteSettings } from "../../actions/settings.actions";
|
||||
import { AirDCPPSettingsConfirmation } from "./AirDCPPSettingsConfirmation";
|
||||
import { AirDCPPSocketContext } from "../../context/AirDCPPSocket";
|
||||
import AirDCPPSocket from "../../services/DcppSearchService";
|
||||
import { isUndefined, isEmpty, isNil } from "lodash";
|
||||
|
||||
export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => {
|
||||
const { settings } = airDCPPClientSettings;
|
||||
export const AirDCPPSettingsForm = (): ReactElement => {
|
||||
const dispatch = useDispatch();
|
||||
const { setADCPPSocket } = useContext(AirDCPPSocketContext);
|
||||
const airDCPPConfiguration = useContext(AirDCPPSocketContext);
|
||||
const { AirDCPPSocket, settings } = airDCPPConfiguration;
|
||||
|
||||
const onSubmit = async (values) => {
|
||||
try {
|
||||
const socket = new AirDCPPSocket({
|
||||
hostname: `${values.hostname}`,
|
||||
protocol: `${values.protocol}`,
|
||||
});
|
||||
const socketConnectionResponse = await socket.connect(
|
||||
values.username,
|
||||
values.password,
|
||||
true,
|
||||
);
|
||||
if (!isNil(socketConnectionResponse.session_id)) {
|
||||
if (!isNil(AirDCPPSocket.session_id)) {
|
||||
dispatch(
|
||||
saveSettings({
|
||||
host: values,
|
||||
airDCPPUserSettings: socketConnectionResponse,
|
||||
}),
|
||||
);
|
||||
setADCPPSocket(
|
||||
new AirDCPPSocket({
|
||||
hostname: `${values.hostname}`,
|
||||
protocol: `${values.protocol}`,
|
||||
airDCPPUserSettings: settings,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -44,7 +28,6 @@ export const AirDCPPSettingsForm = (airDCPPClientSettings): ReactElement => {
|
||||
|
||||
const removeSettings = useCallback(async () => {
|
||||
dispatch(deleteSettings());
|
||||
setADCPPSocket({});
|
||||
}, []);
|
||||
|
||||
const validate = async () => {};
|
||||
|
||||
Reference in New Issue
Block a user