Files
jitsi-meet/react/features/mobile/wake-lock/middleware.js
Saúl Ibarra Corretgé 467c9d36cf audio-only,lastn: move audio-only and last N handling to standalone features
This refactors all handling of audio-only and last N to 2 features in preparation
for "low bandwidth mode".

The main motivation to do this is that lastN is a "global" setting so it helps
to have all processing for it in a single place.
2019-08-02 15:54:47 +02:00

36 lines
1015 B
JavaScript

import KeepAwake from 'react-native-keep-awake';
import { getCurrentConference } from '../../base/conference';
import { StateListenerRegistry } from '../../base/redux';
/**
* State listener that activates or deactivates the wake lock accordingly. If
* the wake lock is active, it will prevent the screen from dimming.
*/
StateListenerRegistry.register(
/* selector */ state => {
const { enabled: audioOnly } = state['features/base/audio-only'];
const conference = getCurrentConference(state);
return Boolean(conference && !audioOnly);
},
/* listener */ wakeLock => _setWakeLock(wakeLock)
);
/**
* Activates/deactivates the wake lock. If the wake lock is active, it will
* prevent the screen from dimming.
*
* @param {boolean} wakeLock - True to active the wake lock or false to
* deactivate it.
* @private
* @returns {void}
*/
function _setWakeLock(wakeLock) {
if (wakeLock) {
KeepAwake.activate();
} else {
KeepAwake.deactivate();
}
}