Files
jitsi-meet/react/features/mobile/wake-lock/middleware.ts
Calinteodor b511f4b8df dep(react-native): Update to 0.77.2 (#16160)
* This is a huge update, mostly because we updated Gradle on the Android side, which includes a more strict bundle process for third party modules. On iOS, even though new architecture is disabled, we had to be explicit about it because of this react native update and because some updated dependencies have it enabled by default and are using turbo modules which are not available, YET, in our project.
2025-07-10 14:56:43 +03:00

36 lines
1.1 KiB
TypeScript

import { activateKeepAwake, deactivateKeepAwake } from '@sayem314/react-native-keep-awake';
import { getCurrentConference } from '../../base/conference/functions';
import StateListenerRegistry from '../../base/redux/StateListenerRegistry';
/**
* 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: boolean) {
if (wakeLock) {
activateKeepAwake();
} else {
deactivateKeepAwake();
}
}