snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
96
react/features/base/settings/middleware.native.ts
Normal file
96
react/features/base/settings/middleware.native.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import { IStore } from '../../app/types';
|
||||
import { APP_WILL_MOUNT } from '../app/actionTypes';
|
||||
import { setLowBandwidthMode } from '../low-bandwidth-mode/actions';
|
||||
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
|
||||
|
||||
import { SETTINGS_UPDATED } from './actionTypes';
|
||||
import { handleCallIntegrationChange, handleCrashReportingChange } from './functions.native';
|
||||
import { ISettingsState } from './reducer';
|
||||
|
||||
import './middleware.any';
|
||||
|
||||
/**
|
||||
* The middleware of the feature base/settings. Distributes changes to the state
|
||||
* of base/settings to the states of other features computed from the state of
|
||||
* base/settings.
|
||||
*
|
||||
* @param {Store} store - The redux store.
|
||||
* @returns {Function}
|
||||
*/
|
||||
MiddlewareRegistry.register(store => next => action => {
|
||||
const result = next(action);
|
||||
|
||||
switch (action.type) {
|
||||
case APP_WILL_MOUNT:
|
||||
_initializeCallIntegration(store);
|
||||
break;
|
||||
case SETTINGS_UPDATED:
|
||||
_maybeHandleCallIntegrationChange(action);
|
||||
_maybeCrashReportingChange(action);
|
||||
_maybeSetLowBandwidthMode(store, action);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
/**
|
||||
* Initializes the audio device handler based on the `disableCallIntegration` setting.
|
||||
*
|
||||
* @param {Store} store - The redux store.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _initializeCallIntegration({ getState }: IStore) {
|
||||
const { disableCallIntegration } = getState()['features/base/settings'];
|
||||
|
||||
if (typeof disableCallIntegration === 'boolean') {
|
||||
handleCallIntegrationChange(disableCallIntegration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a change in the `disableCallIntegration` setting.
|
||||
*
|
||||
* @param {Object} action - The redux action.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _maybeHandleCallIntegrationChange({ settings: { disableCallIntegration } }: {
|
||||
settings: Partial<ISettingsState>;
|
||||
}) {
|
||||
if (typeof disableCallIntegration === 'boolean') {
|
||||
handleCallIntegrationChange(disableCallIntegration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a change in the `disableCrashReporting` setting.
|
||||
*
|
||||
* @param {Object} action - The redux action.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _maybeCrashReportingChange({ settings: { disableCrashReporting } }: {
|
||||
settings: Partial<ISettingsState>;
|
||||
}) {
|
||||
if (typeof disableCrashReporting === 'boolean') {
|
||||
handleCrashReportingChange(disableCrashReporting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates {@code startLowBandwidthMode} flag if it's updated in the settings.
|
||||
*
|
||||
* @param {Store} store - The redux store.
|
||||
* @param {Object} action - The redux action.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _maybeSetLowBandwidthMode(
|
||||
{ dispatch }: IStore,
|
||||
{ settings: { startLowBandwidthMode } }: { settings: Partial<ISettingsState>; }) {
|
||||
if (typeof startLowBandwidthMode === 'boolean') {
|
||||
dispatch(setLowBandwidthMode(startLowBandwidthMode));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user