mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-21 08:37:46 +00:00
fix(sdk): custom server url is overwritten by sdk default url option value (#14092)
* fix(sdk): custom server url is overwritten by sdk default url option value
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useMemo } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { IReduxState } from '../../../app/types';
|
||||
import { updateSettings } from '../../../base/settings/actions';
|
||||
import Input from '../../../base/ui/components/native/Input';
|
||||
import Switch from '../../../base/ui/components/native/Switch';
|
||||
import { isServerURLChangeEnabled, normalizeUserInputURL } from '../../functions.any';
|
||||
import { isServerURLChangeEnabled, normalizeUserInputURL } from '../../functions.native';
|
||||
|
||||
import FormRow from './FormRow';
|
||||
import FormSection from './FormSection';
|
||||
@@ -17,7 +17,6 @@ import styles from './styles';
|
||||
const ConferenceSection = () => {
|
||||
const { t } = useTranslation();
|
||||
const dispatch = useDispatch();
|
||||
const defaultServerURL = useSelector((state: IReduxState) => getDefaultURL(state));
|
||||
const {
|
||||
serverURL,
|
||||
startCarMode,
|
||||
@@ -25,7 +24,10 @@ const ConferenceSection = () => {
|
||||
startWithVideoMuted
|
||||
} = useSelector((state: IReduxState) => state['features/base/settings']);
|
||||
|
||||
const { serverURLChangeEnabled } = useSelector((state: IReduxState) => isServerURLChangeEnabled(state));
|
||||
const defaultServerURL = useSelector((state: IReduxState) => getDefaultURL(state));
|
||||
const [ newServerURL, setNewServerURL ] = useState(serverURL ?? '');
|
||||
|
||||
const serverURLChangeEnabled = useSelector((state: IReduxState) => isServerURLChangeEnabled(state));
|
||||
|
||||
const switches = useMemo(() => [
|
||||
{
|
||||
@@ -45,21 +47,27 @@ const ConferenceSection = () => {
|
||||
}
|
||||
], [ startCarMode, startWithAudioMuted, startWithVideoMuted ]);
|
||||
|
||||
const onChangeServerURL = useCallback(newServerURL => {
|
||||
dispatch(updateSettings({ serverURL: newServerURL }));
|
||||
}, [ updateSettings ]);
|
||||
const onChangeServerURL = useCallback(value => {
|
||||
|
||||
setNewServerURL(value);
|
||||
dispatch(updateSettings({
|
||||
serverURL: value
|
||||
}));
|
||||
}, [ dispatch, newServerURL ]);
|
||||
|
||||
const processServerURL = useCallback(() => {
|
||||
const normalizedURL = normalizeUserInputURL(serverURL ?? '');
|
||||
const normalizedURL = normalizeUserInputURL(newServerURL);
|
||||
|
||||
onChangeServerURL(normalizedURL);
|
||||
}, [ serverURL ]);
|
||||
}, [ newServerURL ]);
|
||||
|
||||
useEffect(() => () => processServerURL(), []);
|
||||
|
||||
const onSwitchToggled = useCallback((name: string) => (enabled?: boolean) => {
|
||||
|
||||
// @ts-ignore
|
||||
dispatch(updateSettings({ [name]: enabled }));
|
||||
}, [ dispatch, updateSettings ]);
|
||||
}, [ dispatch ]);
|
||||
|
||||
return (
|
||||
<FormSection
|
||||
@@ -74,7 +82,7 @@ const ConferenceSection = () => {
|
||||
onChange = { onChangeServerURL }
|
||||
placeholder = { defaultServerURL }
|
||||
textContentType = { 'URL' } // iOS only
|
||||
value = { serverURL ?? '' } />
|
||||
value = { newServerURL } />
|
||||
{
|
||||
switches.map(({ label, state, name }) => (
|
||||
<FormRow
|
||||
|
||||
Reference in New Issue
Block a user