You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. import _ from 'lodash';
  2. import { CONFERENCE_INFO } from '../../conference/components/constants';
  3. import ReducerRegistry from '../redux/ReducerRegistry';
  4. import { equals } from '../redux/functions';
  5. import {
  6. CONFIG_WILL_LOAD,
  7. LOAD_CONFIG_ERROR,
  8. OVERWRITE_CONFIG,
  9. SET_CONFIG,
  10. UPDATE_CONFIG
  11. } from './actionTypes';
  12. import {
  13. IConfig,
  14. IDeeplinkingConfig,
  15. IDeeplinkingMobileConfig,
  16. IDeeplinkingPlatformConfig,
  17. IMobileDynamicLink
  18. } from './configType';
  19. import { _cleanupConfig, _setDeeplinkingDefaults } from './functions';
  20. /**
  21. * The initial state of the feature base/config when executing in a
  22. * non-React Native environment. The mandatory configuration to be passed to
  23. * JitsiMeetJS#init(). The app will download config.js from the Jitsi Meet
  24. * deployment and take its values into account but the values below will be
  25. * enforced (because they are essential to the correct execution of the
  26. * application).
  27. *
  28. * @type {Object}
  29. */
  30. const INITIAL_NON_RN_STATE: IConfig = {
  31. };
  32. /**
  33. * The initial state of the feature base/config when executing in a React Native
  34. * environment. The mandatory configuration to be passed to JitsiMeetJS#init().
  35. * The app will download config.js from the Jitsi Meet deployment and take its
  36. * values into account but the values below will be enforced (because they are
  37. * essential to the correct execution of the application).
  38. *
  39. * @type {Object}
  40. */
  41. const INITIAL_RN_STATE: IConfig = {
  42. analytics: {},
  43. // FIXME The support for audio levels in lib-jitsi-meet polls the statistics
  44. // of WebRTC at a short interval multiple times a second. Unfortunately,
  45. // React Native is slow to fetch these statistics from the native WebRTC
  46. // API, through the React Native bridge and eventually to JavaScript.
  47. // Because the audio levels are of no interest to the mobile app, it is
  48. // fastest to merely disable them.
  49. disableAudioLevels: true,
  50. // FIXME: Mobile codecs should probably be configurable separately, rather
  51. // than requiring this override here...
  52. p2p: {
  53. disabledCodec: 'vp9',
  54. preferredCodec: 'vp8'
  55. },
  56. videoQuality: {
  57. disabledCodec: 'vp9',
  58. preferredCodec: 'vp8'
  59. }
  60. };
  61. /**
  62. * Mapping between old configs controlling the conference info headers visibility and the
  63. * new configs. Needed in order to keep backwards compatibility.
  64. */
  65. const CONFERENCE_HEADER_MAPPING: any = {
  66. hideConferenceTimer: [ 'conference-timer' ],
  67. hideConferenceSubject: [ 'subject' ],
  68. hideParticipantsStats: [ 'participants-count' ],
  69. hideRecordingLabel: [ 'recording' ]
  70. };
  71. export interface IConfigState extends IConfig {
  72. analysis?: {
  73. obfuscateRoomName?: boolean;
  74. };
  75. disableRemoteControl?: boolean;
  76. error?: Error;
  77. }
  78. ReducerRegistry.register<IConfigState>('features/base/config', (state = _getInitialState(), action): IConfigState => {
  79. switch (action.type) {
  80. case UPDATE_CONFIG:
  81. return _updateConfig(state, action);
  82. case CONFIG_WILL_LOAD:
  83. return {
  84. error: undefined,
  85. /**
  86. * The URL of the location associated with/configured by this
  87. * configuration.
  88. *
  89. * @type URL
  90. */
  91. locationURL: action.locationURL
  92. };
  93. case LOAD_CONFIG_ERROR:
  94. // XXX LOAD_CONFIG_ERROR is one of the settlement execution paths of
  95. // the asynchronous "loadConfig procedure/process" started with
  96. // CONFIG_WILL_LOAD. Due to the asynchronous nature of it, whoever
  97. // is settling the process needs to provide proof that they have
  98. // started it and that the iteration of the process being completed
  99. // now is still of interest to the app.
  100. if (state.locationURL === action.locationURL) {
  101. return {
  102. /**
  103. * The {@link Error} which prevented the loading of the
  104. * configuration of the associated {@code locationURL}.
  105. *
  106. * @type Error
  107. */
  108. error: action.error
  109. };
  110. }
  111. break;
  112. case SET_CONFIG:
  113. return _setConfig(state, action);
  114. case OVERWRITE_CONFIG:
  115. return {
  116. ...state,
  117. ...action.config
  118. };
  119. }
  120. return state;
  121. });
  122. /**
  123. * Gets the initial state of the feature base/config. The mandatory
  124. * configuration to be passed to JitsiMeetJS#init(). The app will download
  125. * config.js from the Jitsi Meet deployment and take its values into account but
  126. * the values below will be enforced (because they are essential to the correct
  127. * execution of the application).
  128. *
  129. * @returns {Object}
  130. */
  131. function _getInitialState() {
  132. return (
  133. navigator.product === 'ReactNative'
  134. ? INITIAL_RN_STATE
  135. : INITIAL_NON_RN_STATE);
  136. }
  137. /**
  138. * Reduces a specific Redux action SET_CONFIG of the feature
  139. * base/lib-jitsi-meet.
  140. *
  141. * @param {IConfig} state - The Redux state of the feature base/config.
  142. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  143. * @private
  144. * @returns {Object} The new state after the reduction of the specified action.
  145. */
  146. function _setConfig(state: IConfig, { config }: { config: IConfig; }) {
  147. // eslint-disable-next-line no-param-reassign
  148. config = _translateLegacyConfig(config);
  149. const { audioQuality } = config;
  150. const hdAudioOptions = {};
  151. if (audioQuality?.stereo) {
  152. Object.assign(hdAudioOptions, {
  153. disableAP: true,
  154. enableNoAudioDetection: false,
  155. enableNoisyMicDetection: false,
  156. enableTalkWhileMuted: false
  157. });
  158. }
  159. const newState = _.merge(
  160. {},
  161. config,
  162. hdAudioOptions,
  163. { error: undefined },
  164. // The config of _getInitialState() is meant to override the config
  165. // downloaded from the Jitsi Meet deployment because the former contains
  166. // values that are mandatory.
  167. _getInitialState()
  168. );
  169. _cleanupConfig(newState);
  170. return equals(state, newState) ? state : newState;
  171. }
  172. /**
  173. * Processes the conferenceInfo object against the defaults.
  174. *
  175. * @param {IConfig} config - The old config.
  176. * @returns {Object} The processed conferenceInfo object.
  177. */
  178. function _getConferenceInfo(config: IConfig) {
  179. const { conferenceInfo } = config;
  180. if (conferenceInfo) {
  181. return {
  182. alwaysVisible: conferenceInfo.alwaysVisible ?? [ ...CONFERENCE_INFO.alwaysVisible ],
  183. autoHide: conferenceInfo.autoHide ?? [ ...CONFERENCE_INFO.autoHide ]
  184. };
  185. }
  186. return {
  187. ...CONFERENCE_INFO
  188. };
  189. }
  190. /**
  191. * Constructs a new config {@code Object}, if necessary, out of a specific
  192. * interface_config {@code Object} which is in the latest format supported by jitsi-meet.
  193. *
  194. * @param {Object} oldValue - The config {@code Object} which may or may not be
  195. * in the latest form supported by jitsi-meet and from which a new config
  196. * {@code Object} is to be constructed if necessary.
  197. * @returns {Object} A config {@code Object} which is in the latest format
  198. * supported by jitsi-meet.
  199. */
  200. function _translateInterfaceConfig(oldValue: IConfig) {
  201. const newValue = oldValue;
  202. if (!Array.isArray(oldValue.toolbarButtons)
  203. && typeof interfaceConfig === 'object' && Array.isArray(interfaceConfig.TOOLBAR_BUTTONS)) {
  204. newValue.toolbarButtons = interfaceConfig.TOOLBAR_BUTTONS;
  205. }
  206. if (!oldValue.toolbarConfig) {
  207. oldValue.toolbarConfig = {};
  208. }
  209. newValue.toolbarConfig = oldValue.toolbarConfig || {};
  210. if (typeof oldValue.toolbarConfig.alwaysVisible !== 'boolean'
  211. && typeof interfaceConfig === 'object'
  212. && typeof interfaceConfig.TOOLBAR_ALWAYS_VISIBLE === 'boolean') {
  213. newValue.toolbarConfig.alwaysVisible = interfaceConfig.TOOLBAR_ALWAYS_VISIBLE;
  214. }
  215. if (typeof oldValue.toolbarConfig.initialTimeout !== 'number'
  216. && typeof interfaceConfig === 'object'
  217. && typeof interfaceConfig.INITIAL_TOOLBAR_TIMEOUT === 'number') {
  218. newValue.toolbarConfig.initialTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  219. }
  220. if (typeof oldValue.toolbarConfig.timeout !== 'number'
  221. && typeof interfaceConfig === 'object'
  222. && typeof interfaceConfig.TOOLBAR_TIMEOUT === 'number') {
  223. newValue.toolbarConfig.timeout = interfaceConfig.TOOLBAR_TIMEOUT;
  224. }
  225. if (!oldValue.connectionIndicators
  226. && typeof interfaceConfig === 'object'
  227. && (interfaceConfig.hasOwnProperty('CONNECTION_INDICATOR_DISABLED')
  228. || interfaceConfig.hasOwnProperty('CONNECTION_INDICATOR_AUTO_HIDE_ENABLED')
  229. || interfaceConfig.hasOwnProperty('CONNECTION_INDICATOR_AUTO_HIDE_TIMEOUT'))) {
  230. newValue.connectionIndicators = {
  231. disabled: interfaceConfig.CONNECTION_INDICATOR_DISABLED,
  232. autoHide: interfaceConfig.CONNECTION_INDICATOR_AUTO_HIDE_ENABLED,
  233. autoHideTimeout: interfaceConfig.CONNECTION_INDICATOR_AUTO_HIDE_TIMEOUT
  234. };
  235. }
  236. if (oldValue.disableModeratorIndicator === undefined
  237. && typeof interfaceConfig === 'object'
  238. && interfaceConfig.hasOwnProperty('DISABLE_FOCUS_INDICATOR')) {
  239. newValue.disableModeratorIndicator = interfaceConfig.DISABLE_FOCUS_INDICATOR;
  240. }
  241. if (oldValue.defaultLocalDisplayName === undefined
  242. && typeof interfaceConfig === 'object'
  243. && interfaceConfig.hasOwnProperty('DEFAULT_LOCAL_DISPLAY_NAME')) {
  244. newValue.defaultLocalDisplayName = interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME;
  245. }
  246. if (oldValue.defaultRemoteDisplayName === undefined
  247. && typeof interfaceConfig === 'object'
  248. && interfaceConfig.hasOwnProperty('DEFAULT_REMOTE_DISPLAY_NAME')) {
  249. newValue.defaultRemoteDisplayName = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
  250. }
  251. if (oldValue.defaultLogoUrl === undefined) {
  252. if (typeof interfaceConfig === 'object'
  253. && interfaceConfig.hasOwnProperty('DEFAULT_LOGO_URL')) {
  254. newValue.defaultLogoUrl = interfaceConfig.DEFAULT_LOGO_URL;
  255. } else {
  256. newValue.defaultLogoUrl = 'images/watermark.svg';
  257. }
  258. }
  259. // if we have `deeplinking` defined, ignore deprecated values, except `disableDeepLinking`.
  260. // Otherwise, compose the config.
  261. if (oldValue.deeplinking && newValue.deeplinking) { // make TS happy
  262. newValue.deeplinking.disabled = oldValue.deeplinking.hasOwnProperty('disabled')
  263. ? oldValue.deeplinking.disabled
  264. : Boolean(oldValue.disableDeepLinking);
  265. } else {
  266. const disabled = Boolean(oldValue.disableDeepLinking);
  267. const deeplinking: IDeeplinkingConfig = {
  268. desktop: {} as IDeeplinkingPlatformConfig,
  269. hideLogo: false,
  270. disabled,
  271. android: {} as IDeeplinkingMobileConfig,
  272. ios: {} as IDeeplinkingMobileConfig
  273. };
  274. if (typeof interfaceConfig === 'object') {
  275. const mobileDynamicLink = interfaceConfig.MOBILE_DYNAMIC_LINK;
  276. const dynamicLink: IMobileDynamicLink | undefined = mobileDynamicLink ? {
  277. apn: mobileDynamicLink.APN,
  278. appCode: mobileDynamicLink.APP_CODE,
  279. ibi: mobileDynamicLink.IBI,
  280. isi: mobileDynamicLink.ISI,
  281. customDomain: mobileDynamicLink.CUSTOM_DOMAIN
  282. } : undefined;
  283. if (deeplinking.desktop) {
  284. deeplinking.desktop.appName = interfaceConfig.NATIVE_APP_NAME;
  285. }
  286. deeplinking.hideLogo = Boolean(interfaceConfig.HIDE_DEEP_LINKING_LOGO);
  287. deeplinking.android = {
  288. appName: interfaceConfig.NATIVE_APP_NAME,
  289. appScheme: interfaceConfig.APP_SCHEME,
  290. downloadLink: interfaceConfig.MOBILE_DOWNLOAD_LINK_ANDROID,
  291. appPackage: interfaceConfig.ANDROID_APP_PACKAGE,
  292. fDroidUrl: interfaceConfig.MOBILE_DOWNLOAD_LINK_F_DROID,
  293. dynamicLink
  294. };
  295. deeplinking.ios = {
  296. appName: interfaceConfig.NATIVE_APP_NAME,
  297. appScheme: interfaceConfig.APP_SCHEME,
  298. downloadLink: interfaceConfig.MOBILE_DOWNLOAD_LINK_IOS,
  299. dynamicLink
  300. };
  301. }
  302. newValue.deeplinking = deeplinking;
  303. }
  304. return newValue;
  305. }
  306. /**
  307. * Constructs a new config {@code Object}, if necessary, out of a specific
  308. * config {@code Object} which is in the latest format supported by jitsi-meet.
  309. * Such a translation from an old config format to a new/the latest config
  310. * format is necessary because the mobile app bundles jitsi-meet and
  311. * lib-jitsi-meet at build time and does not download them at runtime from the
  312. * deployment on which it will join a conference.
  313. *
  314. * @param {Object} oldValue - The config {@code Object} which may or may not be
  315. * in the latest form supported by jitsi-meet and from which a new config
  316. * {@code Object} is to be constructed if necessary.
  317. * @returns {Object} A config {@code Object} which is in the latest format
  318. * supported by jitsi-meet.
  319. */
  320. function _translateLegacyConfig(oldValue: IConfig) {
  321. const newValue = _translateInterfaceConfig(oldValue);
  322. // Translate deprecated config values to new config values.
  323. const filteredConferenceInfo = Object.keys(CONFERENCE_HEADER_MAPPING).filter(key => oldValue[key as keyof IConfig]);
  324. if (filteredConferenceInfo.length) {
  325. newValue.conferenceInfo = _getConferenceInfo(oldValue);
  326. filteredConferenceInfo.forEach(key => {
  327. newValue.conferenceInfo = oldValue.conferenceInfo ?? {};
  328. // hideRecordingLabel does not mean not render it at all, but autoHide it
  329. if (key === 'hideRecordingLabel') {
  330. newValue.conferenceInfo.alwaysVisible
  331. = (newValue.conferenceInfo?.alwaysVisible ?? [])
  332. .filter(c => !CONFERENCE_HEADER_MAPPING[key].includes(c));
  333. newValue.conferenceInfo.autoHide
  334. = _.union(newValue.conferenceInfo.autoHide, CONFERENCE_HEADER_MAPPING[key]);
  335. } else {
  336. newValue.conferenceInfo.alwaysVisible
  337. = (newValue.conferenceInfo.alwaysVisible ?? [])
  338. .filter(c => !CONFERENCE_HEADER_MAPPING[key].includes(c));
  339. newValue.conferenceInfo.autoHide
  340. = (newValue.conferenceInfo.autoHide ?? []).filter(c => !CONFERENCE_HEADER_MAPPING[key].includes(c));
  341. }
  342. });
  343. }
  344. newValue.welcomePage = oldValue.welcomePage || {};
  345. if (oldValue.hasOwnProperty('enableWelcomePage')
  346. && !newValue.welcomePage.hasOwnProperty('disabled')
  347. ) {
  348. newValue.welcomePage.disabled = !oldValue.enableWelcomePage;
  349. }
  350. newValue.prejoinConfig = oldValue.prejoinConfig || {};
  351. if (oldValue.hasOwnProperty('prejoinPageEnabled')
  352. && !newValue.prejoinConfig.hasOwnProperty('enabled')
  353. ) {
  354. newValue.prejoinConfig.enabled = oldValue.prejoinPageEnabled;
  355. }
  356. newValue.disabledSounds = newValue.disabledSounds || [];
  357. if (oldValue.disableJoinLeaveSounds) {
  358. newValue.disabledSounds.unshift('PARTICIPANT_LEFT_SOUND', 'PARTICIPANT_JOINED_SOUND');
  359. }
  360. if (oldValue.disableRecordAudioNotification) {
  361. newValue.disabledSounds.unshift(
  362. 'RECORDING_ON_SOUND',
  363. 'RECORDING_OFF_SOUND',
  364. 'LIVE_STREAMING_ON_SOUND',
  365. 'LIVE_STREAMING_OFF_SOUND'
  366. );
  367. }
  368. if (oldValue.disableIncomingMessageSound) {
  369. newValue.disabledSounds.unshift('INCOMING_MSG_SOUND');
  370. }
  371. if (oldValue.stereo || oldValue.opusMaxAverageBitrate) {
  372. newValue.audioQuality = {
  373. opusMaxAverageBitrate: oldValue.audioQuality?.opusMaxAverageBitrate ?? oldValue.opusMaxAverageBitrate,
  374. stereo: oldValue.audioQuality?.stereo ?? oldValue.stereo
  375. };
  376. }
  377. newValue.e2ee = newValue.e2ee || {};
  378. if (oldValue.e2eeLabels) {
  379. newValue.e2ee.e2eeLabels = oldValue.e2eeLabels;
  380. }
  381. newValue.defaultLocalDisplayName
  382. = newValue.defaultLocalDisplayName || 'me';
  383. if (oldValue.hideAddRoomButton) {
  384. newValue.breakoutRooms = {
  385. /* eslint-disable-next-line no-extra-parens */
  386. ...(newValue.breakoutRooms || {}),
  387. hideAddRoomButton: oldValue.hideAddRoomButton
  388. };
  389. }
  390. newValue.defaultRemoteDisplayName
  391. = newValue.defaultRemoteDisplayName || 'Fellow Jitster';
  392. newValue.transcription = newValue.transcription || {};
  393. if (oldValue.transcribingEnabled !== undefined) {
  394. newValue.transcription = {
  395. ...newValue.transcription,
  396. enabled: oldValue.transcribingEnabled
  397. };
  398. }
  399. if (oldValue.transcribeWithAppLanguage !== undefined) {
  400. newValue.transcription = {
  401. ...newValue.transcription,
  402. useAppLanguage: oldValue.transcribeWithAppLanguage
  403. };
  404. }
  405. if (oldValue.preferredTranscribeLanguage !== undefined) {
  406. newValue.transcription = {
  407. ...newValue.transcription,
  408. preferredLanguage: oldValue.preferredTranscribeLanguage
  409. };
  410. }
  411. if (oldValue.autoCaptionOnRecord !== undefined) {
  412. newValue.transcription = {
  413. ...newValue.transcription,
  414. autoCaptionOnRecord: oldValue.autoCaptionOnRecord
  415. };
  416. }
  417. newValue.recordingService = newValue.recordingService || {};
  418. if (oldValue.fileRecordingsServiceEnabled !== undefined
  419. && newValue.recordingService.enabled === undefined) {
  420. newValue.recordingService = {
  421. ...newValue.recordingService,
  422. enabled: oldValue.fileRecordingsServiceEnabled
  423. };
  424. }
  425. if (oldValue.fileRecordingsServiceSharingEnabled !== undefined
  426. && newValue.recordingService.sharingEnabled === undefined) {
  427. newValue.recordingService = {
  428. ...newValue.recordingService,
  429. sharingEnabled: oldValue.fileRecordingsServiceSharingEnabled
  430. };
  431. }
  432. newValue.liveStreaming = newValue.liveStreaming || {};
  433. // Migrate config.liveStreamingEnabled
  434. if (oldValue.liveStreamingEnabled !== undefined) {
  435. newValue.liveStreaming = {
  436. ...newValue.liveStreaming,
  437. enabled: oldValue.liveStreamingEnabled
  438. };
  439. }
  440. // Migrate interfaceConfig.LIVE_STREAMING_HELP_LINK
  441. if (oldValue.liveStreaming === undefined
  442. && typeof interfaceConfig === 'object'
  443. && interfaceConfig.hasOwnProperty('LIVE_STREAMING_HELP_LINK')) {
  444. newValue.liveStreaming = {
  445. ...newValue.liveStreaming,
  446. helpLink: interfaceConfig.LIVE_STREAMING_HELP_LINK
  447. };
  448. }
  449. newValue.speakerStats = newValue.speakerStats || {};
  450. if (oldValue.disableSpeakerStatsSearch !== undefined
  451. && newValue.speakerStats.disableSearch === undefined
  452. ) {
  453. newValue.speakerStats = {
  454. ...newValue.speakerStats,
  455. disableSearch: oldValue.disableSpeakerStatsSearch
  456. };
  457. }
  458. if (oldValue.speakerStatsOrder !== undefined
  459. && newValue.speakerStats.order === undefined) {
  460. newValue.speakerStats = {
  461. ...newValue.speakerStats,
  462. order: oldValue.speakerStatsOrder
  463. };
  464. }
  465. if (oldValue.autoKnockLobby !== undefined
  466. && newValue.lobby?.autoKnock === undefined) {
  467. newValue.lobby = {
  468. ...newValue.lobby || {},
  469. autoKnock: oldValue.autoKnockLobby
  470. };
  471. }
  472. if (oldValue.enableLobbyChat !== undefined
  473. && newValue.lobby?.enableChat === undefined) {
  474. newValue.lobby = {
  475. ...newValue.lobby || {},
  476. enableChat: oldValue.enableLobbyChat
  477. };
  478. }
  479. if (oldValue.hideLobbyButton !== undefined
  480. && newValue.securityUi?.hideLobbyButton === undefined) {
  481. newValue.securityUi = {
  482. ...newValue.securityUi || {},
  483. hideLobbyButton: oldValue.hideLobbyButton
  484. };
  485. }
  486. _setDeeplinkingDefaults(newValue.deeplinking as IDeeplinkingConfig);
  487. return newValue;
  488. }
  489. /**
  490. * Updates the stored configuration with the given extra options.
  491. *
  492. * @param {Object} state - The Redux state of the feature base/config.
  493. * @param {Action} action - The Redux action to reduce.
  494. * @private
  495. * @returns {Object} The new state after the reduction of the specified action.
  496. */
  497. function _updateConfig(state: IConfig, { config }: { config: IConfig; }) {
  498. const newState = _.merge({}, state, config);
  499. _cleanupConfig(newState);
  500. return equals(state, newState) ? state : newState;
  501. }