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
28
main.js
28
main.js
|
@ -403,7 +403,10 @@ async function createWindow() {
|
||||||
),
|
),
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
spellcheck: await getSpellCheckSetting(),
|
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,
|
enablePreferredSizeMode: true,
|
||||||
},
|
},
|
||||||
icon: windowIcon,
|
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) => {
|
ipc.on('convert-image', async (event, uuid, data) => {
|
||||||
const { error, response } = await heicConverter(uuid, data);
|
const { error, response } = await heicConverter(uuid, data);
|
||||||
event.reply(`convert-image:${uuid}`, { error, response });
|
event.reply(`convert-image:${uuid}`, { error, response });
|
||||||
|
|
|
@ -87,6 +87,7 @@ const createProps = (storyProps: Partial<PropsType> = {}): PropsType => ({
|
||||||
renderDeviceSelection: () => <div />,
|
renderDeviceSelection: () => <div />,
|
||||||
renderSafetyNumberViewer: (_: SafetyNumberViewerProps) => <div />,
|
renderSafetyNumberViewer: (_: SafetyNumberViewerProps) => <div />,
|
||||||
setGroupCallVideoRequest: action('set-group-call-video-request'),
|
setGroupCallVideoRequest: action('set-group-call-video-request'),
|
||||||
|
setIsCallActive: action('set-is-call-active'),
|
||||||
setLocalAudio: action('set-local-audio'),
|
setLocalAudio: action('set-local-audio'),
|
||||||
setLocalPreview: action('set-local-preview'),
|
setLocalPreview: action('set-local-preview'),
|
||||||
setLocalVideo: action('set-local-video'),
|
setLocalVideo: action('set-local-video'),
|
||||||
|
|
|
@ -86,6 +86,7 @@ export type PropsType = {
|
||||||
openSystemPreferencesAction: () => unknown;
|
openSystemPreferencesAction: () => unknown;
|
||||||
playRingtone: () => unknown;
|
playRingtone: () => unknown;
|
||||||
setGroupCallVideoRequest: (_: SetGroupCallVideoRequestType) => void;
|
setGroupCallVideoRequest: (_: SetGroupCallVideoRequestType) => void;
|
||||||
|
setIsCallActive: (_: boolean) => void;
|
||||||
setLocalAudio: (_: SetLocalAudioType) => void;
|
setLocalAudio: (_: SetLocalAudioType) => void;
|
||||||
setLocalVideo: (_: SetLocalVideoType) => void;
|
setLocalVideo: (_: SetLocalVideoType) => void;
|
||||||
setLocalPreview: (_: SetLocalPreviewType) => void;
|
setLocalPreview: (_: SetLocalPreviewType) => void;
|
||||||
|
@ -366,9 +367,15 @@ export const CallManager: React.FC<PropsType> = props => {
|
||||||
notifyForCall,
|
notifyForCall,
|
||||||
playRingtone,
|
playRingtone,
|
||||||
stopRingtone,
|
stopRingtone,
|
||||||
|
setIsCallActive,
|
||||||
setOutgoingRing,
|
setOutgoingRing,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const isCallActive = Boolean(activeCall);
|
||||||
|
useEffect(() => {
|
||||||
|
setIsCallActive(isCallActive);
|
||||||
|
}, [isCallActive, setIsCallActive]);
|
||||||
|
|
||||||
const shouldRing = getShouldRing(props);
|
const shouldRing = getShouldRing(props);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldRing) {
|
if (shouldRing) {
|
||||||
|
|
|
@ -7,6 +7,9 @@ import { NativeThemeState } from '../types/NativeThemeNotifier.d';
|
||||||
export type Callback = (change: NativeThemeState) => void;
|
export type Callback = (change: NativeThemeState) => void;
|
||||||
|
|
||||||
export interface MinimalIPC {
|
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
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
sendSync(channel: string): any;
|
sendSync(channel: string): any;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,11 @@ export class Context {
|
||||||
|
|
||||||
public readonly nativeThemeListener;
|
public readonly nativeThemeListener;
|
||||||
|
|
||||||
constructor(ipc: MinimalIPC) {
|
constructor(private readonly ipc: MinimalIPC) {
|
||||||
this.nativeThemeListener = createNativeThemeListener(ipc, window);
|
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(
|
function setLocalPreview(
|
||||||
payload: SetLocalPreviewType
|
payload: SetLocalPreviewType
|
||||||
): ThunkAction<void, RootStateType, unknown, never> {
|
): ThunkAction<void, RootStateType, unknown, never> {
|
||||||
|
@ -1203,6 +1211,7 @@ export const actions = {
|
||||||
remoteVideoChange,
|
remoteVideoChange,
|
||||||
returnToActiveCall,
|
returnToActiveCall,
|
||||||
setGroupCallVideoRequest,
|
setGroupCallVideoRequest,
|
||||||
|
setIsCallActive,
|
||||||
setLocalAudio,
|
setLocalAudio,
|
||||||
setLocalPreview,
|
setLocalPreview,
|
||||||
setLocalVideo,
|
setLocalVideo,
|
||||||
|
|
|
@ -20,6 +20,13 @@ class FakeIPC extends EventEmitter implements MinimalIPC {
|
||||||
assert.strictEqual(channel, 'native-theme:init');
|
assert.strictEqual(channel, 'native-theme:init');
|
||||||
return this.state;
|
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', () => {
|
describe('NativeThemeListener', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue