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.

middleware.js 1.2KB

123456789101112131415161718192021222324252627282930313233
  1. import { NativeModules } from 'react-native';
  2. import { getCurrentConference } from '../../base/conference';
  3. import { StateListenerRegistry } from '../../base/redux';
  4. /**
  5. * State listener which enables / disables the proximity sensor based on the
  6. * current conference state. If the proximity sensor is enabled, it will dim
  7. * the screen and disable touch controls when an object is nearby. The
  8. * functionality is enabled when a conference is in audio-only mode.
  9. */
  10. StateListenerRegistry.register(
  11. /* selector */ state => {
  12. const { enabled: audioOnly } = state['features/base/audio-only'];
  13. const conference = getCurrentConference(state);
  14. return Boolean(conference && audioOnly);
  15. },
  16. /* listener */ proximityEnabled => _setProximityEnabled(proximityEnabled)
  17. );
  18. /**
  19. * Enables / disables the proximity sensor. If the proximity sensor is enabled,
  20. * it will dim the screen and disable touch controls when an object is nearby.
  21. *
  22. * @param {boolean} enabled - True to enable the proximity sensor or false to
  23. * disable it.
  24. * @private
  25. * @returns {void}
  26. */
  27. function _setProximityEnabled(enabled) {
  28. NativeModules.Proximity.setEnabled(Boolean(enabled));
  29. }