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 1015B

1234567891011121314151617181920212223242526272829303132333435
  1. import KeepAwake from 'react-native-keep-awake';
  2. import { getCurrentConference } from '../../base/conference';
  3. import { StateListenerRegistry } from '../../base/redux';
  4. /**
  5. * State listener that activates or deactivates the wake lock accordingly. If
  6. * the wake lock is active, it will prevent the screen from dimming.
  7. */
  8. StateListenerRegistry.register(
  9. /* selector */ state => {
  10. const { enabled: audioOnly } = state['features/base/audio-only'];
  11. const conference = getCurrentConference(state);
  12. return Boolean(conference && !audioOnly);
  13. },
  14. /* listener */ wakeLock => _setWakeLock(wakeLock)
  15. );
  16. /**
  17. * Activates/deactivates the wake lock. If the wake lock is active, it will
  18. * prevent the screen from dimming.
  19. *
  20. * @param {boolean} wakeLock - True to active the wake lock or false to
  21. * deactivate it.
  22. * @private
  23. * @returns {void}
  24. */
  25. function _setWakeLock(wakeLock) {
  26. if (wakeLock) {
  27. KeepAwake.activate();
  28. } else {
  29. KeepAwake.deactivate();
  30. }
  31. }