2022-10-13 08:26:28 +00:00
|
|
|
import { UPDATE_DEVICE_LIST } from '../base/devices/actionTypes';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
2019-03-28 12:21:38 +00:00
|
|
|
|
2017-06-04 03:12:04 +00:00
|
|
|
/**
|
|
|
|
* Implements the middleware of the feature device-selection.
|
|
|
|
*
|
|
|
|
* @param {Store} store - Redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
if (action.type === UPDATE_DEVICE_LIST) {
|
2019-03-28 12:21:38 +00:00
|
|
|
const state = store.getState();
|
2020-06-19 13:21:00 +00:00
|
|
|
const { availableDevices } = state['features/base/devices'] || {};
|
2017-06-04 03:12:04 +00:00
|
|
|
|
2019-03-28 12:21:38 +00:00
|
|
|
if (typeof APP !== 'undefined') {
|
2019-03-28 16:29:30 +00:00
|
|
|
APP.API.notifyDeviceListChanged(availableDevices);
|
2017-06-04 03:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
});
|