In prerelease, enable background throttling when not on a call
This commit is contained in:
parent
2f7226e200
commit
942ce16610
7 changed files with 59 additions and 2 deletions
|
@ -87,6 +87,7 @@ const createProps = (storyProps: Partial<PropsType> = {}): PropsType => ({
|
|||
renderDeviceSelection: () => <div />,
|
||||
renderSafetyNumberViewer: (_: SafetyNumberViewerProps) => <div />,
|
||||
setGroupCallVideoRequest: action('set-group-call-video-request'),
|
||||
setIsCallActive: action('set-is-call-active'),
|
||||
setLocalAudio: action('set-local-audio'),
|
||||
setLocalPreview: action('set-local-preview'),
|
||||
setLocalVideo: action('set-local-video'),
|
||||
|
|
|
@ -86,6 +86,7 @@ export type PropsType = {
|
|||
openSystemPreferencesAction: () => unknown;
|
||||
playRingtone: () => unknown;
|
||||
setGroupCallVideoRequest: (_: SetGroupCallVideoRequestType) => void;
|
||||
setIsCallActive: (_: boolean) => void;
|
||||
setLocalAudio: (_: SetLocalAudioType) => void;
|
||||
setLocalVideo: (_: SetLocalVideoType) => void;
|
||||
setLocalPreview: (_: SetLocalPreviewType) => void;
|
||||
|
@ -366,9 +367,15 @@ export const CallManager: React.FC<PropsType> = props => {
|
|||
notifyForCall,
|
||||
playRingtone,
|
||||
stopRingtone,
|
||||
setIsCallActive,
|
||||
setOutgoingRing,
|
||||
} = props;
|
||||
|
||||
const isCallActive = Boolean(activeCall);
|
||||
useEffect(() => {
|
||||
setIsCallActive(isCallActive);
|
||||
}, [isCallActive, setIsCallActive]);
|
||||
|
||||
const shouldRing = getShouldRing(props);
|
||||
useEffect(() => {
|
||||
if (shouldRing) {
|
||||
|
|
|
@ -7,6 +7,9 @@ import { NativeThemeState } from '../types/NativeThemeNotifier.d';
|
|||
export type Callback = (change: NativeThemeState) => void;
|
||||
|
||||
export interface MinimalIPC {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
send(channel: string, ...args: ReadonlyArray<any>): void;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
sendSync(channel: string): any;
|
||||
|
||||
|
|
|
@ -15,7 +15,11 @@ export class Context {
|
|||
|
||||
public readonly nativeThemeListener;
|
||||
|
||||
constructor(ipc: MinimalIPC) {
|
||||
constructor(private readonly ipc: MinimalIPC) {
|
||||
this.nativeThemeListener = createNativeThemeListener(ipc, window);
|
||||
}
|
||||
|
||||
setIsCallActive(isCallActive: boolean): void {
|
||||
this.ipc.send('set-is-call-active', isCallActive);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -960,6 +960,14 @@ function returnToActiveCall(): ReturnToActiveCallActionType {
|
|||
};
|
||||
}
|
||||
|
||||
function setIsCallActive(
|
||||
isCallActive: boolean
|
||||
): ThunkAction<void, RootStateType, unknown, never> {
|
||||
return () => {
|
||||
window.SignalContext.setIsCallActive(isCallActive);
|
||||
};
|
||||
}
|
||||
|
||||
function setLocalPreview(
|
||||
payload: SetLocalPreviewType
|
||||
): ThunkAction<void, RootStateType, unknown, never> {
|
||||
|
@ -1203,6 +1211,7 @@ export const actions = {
|
|||
remoteVideoChange,
|
||||
returnToActiveCall,
|
||||
setGroupCallVideoRequest,
|
||||
setIsCallActive,
|
||||
setLocalAudio,
|
||||
setLocalPreview,
|
||||
setLocalVideo,
|
||||
|
|
|
@ -20,6 +20,13 @@ class FakeIPC extends EventEmitter implements MinimalIPC {
|
|||
assert.strictEqual(channel, 'native-theme:init');
|
||||
return this.state;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
public send() {
|
||||
throw new Error(
|
||||
'This should not be called. It is only here to satisfy the interface'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
describe('NativeThemeListener', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue