Make web use the redux settings/profile

This commit is contained in:
zbettenbuk
2018-04-12 21:58:20 +02:00
committed by Saúl Ibarra Corretgé
parent ab7e572162
commit 959db3a665
29 changed files with 455 additions and 434 deletions

View File

@@ -2,7 +2,7 @@
import { Component } from 'react';
import { updateProfile } from '../../base/profile';
import { updateSettings } from '../../base/settings';
/**
* The type of the React {@code Component} props of
@@ -11,19 +11,17 @@ import { updateProfile } from '../../base/profile';
type Props = {
/**
* The current profile object.
*
* @protected
*/
_profile: Object,
/**
* The default URL for when there is no custom URL set in the profile.
* The default URL for when there is no custom URL set in the settings.
*
* @protected
*/
_serverURL: string,
/**
* The current settings object.
*/
_settings: Object,
/**
* Whether {@link AbstractSettingsView} is visible.
*
@@ -79,7 +77,7 @@ export class AbstractSettingsView extends Component<Props> {
* @returns {void}
*/
_onChangeDisplayName(text) {
this._updateProfile({
this._updateSettings({
displayName: text
});
}
@@ -94,7 +92,7 @@ export class AbstractSettingsView extends Component<Props> {
* @returns {void}
*/
_onChangeEmail(text) {
this._updateProfile({
this._updateSettings({
email: text
});
}
@@ -109,7 +107,7 @@ export class AbstractSettingsView extends Component<Props> {
* @returns {void}
*/
_onChangeServerURL(text) {
this._updateProfile({
this._updateSettings({
serverURL: text
});
}
@@ -125,7 +123,7 @@ export class AbstractSettingsView extends Component<Props> {
* @returns {void}
*/
_onStartAudioMutedChange(newValue) {
this._updateProfile({
this._updateSettings({
startWithAudioMuted: newValue
});
}
@@ -141,22 +139,23 @@ export class AbstractSettingsView extends Component<Props> {
* @returns {void}
*/
_onStartVideoMutedChange(newValue) {
this._updateProfile({
this._updateSettings({
startWithVideoMuted: newValue
});
}
_updateProfile: (Object) => void;
_updateSettings: (Object) => void;
/**
* Updates the persisted profile on any change.
* Updates the persisted settings on any change.
*
* @param {Object} updateObject - The partial update object for the profile.
* @param {Object} updateObject - The partial update object for the
* settings.
* @private
* @returns {void}
*/
_updateProfile(updateObject: Object) {
this.props.dispatch(updateProfile(updateObject));
_updateSettings(updateObject: Object) {
this.props.dispatch(updateSettings(updateObject));
}
}
@@ -167,15 +166,15 @@ export class AbstractSettingsView extends Component<Props> {
* @param {Object} state - The redux state.
* @protected
* @returns {{
* _profile: Object,
* _serverURL: string,
* _settings: Object,
* _visible: boolean
* }}
*/
export function _mapStateToProps(state: Object) {
return {
_profile: state['features/base/profile'],
_serverURL: state['features/app'].app._getDefaultURL(),
_settings: state['features/base/settings'],
_visible: state['features/settings'].visible
};
}

View File

@@ -120,7 +120,7 @@ class SettingsView extends AbstractSettingsView {
* @returns {void}
*/
_processServerURL(hideOnSuccess: boolean) {
const { serverURL } = this.props._profile;
const { serverURL } = this.props._settings;
const normalizedURL = normalizeUserInputURL(serverURL);
if (normalizedURL === null) {
@@ -140,7 +140,7 @@ class SettingsView extends AbstractSettingsView {
* @returns {React$Element}
*/
_renderBody() {
const { _profile } = this.props;
const { _settings } = this.props;
return (
<SafeAreaView style = { styles.settingsForm }>
@@ -154,7 +154,7 @@ class SettingsView extends AbstractSettingsView {
autoCorrect = { false }
onChangeText = { this._onChangeDisplayName }
placeholder = 'John Doe'
value = { _profile.displayName } />
value = { _settings.displayName } />
</FormRow>
<FormRow i18nLabel = 'settingsView.email'>
<TextInput
@@ -163,7 +163,7 @@ class SettingsView extends AbstractSettingsView {
keyboardType = { 'email-address' }
onChangeText = { this._onChangeEmail }
placeholder = 'email@example.com'
value = { _profile.email } />
value = { _settings.email } />
</FormRow>
<FormSectionHeader
i18nLabel = 'settingsView.conferenceSection' />
@@ -176,19 +176,19 @@ class SettingsView extends AbstractSettingsView {
onBlur = { this._onBlurServerURL }
onChangeText = { this._onChangeServerURL }
placeholder = { this.props._serverURL }
value = { _profile.serverURL } />
value = { _settings.serverURL } />
</FormRow>
<FormRow
fieldSeparator = { true }
i18nLabel = 'settingsView.startWithAudioMuted'>
<Switch
onValueChange = { this._onStartAudioMutedChange }
value = { _profile.startWithAudioMuted } />
value = { _settings.startWithAudioMuted } />
</FormRow>
<FormRow i18nLabel = 'settingsView.startWithVideoMuted'>
<Switch
onValueChange = { this._onStartVideoMutedChange }
value = { _profile.startWithVideoMuted } />
value = { _settings.startWithVideoMuted } />
</FormRow>
</ScrollView>
</SafeAreaView>