diff options
author | Saúl Ibarra Corretgé <s@saghul.net> | 2020-04-14 10:35:33 +0200 |
---|---|---|
committer | Saúl Ibarra Corretgé <s@saghul.net> | 2020-04-14 13:21:19 +0200 |
commit | b72ea5a1237269f2a657cdc17d40238ad77c420c (patch) | |
tree | a1e0d126516d1ad47803435735ad4ce46652383e | |
parent | 2794692cbf43e17eac3ec87b72635315d6f919e1 (diff) |
Fix show AoT window default value
-rw-r--r-- | app/features/conference/components/Conference.js | 5 | ||||
-rw-r--r-- | app/features/settings/functions.js | 20 | ||||
-rw-r--r-- | app/features/settings/index.js | 1 |
3 files changed, 24 insertions, 2 deletions
diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js index 8d02fe3..30d6139 100644 --- a/app/features/conference/components/Conference.js +++ b/app/features/conference/components/Conference.js @@ -8,7 +8,7 @@ import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import config from '../../config'; -import { setEmail, setName } from '../../settings'; +import { getSetting, setEmail, setName } from '../../settings'; import { conferenceEnded, conferenceJoined } from '../actions'; import { LoadingIndicator, Wrapper } from '../styled'; @@ -407,7 +407,8 @@ class Conference extends Component<Props, State> { */ function _mapStateToProps(state: Object) { return { - _alwaysOnTopWindowEnabled: state.settings.alwaysOnTopWindowEnabled, + _alwaysOnTopWindowEnabled: + getSetting(state, 'alwaysOnTopWindowEnabled', true), _avatarURL: state.settings.avatarURL, _email: state.settings.email, _name: state.settings.name, diff --git a/app/features/settings/functions.js b/app/features/settings/functions.js new file mode 100644 index 0000000..b3a7392 --- /dev/null +++ b/app/features/settings/functions.js @@ -0,0 +1,20 @@ +// @flow + +/** + * Get's the value for the given setting, providing a default value. + * + * @param {Object} state - The redux state. + * @param {string} setting - The name for the desired setting. + * @param {*} defaultValue - The default value, in case the setting is + * undefined. + * @returns {*} The setting value. + */ +export function getSetting(state: Object, setting: string, defaultValue: any) { + const value = state.settings[setting]; + + if (typeof value === 'undefined') { + return defaultValue; + } + + return value; +} diff --git a/app/features/settings/index.js b/app/features/settings/index.js index 17b8002..40f520e 100644 --- a/app/features/settings/index.js +++ b/app/features/settings/index.js @@ -1,6 +1,7 @@ export * from './actions'; export * from './actionTypes'; export * from './components'; +export * from './functions'; export * from './styled'; export { default as middleware } from './middleware'; |