In prerelease, enable background throttling when not on a call
This commit is contained in:
parent
2f7226e200
commit
942ce16610
28
main.js
28
main.js
|
@ -403,7 +403,10 @@ async function createWindow() {
|
|||
),
|
||||
nativeWindowOpen: true,
|
||||
spellcheck: await getSpellCheckSetting(),
|
||||
backgroundThrottling: false,
|
||||
// We are evaluating background throttling in prerelease versions. If we decide to
|
||||
// move forward, we can remove this line (as `backgroundThrottling` is true by
|
||||
// default).
|
||||
backgroundThrottling: !isProduction(app.getVersion()),
|
||||
enablePreferredSizeMode: true,
|
||||
},
|
||||
icon: windowIcon,
|
||||
|
@ -664,6 +667,29 @@ ipc.on('title-bar-double-click', () => {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('set-is-call-active', (_event, isCallActive) => {
|
||||
if (!mainWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We are evaluating background throttling in prerelease versions. If we decide to move
|
||||
// forward, we can remove this check.
|
||||
if (isProduction(app.getVersion())) {
|
||||
return;
|
||||
}
|
||||
|
||||
let backgroundThrottling;
|
||||
if (isCallActive) {
|
||||
console.log('Background throttling disabled because a call is active');
|
||||
backgroundThrottling = false;
|
||||
} else {
|
||||
console.log('Background throttling enabled because no call is active');
|
||||
backgroundThrottling = true;
|
||||
}
|
||||
|
||||
mainWindow.webContents.setBackgroundThrottling(backgroundThrottling);
|
||||
});
|
||||
|
||||
ipc.on('convert-image', async (event, uuid, data) => {
|
||||
const { error, response } = await heicConverter(uuid, data);
|
||||
event.reply(`convert-image:${uuid}`, { error, response });
|
||||
|
|
|
@ -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…
Reference in New Issue