2022-08-26 09:54:16 +00:00
|
|
|
import ReducerRegistry from '../../base/redux/ReducerRegistry';
|
|
|
|
import { equals, set } from '../../base/redux/functions';
|
2019-08-09 10:41:52 +00:00
|
|
|
|
|
|
|
import { _SET_AUDIOMODE_DEVICES, _SET_AUDIOMODE_SUBSCRIPTIONS } from './actionTypes';
|
|
|
|
|
2022-08-26 09:54:16 +00:00
|
|
|
export interface IMobileAudioModeState {
|
|
|
|
devices: Object[];
|
|
|
|
subscriptions: Object[];
|
|
|
|
}
|
|
|
|
|
2019-08-09 10:41:52 +00:00
|
|
|
const DEFAULT_STATE = {
|
|
|
|
devices: [],
|
|
|
|
subscriptions: []
|
|
|
|
};
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IMobileAudioModeState>('features/mobile/audio-mode',
|
|
|
|
(state = DEFAULT_STATE, action): IMobileAudioModeState => {
|
2019-08-09 10:41:52 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case _SET_AUDIOMODE_DEVICES: {
|
|
|
|
const { devices } = action;
|
|
|
|
|
|
|
|
if (equals(state.devices, devices)) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return set(state, 'devices', devices);
|
|
|
|
}
|
|
|
|
case _SET_AUDIOMODE_SUBSCRIPTIONS:
|
|
|
|
return set(state, 'subscriptions', action.subscriptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|